diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-27 23:25:25 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-27 23:25:25 +0000 |
| commit | b8834bc878f47b2cee02588607beeac1d1ae1246 (patch) | |
| tree | 0c53dfb13e84277a97ccf9dbd387296cd4b779ac | |
| parent | 7f7be8a8202b9ccea19ae379665e3a34a81b6797 (diff) | |
Added script for checking examples with 'make test' too
| -rw-r--r-- | Makefile | 1 | ||||
| -rwxr-xr-x | tests/run_example_transpile.sh | 39 |
2 files changed, 40 insertions, 0 deletions
@@ -191,6 +191,7 @@ clean: test: $(TARGET) ./tests/run_tests.sh ./tests/run_codegen_tests.sh + ./tests/run_example_transpile.sh # Build with alternative compilers zig: diff --git a/tests/run_example_transpile.sh b/tests/run_example_transpile.sh new file mode 100755 index 0000000..c08a3ea --- /dev/null +++ b/tests/run_example_transpile.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +ZC="./zc" +EXAMPLES_DIR="examples" +FAIL_COUNT=0 +PASS_COUNT=0 + +echo "Running Example Transpilation Tests..." + +while IFS= read -r file; do + echo -n "Transpiling $file... " + + OUTPUT=$($ZC transpile "$file" 2>&1) + EXIT_CODE=$? + + if [ $EXIT_CODE -eq 0 ]; then + echo "PASS" + PASS_COUNT=$((PASS_COUNT + 1)) + [ -f "out.c" ] && rm "out.c" + [ -f "a.out" ] && rm "a.out" + else + echo "FAIL" + echo "$OUTPUT" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + +done < <(find "$EXAMPLES_DIR" -name "*.zc") + +echo "----------------------------------------" +echo "Summary:" +echo "-> Passed: $PASS_COUNT" +echo "-> Failed: $FAIL_COUNT" +echo "----------------------------------------" + +if [ $FAIL_COUNT -ne 0 ]; then + exit 1 +fi + +exit 0 |
