Skip to content

Commit 2db08b9

Browse files
committed
feat(make): testar arquivos um por um
1 parent ce28869 commit 2db08b9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@ $(YACC_OUT): $(YACC_SRC)
2626
clean:
2727
rm -f $(TARGET) $(LEX_OUT) $(YACC_OUT) $(YACC_HEADER)
2828

29+
TEST_CASES = \
30+
expressions \
31+
variable
32+
2933
test: all
3034
@echo "== Running sample tests =="
31-
@./c2lua tests/expr1.txt | diff -u - tests/expr1.ast && echo "expr1 ✓" || (echo "expr1 ✗"; exit 1)
32-
@./c2lua tests/expr2.txt | diff -u - tests/expr2.ast && echo "expr2 ✓" || (echo "expr2 ✗"; exit 1)
33-
@./c2lua tests/expr3.txt | diff -u - tests/expr3.ast && echo "expr3 ✓" || (echo "expr3 ✗"; exit 1)
35+
@for case in $(TEST_CASES); do \
36+
output=$$(./c2lua tests/$$case.c); \
37+
expected=$$(cat tests/$$case.lua); \
38+
printf '%s' "-- $$case... "; \
39+
if [ "$$output" = "$$expected" ]; then \
40+
echo "ok"; \
41+
else \
42+
echo "fail"; \
43+
printf 'Expected:\n%s\n\nGot:\n%s\n' "$$expected" "$$output"; \
44+
exit 1; \
45+
fi; \
46+
done
3447
@echo "All tests passed."

0 commit comments

Comments
 (0)