Commit | Line | Data |
---|---|---|
31690700 JM |
1 | # |
2 | # Command line settings | |
3 | # | |
4 | ||
5 | MAL_IMPL = js | |
6 | ||
7 | # | |
8 | # Settings | |
9 | # | |
10 | ||
11 | IMPLS = bash c clojure java js make php python mal | |
12 | ||
13 | step0 = step0_repl | |
14 | step1 = step1_read_print | |
15 | step2 = step2_eval | |
16 | step3 = step3_env | |
17 | step4 = step4_if_fn_do | |
18 | step5 = step5_tco | |
19 | step6 = step6_file | |
20 | step7 = step7_quote | |
21 | step8 = step8_macros | |
22 | step9 = step9_interop | |
23 | stepA = stepA_more | |
24 | ||
25 | EXCLUDE_TESTS = test^make^step5 test^mal^step0 test^mal^step5 test^mal^step9 test^java^step9 | |
26 | ||
27 | # | |
28 | # Utility functions | |
29 | # | |
30 | ||
31 | STEP_TEST_FILES = $(strip $(wildcard $(1)/tests/$($(2)).mal) $(wildcard tests/$($(2)).mal)) | |
32 | ||
33 | bash_STEP_TO_PROG = bash/$($(1)).sh | |
34 | c_STEP_TO_PROG = c/$($(1)) | |
35 | clojure_STEP_TO_PROG = clojure/src/$($(1)).clj | |
36 | java_STEP_TO_PROG = java/src/main/java/mal/$($(1)).java | |
37 | js_STEP_TO_PROG = js/$($(1)).js | |
38 | make_STEP_TO_PROG = make/$($(1)).mk | |
39 | php_STEP_TO_PROG = php/$($(1)).php | |
40 | python_STEP_TO_PROG = python/$($(1)).py | |
41 | mal_STEP_TO_PROG = mal/$($(1)).mal | |
42 | ||
43 | ||
44 | bash_RUNTEST = ../runtest.py $(4) ../$(1) -- bash ../$(2) $(5) | |
45 | c_RUNTEST = ../runtest.py $(4) ../$(1) -- ../$(2) $(5) | |
46 | clojure_RUNTEST = ../runtest.py $(4) ../$(1) -- lein with-profile +$(3) trampoline run $(5) | |
47 | java_RUNTEST = ../runtest.py $(4) ../$(1) -- mvn -quiet exec:java -Dexec.mainClass="mal.$($(3))" -Dexec.args="--raw$(if $(5), $(5),)" | |
48 | js_RUNTEST = ../runtest.py $(4) ../$(1) -- node ../$(2) $(5) | |
49 | make_RUNTEST = ../runtest.py $(4) ../$(1) -- make -f ../$(2) $(5) | |
50 | php_RUNTEST = ../runtest.py $(4) ../$(1) -- php ../$(2) $(5) | |
51 | python_RUNTEST = ../runtest.py $(4) ../$(1) -- python ../$(2) $(5) | |
52 | mal_RUNTEST = $(call $(MAL_IMPL)_RUNTEST,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),stepA,--start-timeout 30 --test-timeout 120,../$(2)) | |
53 | ||
54 | ||
55 | # Derived lists | |
56 | STEPS = $(sort $(filter step%,$(.VARIABLES))) | |
57 | IMPL_TESTS = $(foreach impl,$(IMPLS),test^$(impl)) | |
58 | STEP_TESTS = $(foreach step,$(STEPS),test^$(step)) | |
59 | ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\ | |
60 | $(strip $(sort \ | |
61 | $(foreach impl,$(IMPLS),\ | |
62 | $(foreach step,$(STEPS),test^$(impl)^$(step)))))) | |
63 | ||
64 | IMPL_STATS = $(foreach impl,$(IMPLS),stats^$(impl)) | |
65 | ||
66 | # | |
67 | # Build rules | |
68 | # | |
69 | ||
70 | # Build a program in 'c' directory | |
71 | c/%: | |
72 | $(MAKE) -C $(dir $(@)) $(notdir $(@)) | |
73 | ||
74 | # Allow test, test^STEP, test^IMPL, and test^IMPL^STEP | |
75 | .SECONDEXPANSION: | |
76 | $(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS)) | |
77 | ||
78 | .SECONDEXPANSION: | |
79 | $(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS))) | |
80 | ||
81 | .SECONDEXPANSION: | |
82 | $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) | |
83 | @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
84 | $(foreach step,$(word 3,$(subst ^, ,$(@))),\ | |
85 | cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ | |
86 | $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\ | |
87 | echo '----------------------------------------------'; \ | |
88 | echo 'Testing $@, step file: $+, test file: $(test)'; \ | |
89 | echo 'Running: $(call $(impl)_RUNTEST,$(test),$(+),$(step))'; \ | |
90 | $(call $(impl)_RUNTEST,$(test),$(+),$(step))))) | |
91 | ||
92 | test: $(ALL_TESTS) | |
93 | tests: $(ALL_TESTS) | |
94 | ||
95 | ||
96 | # Stats rules | |
97 | ||
98 | .SECONDEXPANSION: | |
99 | $(IMPL_STATS): | |
100 | @echo "----------------------------------------------"; \ | |
101 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
102 | echo "Stats for $(impl):"; \ | |
103 | $(MAKE) --no-print-directory -C $(impl) stats) | |
104 | ||
105 | stats: $(IMPL_STATS) |