diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:32:05 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:32:33 +0200 |
| commit | 1ddbf300f2b7f4c7f545e62a84ca007476d3c9e5 (patch) | |
| tree | 01100eb0163c754c951700f63cbed7b1c2a00400 | |
| parent | 753c4168495b693b7b88f828213259b67b081bfb (diff) | |
Replace generate.fish with generate.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | generate.fish | 23 | ||||
| -rw-r--r-- | generate_tests.py | 30 | ||||
| -rw-r--r-- | mise.toml | 2 |
3 files changed, 31 insertions, 24 deletions
diff --git a/generate.fish b/generate.fish deleted file mode 100644 index 460cfff..0000000 --- a/generate.fish +++ /dev/null @@ -1,23 +0,0 @@ -echo "" > test.c; -set fs (ls src/**/test_*.c); -for f in $fs; - echo "#include \"$f\"" >> test.c; -end; -echo -e "" >> test.c -cat base_test.c >> test.c; -echo -e "" >> test.c; -echo "i32 main() {" >> test.c; -for f in $fs; - echo "Parsing $f"; - set funcs (rg 'i32 test_' $f); - for func in $funcs; - set pfunc (echo $func | awk '{match($0, /test_[^(]+/); print substr($0, RSTART, RLENGTH)}'); - echo "Found $pfunc in $f"; - echo " test($pfunc);" >> test.c - end; -end; -echo " - printf(\"Success: %d, Failures: %d\n\", success, failures); - - return failures; -}" >> test.c; diff --git a/generate_tests.py b/generate_tests.py new file mode 100644 index 0000000..32ee110 --- /dev/null +++ b/generate_tests.py @@ -0,0 +1,30 @@ +import re +import subprocess +from pathlib import Path + +test_files = sorted(Path("src").rglob("test_*.c")) + +lines: list[str] = [] + +for f in test_files: + lines.append(f'#include "{f}"') + +lines.append("") +lines.append(Path("base_test.c").read_text()) +lines.append("i32 main() {") + +for f in test_files: + result = subprocess.run(["rg", "i32 test_", str(f)], capture_output=True, text=True) + for match in re.finditer(r"test_[^(]+", result.stdout): + func = match.group().rstrip() + print(f"Found {func} in {f}") + lines.append(f" test({func});") + +lines.append(""" + printf("Success: %d, Failures: %d\\n", success, failures); + + return failures; +} +""") + +Path("test.c").write_text("\n".join(lines)) @@ -1,5 +1,5 @@ [tasks.generate] -run = "fish generate.fish" +run = "uv run python generate_tests.py" [tasks.debug] depends = ["generate"] |
