Skip to content

Commit

Permalink
chore: configure ruff (#18)
Browse files Browse the repository at this point in the history
We configure ruff as the project's formatter.
  • Loading branch information
Nirei authored Jan 2, 2025
1 parent 4908d52 commit ff6771d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ name = "pypi"
parsimonious = "*"

[dev-packages]
ruff = "*"

[requires]
python_version = "3.12"

[scripts]
test = "python run_tests.py"
test = "python run_tests.py"
30 changes: 28 additions & 2 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.ruff]
line-length = 120
38 changes: 28 additions & 10 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
import os
import subprocess

GREEN = "\033[32m"
RED = "\033[31m"
RESET = "\033[0m"


def run_tests():
failed_result = False
test_directory = 'tests'

test_directory = "tests"
errors = []

for file in os.listdir(test_directory):
if file.endswith('.imp'):
if file.endswith(".imp"):
test_path = os.path.join(test_directory, file)
print(f"Running test {test_path}")
print(f"Running test {test_path}", end=" ")
try:
subprocess.run(['./imperivm', test_path], check=True, text=True, capture_output=True)
print("\033[32mOK\033[0m")
subprocess.run(["./imperivm", test_path], check=True, text=True, capture_output=True)
print(f"{GREEN}OK{RESET}")
except subprocess.CalledProcessError as e:
print("\033[31mKO\033[0m")
print(f"Error: {e.stderr}")
print(f"{RED}KO{RESET}")
errors.append((test_path, e.stderr))
failed_result = True


if errors:
print("\nErrors:")
for test, error in errors:
print(f"On {test}")
print(f"{RED}{error}{RESET}")
print()

if errors:
print("Failed tests:")
for test, _ in errors:
print(f"\t{RED}{test}{RESET}")

return failed_result


if __name__ == "__main__":
failed = run_tests()
exit(1 if failed else 0)
exit(1 if failed else 0)

0 comments on commit ff6771d

Please sign in to comment.