Commit | Line | Data |
---|---|---|
31690700 JM |
1 | # |
2 | # Command line settings | |
3 | # | |
4 | ||
5 | MAL_IMPL = js | |
6 | ||
a05f7822 JM |
7 | PYTHON = python |
8 | ||
337c8031 JM |
9 | # Extra options to pass to runtest.py |
10 | TEST_OPTS = | |
11 | ||
12 | # Extra implementation specific options to pass to runtest.py | |
13 | mal_TEST_OPTS = --start-timeout 60 --test-timeout 120 | |
14 | ||
31690700 JM |
15 | # |
16 | # Settings | |
17 | # | |
18 | ||
f82cb965 | 19 | IMPLS = awk bash c d clojure coffee cpp crystal cs erlang elixir es6 factor forth fsharp go groovy \ |
105c46f1 | 20 | guile haskell java julia js kotlin lua make mal ocaml matlab miniMAL nim \ |
54d9903c | 21 | perl php ps python r racket rpython ruby rust scala swift tcl vb vimscript |
31690700 JM |
22 | |
23 | step0 = step0_repl | |
24 | step1 = step1_read_print | |
25 | step2 = step2_eval | |
26 | step3 = step3_env | |
27 | step4 = step4_if_fn_do | |
28 | step5 = step5_tco | |
29 | step6 = step6_file | |
30 | step7 = step7_quote | |
31 | step8 = step8_macros | |
01c97316 | 32 | step9 = step9_try |
90f618cb | 33 | stepA = stepA_mal |
31690700 | 34 | |
3b7ef8c7 | 35 | EXCLUDE_TESTS += test^awk^step5 # completes at 10,000 |
cc021efe JM |
36 | EXCLUDE_TESTS += test^bash^step5 # no stack exhaustion or completion |
37 | EXCLUDE_TESTS += test^c^step5 # segfault | |
0fbd1b81 | 38 | EXCLUDE_TESTS += test^cpp^step5 # completes at 10,000 |
cc021efe | 39 | EXCLUDE_TESTS += test^cs^step5 # fatal stack overflow fault |
f82cb965 | 40 | EXCLUDE_TESTS += test^d^step5 # completes at 10,000, fatal stack overflow at 1,000,000 |
e07b9830 | 41 | EXCLUDE_TESTS += test^erlang^step5 # erlang is TCO, test passes |
d88bc831 | 42 | EXCLUDE_TESTS += test^elixir^step5 # elixir is TCO, test passes |
8862f80e | 43 | EXCLUDE_TESTS += test^fsharp^step5 # completes at 10,000, fatal stack overflow at 100,000 |
7907cd90 | 44 | EXCLUDE_TESTS += test^haskell^step5 # test completes |
cc021efe JM |
45 | EXCLUDE_TESTS += test^make^step5 # no TCO capability/step |
46 | EXCLUDE_TESTS += test^mal^step5 # no TCO capability/step | |
dbac60df JM |
47 | EXCLUDE_TESTS += test^miniMAL^step5 # strange error with runtest.py |
48 | EXCLUDE_TESTS += test^nim^step5 # test completes, even at 100,000 | |
17e1c5f9 | 49 | EXCLUDE_TESTS += test^go^step5 # test completes, even at 100,000 |
cc021efe | 50 | EXCLUDE_TESTS += test^php^step5 # test completes, even at 100,000 |
7907cd90 | 51 | EXCLUDE_TESTS += test^racket^step5 # test completes |
cc021efe | 52 | EXCLUDE_TESTS += test^ruby^step5 # test completes, even at 100,000 |
a77e2b31 | 53 | EXCLUDE_TESTS += test^rust^step5 # no catching stack overflows |
44d4e31f | 54 | EXCLUDE_TESTS += test^ocaml^step5 # test completes, even at 1,000,000 |
dbac60df | 55 | EXCLUDE_TESTS += test^vb^step5 # completes at 10,000 |
725ee0bd | 56 | EXCLUDE_TESTS += test^crystal^step5 # test completes, even at 1,000,000 |
cc021efe | 57 | |
db4c329a | 58 | EXCLUDE_PERFS = perf^mal # TODO: fix this |
31690700 JM |
59 | |
60 | # | |
61 | # Utility functions | |
62 | # | |
63 | ||
64 | STEP_TEST_FILES = $(strip $(wildcard $(1)/tests/$($(2)).mal) $(wildcard tests/$($(2)).mal)) | |
65 | ||
3b7ef8c7 | 66 | awk_STEP_TO_PROG = awk/$($(1)).awk |
db4c329a JM |
67 | bash_STEP_TO_PROG = bash/$($(1)).sh |
68 | c_STEP_TO_PROG = c/$($(1)) | |
f82cb965 | 69 | d_STEP_TO_PROG = d/$($(1)) |
31690700 | 70 | clojure_STEP_TO_PROG = clojure/src/$($(1)).clj |
891c3f3b | 71 | coffee_STEP_TO_PROG = coffee/$($(1)).coffee |
9ddaa0b9 | 72 | cpp_STEP_TO_PROG = cpp/$($(1)) |
86fe6314 | 73 | crystal_STEP_TO_PROG = crystal/$($(1)) |
db4c329a | 74 | cs_STEP_TO_PROG = cs/$($(1)).exe |
51c2c1fe | 75 | elixir_STEP_TO_PROG = elixir/lib/mix/tasks/$($(1)).ex |
2cc3804b | 76 | erlang_STEP_TO_PROG = erlang/$($(1)) |
4eb71990 | 77 | es6_STEP_TO_PROG = es6/build/$($(1)).js |
199b1ce7 | 78 | factor_STEP_TO_PROG = factor/$($(1))/$($(1)).factor |
59038a10 | 79 | forth_STEP_TO_PROG = forth/$($(1)).fs |
1c358979 | 80 | fsharp_STEP_TO_PROG = fsharp/$($(1)).exe |
69b4abd6 | 81 | go_STEP_TO_PROG = go/$($(1)) |
a9cd6543 | 82 | groovy_STEP_TO_PROG = groovy/$($(1)).groovy |
db4c329a | 83 | java_STEP_TO_PROG = java/src/main/java/mal/$($(1)).java |
b76aa73b | 84 | haskell_STEP_TO_PROG = haskell/$($(1)) |
a23e0cdb | 85 | julia_STEP_TO_PROG = julia/$($(1)).jl |
db4c329a | 86 | js_STEP_TO_PROG = js/$($(1)).js |
53c2ea70 | 87 | kotlin_STEP_TO_PROG = kotlin/$($(1)).jar |
9d42904e | 88 | lua_STEP_TO_PROG = lua/$($(1)).lua |
db4c329a JM |
89 | make_STEP_TO_PROG = make/$($(1)).mk |
90 | mal_STEP_TO_PROG = mal/$($(1)).mal | |
59d10e1b | 91 | ocaml_STEP_TO_PROG = ocaml/$($(1)) |
9a54ea18 | 92 | matlab_STEP_TO_PROG = matlab/$($(1)).m |
c1fe72ae | 93 | miniMAL_STEP_TO_PROG = miniMAL/$($(1)).json |
dbac60df | 94 | nim_STEP_TO_PROG = nim/$($(1)) |
b5dedee0 | 95 | perl_STEP_TO_PROG = perl/$($(1)).pl |
db4c329a JM |
96 | php_STEP_TO_PROG = php/$($(1)).php |
97 | ps_STEP_TO_PROG = ps/$($(1)).ps | |
98 | python_STEP_TO_PROG = python/$($(1)).py | |
4d1456b9 | 99 | r_STEP_TO_PROG = r/$($(1)).r |
f5223195 | 100 | racket_STEP_TO_PROG = racket/$($(1)).rkt |
80320efc | 101 | rpython_STEP_TO_PROG = rpython/$($(1)) |
db4c329a | 102 | ruby_STEP_TO_PROG = ruby/$($(1)).rb |
434516e0 | 103 | rust_STEP_TO_PROG = rust/target/release/$($(1)) |
821930db | 104 | scala_STEP_TO_PROG = scala/$($(1)).scala |
2539e6af | 105 | swift_STEP_TO_PROG = swift/$($(1)) |
54d9903c | 106 | tcl_STEP_TO_PROG = tcl/$($(1)).tcl |
ee7cd585 | 107 | vb_STEP_TO_PROG = vb/$($(1)).exe |
50a964ce | 108 | vimscript_STEP_TO_PROG = vimscript/$($(1)).vim |
5eb1f5cb | 109 | guile_STEP_TO_PROG = guile/$($(1)).scm |
db4c329a | 110 | |
c4033aab JM |
111 | # Needed some argument munging |
112 | COMMA = , | |
113 | noop = | |
114 | SPACE = $(noop) $(noop) | |
d1596ac2 | 115 | export FACTOR_ROOTS := . |
db4c329a | 116 | |
3b7ef8c7 | 117 | awk_RUNSTEP = awk -O -f ../$(2) $(3) |
db4c329a JM |
118 | bash_RUNSTEP = bash ../$(2) $(3) |
119 | c_RUNSTEP = ../$(2) $(3) | |
f82cb965 | 120 | d_RUNSTEP = ../$(2) $(3) |
db4c329a | 121 | clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3) |
891c3f3b | 122 | coffee_RUNSTEP = coffee ../$(2) $(3) |
9ddaa0b9 | 123 | cpp_RUNSTEP = ../$(2) $(3) |
86fe6314 | 124 | crystal_RUNSTEP = ../$(2) $(3) |
db4c329a | 125 | cs_RUNSTEP = mono ../$(2) --raw $(3) |
df2ca97b | 126 | elixir_RUNSTEP = mix $(notdir $(basename $(2))) $(3) |
2cc3804b | 127 | erlang_RUNSTEP = ../$(2) $(3) |
4eb71990 | 128 | es6_RUNSTEP = node ../$(2) $(3) |
389c9b8a | 129 | factor_RUNSTEP = factor ../$(2) $(3) |
59038a10 | 130 | forth_RUNSTEP = gforth ../$(2) $(3) |
1c358979 | 131 | fsharp_RUNSTEP = mono ../$(2) --raw $(3) |
69b4abd6 | 132 | go_RUNSTEP = ../$(2) $(3) |
a9cd6543 | 133 | groovy_RUNSTEP = groovy ../$(2) $(3) |
b76aa73b | 134 | haskell_RUNSTEP = ../$(2) $(3) |
798206ac | 135 | java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" $(if $(3), -Dexec.args="$(3)",) |
a23e0cdb | 136 | julia_RUNSTEP = ../$(2) $(3) |
db4c329a | 137 | js_RUNSTEP = node ../$(2) $(3) |
53c2ea70 | 138 | kotlin_RUNSTEP = java -jar ../$(2) $(3) |
798206ac | 139 | lua_RUNSTEP = ../$(2) $(3) |
db4c329a | 140 | make_RUNSTEP = make -f ../$(2) $(3) |
922d4c3b | 141 | mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,stepA,$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #" |
59d10e1b | 142 | ocaml_RUNSTEP = ../$(2) $(3) |
7f567f36 JM |
143 | matlab_args = $(subst $(SPACE),$(COMMA),$(foreach x,$(strip $(1)),'$(x)')) |
144 | matlab_RUNSTEP = matlab -nodisplay -nosplash -nodesktop -nojvm -r "$($(1))($(call matlab_args,$(3)));quit;" | |
c1fe72ae | 145 | miniMAL_RUNSTEP = miniMAL ../$(2) $(3) |
dbac60df | 146 | nim_RUNSTEP = ../$(2) $(3) |
82acd3de | 147 | perl_RUNSTEP = perl ../$(2) $(3) |
db4c329a | 148 | php_RUNSTEP = php ../$(2) $(3) |
406761e7 | 149 | ps_RUNSTEP = gs -q -I./ -dNODISPLAY -- ../$(2) $(3) |
db4c329a | 150 | python_RUNSTEP = $(PYTHON) ../$(2) $(3) |
4d1456b9 | 151 | r_RUNSTEP = Rscript ../$(2) $(3) |
f5223195 | 152 | racket_RUNSTEP = ../$(2) $(3) |
80320efc | 153 | rpython_RUNSTEP = ../$(2) $(3) |
db4c329a | 154 | ruby_RUNSTEP = ruby ../$(2) $(3) |
abdd56eb | 155 | rust_RUNSTEP = ../$(2) $(3) |
821930db | 156 | scala_RUNSTEP = sbt 'run-main $($(1))$(if $(3), $(3),)' |
2539e6af | 157 | swift_RUNSTEP = ../$(2) $(3) |
576ef370 | 158 | tcl_RUNSTEP = tclsh ../$(2) --raw $(3) |
ee7cd585 | 159 | vb_RUNSTEP = mono ../$(2) --raw $(3) |
50a964ce | 160 | vimscript_RUNSTEP = ./run_vimscript.sh ../$(2) $(3) |
5eb1f5cb | 161 | # needs TERM=dumb to work with readline |
337c8031 | 162 | guile_RUNSTEP = guile --no-auto-compile -L ../guile ../$(2) $(3) |
db4c329a | 163 | |
31690700 | 164 | |
50a964ce DM |
165 | vimscript_TEST_OPTS = --test-timeout 30 |
166 | ifeq ($(MAL_IMPL),vimscript) | |
167 | mal_TEST_OPTS = --start-timeout 60 --test-timeout 180 | |
168 | endif | |
31690700 JM |
169 | |
170 | # Derived lists | |
171 | STEPS = $(sort $(filter step%,$(.VARIABLES))) | |
8569b2af JM |
172 | DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS)) |
173 | IMPL_TESTS = $(foreach impl,$(DO_IMPLS),test^$(impl)) | |
31690700 JM |
174 | STEP_TESTS = $(foreach step,$(STEPS),test^$(step)) |
175 | ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\ | |
176 | $(strip $(sort \ | |
8569b2af | 177 | $(foreach impl,$(DO_IMPLS),\ |
31690700 JM |
178 | $(foreach step,$(STEPS),test^$(impl)^$(step)))))) |
179 | ||
8569b2af JM |
180 | IMPL_STATS = $(foreach impl,$(DO_IMPLS),stats^$(impl)) |
181 | IMPL_STATS_LISP = $(foreach impl,$(DO_IMPLS),stats-lisp^$(impl)) | |
31690700 | 182 | |
cf1d3eae JM |
183 | DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl)) |
184 | ||
8569b2af | 185 | IMPL_PERF = $(filter-out $(EXCLUDE_PERFS),$(foreach impl,$(DO_IMPLS),perf^$(impl))) |
db4c329a | 186 | |
31690700 JM |
187 | # |
188 | # Build rules | |
189 | # | |
190 | ||
4fc7a281 | 191 | # Build a program in an implementation directory |
f045aba1 JM |
192 | # Make sure we always try and build first because the dependencies are |
193 | # encoded in the implementation Makefile not here | |
194 | .PHONY: $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))) | |
4fc7a281 | 195 | $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))): |
f045aba1 JM |
196 | $(foreach impl,$(word 1,$(subst /, ,$(@))),\ |
197 | $(MAKE) -C $(impl) $(subst $(impl)/,,$(@))) | |
9ddaa0b9 | 198 | |
31690700 JM |
199 | # Allow test, test^STEP, test^IMPL, and test^IMPL^STEP |
200 | .SECONDEXPANSION: | |
201 | $(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS)) | |
202 | ||
203 | .SECONDEXPANSION: | |
204 | $(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS))) | |
205 | ||
206 | .SECONDEXPANSION: | |
207 | $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) | |
208 | @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
209 | $(foreach step,$(word 3,$(subst ^, ,$(@))),\ | |
210 | cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ | |
211 | $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\ | |
212 | echo '----------------------------------------------'; \ | |
213 | echo 'Testing $@, step file: $+, test file: $(test)'; \ | |
fc4c7889 JM |
214 | echo 'Running: ../runtest.py $(TEST_OPTS) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))'; \ |
215 | ../runtest.py $(TEST_OPTS) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+));))) | |
31690700 JM |
216 | |
217 | test: $(ALL_TESTS) | |
218 | tests: $(ALL_TESTS) | |
219 | ||
220 | ||
221 | # Stats rules | |
222 | ||
db4c329a JM |
223 | stats: $(IMPL_STATS) |
224 | stats-lisp: $(IMPL_STATS_LISP) | |
225 | ||
31690700 JM |
226 | .SECONDEXPANSION: |
227 | $(IMPL_STATS): | |
228 | @echo "----------------------------------------------"; \ | |
229 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
230 | echo "Stats for $(impl):"; \ | |
231 | $(MAKE) --no-print-directory -C $(impl) stats) | |
232 | ||
712af9ef JM |
233 | .SECONDEXPANSION: |
234 | $(IMPL_STATS_LISP): | |
235 | @echo "----------------------------------------------"; \ | |
236 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
237 | echo "Stats (lisp only) for $(impl):"; \ | |
238 | $(MAKE) --no-print-directory -C $(impl) stats-lisp) | |
239 | ||
cf1d3eae JM |
240 | # Docker build rules |
241 | ||
242 | docker-build: $(DOCKER_BUILD) | |
243 | ||
244 | .SECONDEXPANSION: | |
245 | $(DOCKER_BUILD): | |
246 | echo "----------------------------------------------"; \ | |
247 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
f7824465 JM |
248 | echo "Running: docker build -t kanaka/mal-test-$(impl) .:"; \ |
249 | cd $(impl) && docker build -t kanaka/mal-test-$(impl) .) | |
db4c329a JM |
250 | |
251 | # Performance test rules | |
252 | ||
253 | perf: $(IMPL_PERF) | |
254 | ||
255 | .SECONDEXPANSION: | |
256 | $(IMPL_PERF): | |
257 | @echo "----------------------------------------------"; \ | |
258 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
259 | cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ | |
260 | echo "Performance test for $(impl):"; \ | |
261 | echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \ | |
262 | $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \ | |
263 | echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \ | |
699f0ad2 JM |
264 | $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal); \ |
265 | echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)'; \ | |
266 | $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)) |