-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMake.test
37 lines (26 loc) · 1.56 KB
/
Make.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
LEX_TEST_FILES := $(shell find $(TESTS_DIR) -name '*.lex')
PARSE_TEST_FILES := $(shell find $(TESTS_DIR) -name '*.parse')
RESOLVE_TEST_FILES := $(shell find $(TESTS_DIR) -name '*.resolve')
C_TEST_FILES := $(shell find $(TESTS_DIR) -name '*.c')
LEX_TESTS := $(patsubst %.lex, %.lex.test, $(LEX_TEST_FILES))
PARSE_TESTS := $(patsubst %.parse, %.parse.test, $(PARSE_TEST_FILES))
RESOLVE_TESTS := $(patsubst %.resolve, %.resolve.test, $(RESOLVE_TEST_FILES))
C_TESTS := $(patsubst %.c, %.c.test, $(C_TEST_FILES))
ALL_TESTS := $(LEX_TESTS) $(PARSE_TESTS) $(RESOLVE_TESTS) $(C_TESTS)
clean::
@$(RM) -rf $(TESTS_DIR)/**/*.gen
.PHONY: test
test: $(ALL_TESTS)
@echo "All tests passed."
%.lex.test: %.sign %.lex $(STAGE_3)
@$(STAGE_3) -l $< > $(patsubst %.lex.test, %.lex.gen, $@) 2>&1 || (exit 0)
@diff -q $(word 2, $^) $(patsubst %.lex.test, %.lex.gen, $@) >/dev/null || (echo "Test $@ failed" && exit 1)
%.parse.test: %.sign %.parse $(STAGE_3)
@$(STAGE_3) -p $< > $(patsubst %.parse.test, %.parse.gen, $@) 2>&1 || (exit 0)
@diff -q $(word 2, $^) $(patsubst %.parse.test, %.parse.gen, $@) >/dev/null || (echo "Test $@ failed" && exit 1)
%.resolve.test: %.sign %.resolve $(STAGE_3)
@$(STAGE_3) -r $< > $(patsubst %.resolve.test, %.resolve.gen, $@) 2>&1 || (exit 0)
@diff -q $(word 2, $^) $(patsubst %.resolve.test, %.resolve.gen, $@) >/dev/null || (echo "Test $@ failed" && exit 1)
%.c.test: %.sign %.c $(STAGE_3)
@$(STAGE_3) -g $< > $(patsubst %.c.test, %.c.gen, $@) 2>&1 || (exit 0)
@diff -q $(word 2, $^) $(patsubst %.c.test, %.c.gen, $@) >/dev/null || (echo "Test $@ failed" && exit 1)