]> git.lizzy.rs Git - rust.git/blob - mk/tests.mk
doc: 'if' expressions no longer require parens
[rust.git] / mk / tests.mk
1 ######################################################################
2 # Testing variables
3 ######################################################################
4
5 ALL_TEST_INPUTS = $(wildcard $(S)src/test/*/*.rs   \
6                               $(S)src/test/*/*/*.rs \
7                               $(S)src/test/*/*.rc)
8
9 RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
10 RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
11 RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
12 RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
13 CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
14 CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
15 BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
16 PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
17
18 # perf tests are the same as bench tests only they run under
19 # a performance monitor.
20 PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
21
22 RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
23 RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
24 CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
25 BENCH_TESTS := $(BENCH_RS)
26 PERF_TESTS := $(PERF_RS)
27 PRETTY_TESTS := $(PRETTY_RS)
28
29 FT := run_pass_stage2
30 FT_LIB := $(call CFG_LIB_NAME,$(FT))
31 FT_DRIVER := $(FT)_driver
32 GENERATED += test/$(FT).rc test/$(FT_DRIVER).rs
33
34 # The arguments to all test runners
35 ifdef TESTNAME
36   TESTARGS += $(TESTNAME)
37 endif
38
39 ifdef CHECK_XFAILS
40   TESTARGS += --ignored
41 endif
42
43 # Arguments to the cfail/rfail/rpass/bench tests
44 ifdef CFG_VALGRIND
45   CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
46 endif
47
48 # Arguments to the perf tests
49 ifdef CFG_PERF_TOOL
50   CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
51 endif
52
53 CTEST_TESTARGS := $(TESTARGS)
54
55 ifdef VERBOSE
56   CTEST_TESTARGS += --verbose
57 endif
58
59 # The standard library test crate
60 STDTEST_CRATE := $(S)src/test/stdtest/stdtest.rc
61 STDTEST_INPUTS := $(wildcard $(S)src/test/stdtest/*rs)
62
63 # Run the compiletest runner itself under valgrind
64 ifdef CTEST_VALGRIND
65   CFG_RUN_CTEST=$(call CFG_RUN_TEST,$(2))
66 else
67   CFG_RUN_CTEST=$(call CFG_RUN,$(TARGET_HOST_LIB$(1)),$(2))
68 endif
69
70 ######################################################################
71 # Main test targets
72 ######################################################################
73
74 check: tidy check-stage2 \
75
76 check-full: tidy check-stage1 check-stage2 check-stage3 \
77
78 check-fast: tidy \
79         check-stage2-rustc check-stage2-std \
80         test/$(FT_DRIVER).out \
81
82 tidy:
83         @$(call E, check: formatting)
84         $(Q)echo \
85           $(filter-out $(GENERATED) $(addprefix $(S)src/, $(GENERATED)) \
86             $(addprefix $(S)src/, $(RUSTLLVM_LIB_CS) $(RUSTLLVM_OBJS_CS) \
87               $(RUSTLLVM_HDR) $(PKG_3RDPARTY) \
88               $(RUNTIME_CS) $(RUNTIME_HDR) $(RUNTIME_S)) \
89             $(S)src/etc/%,  \
90             $(COMPILER_CRATE) \
91             $(COMPILER_INPUTS) \
92             $(STDLIB_CRATE) \
93             $(STDLIB_INPUTS) \
94             $(COMPILETEST_CRATE) \
95             $(COMPILETEST_INPUTS) \
96             $(ALL_TEST_INPUTS)) \
97           | xargs -n 10 python $(S)src/etc/tidy.py
98
99
100 ######################################################################
101 # Rules for the test runners
102 ######################################################################
103
104 define TEST_STAGEN
105
106 # All the per-stage build rules you might want to call from the
107 # command line
108
109 check-stage$(1): tidy \
110         check-stage$(1)-rustc \
111         check-stage$(1)-std \
112         check-stage$(1)-rpass \
113         check-stage$(1)-rfail \
114         check-stage$(1)-cfail \
115         check-stage$(1)-bench \
116         check-stage$(1)-pretty
117
118 check-stage$(1)-std: check-stage$(1)-std-dummy
119
120 check-stage$(1)-rustc: check-stage$(1)-rustc-dummy
121
122 check-stage$(1)-cfail: check-stage$(1)-cfail-dummy
123
124 check-stage$(1)-rfail: check-stage$(1)-rfail-dummy
125
126 check-stage$(1)-rpass: check-stage$(1)-rpass-dummy
127
128 check-stage$(1)-bench: check-stage$(1)-bench-dummy
129
130 check-stage$(1)-perf: check-stage$(1)-perf-dummy
131
132 check-stage$(1)-pretty: check-stage$(1)-pretty-rpass \
133                         check-stage$(1)-pretty-rfail \
134                         check-stage$(1)-pretty-bench \
135                         check-stage$(1)-pretty-pretty
136
137 check-stage$(1)-pretty-rpass: check-stage$(1)-pretty-rpass-dummy
138
139 check-stage$(1)-pretty-rfail: check-stage$(1)-pretty-rfail-dummy
140
141 check-stage$(1)-pretty-bench: check-stage$(1)-pretty-bench-dummy
142
143 check-stage$(1)-pretty-pretty: check-stage$(1)-pretty-pretty-dummy
144
145
146 # Rules for the standard library test runner
147
148 test/stdtest.stage$(1)$$(X): $$(STDTEST_CRATE) $$(STDTEST_INPUTS) \
149                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE))
150         @$$(call E, compile_and_link: $$@)
151         $$(STAGE$(1)) -o $$@ $$< --test
152
153 check-stage$(1)-std-dummy: test/stdtest.stage$(1)$$(X)
154         @$$(call E, run: $$<)
155         $$(Q)$$(call CFG_RUN_TEST,$$<) $$(TESTARGS)
156
157
158 # Rules for the rustc test runner
159
160 test/rustctest.stage$(1)$$(X): \
161         $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
162         $$(TARGET_SREQ$(1)$$(CFG_HOST_TRIPLE)) \
163         $$(HOST_LIB$(1))/$$(CFG_RUSTLLVM) \
164         $$(TARGET_LIB$(1)$$(CFG_HOST_TRIPLE))/$$(CFG_RUSTLLVM) \
165         $$(TARGET_LIB$(1)$$(CFG_HOST_TRIPLE))/$$(CFG_STDLIB)
166         @$$(call E, compile_and_link: $$@)
167         $$(STAGE$(1)) -o $$@ $$< --test
168
169 check-stage$(1)-rustc-dummy: test/rustctest.stage$(1)$$(X)
170         @$$(call E, run: $$<)
171         $$(Q)$$(call CFG_RUN_TEST,$$<) \
172           $$(TESTARGS)
173
174
175 # Rules for the cfail/rfail/rpass/bench/perf test runner
176
177 CTEST_COMMON_ARGS$(1) := --compile-lib-path $$(HOST_LIB$(1)) \
178                          --run-lib-path $$(TARGET_LIB$(1)$$(CFG_HOST_TRIPLE)) \
179                          --rustc-path $$(HOST_BIN$(1))/rustc$$(X) \
180                          --stage-id stage$(1) \
181                          --rustcflags "$$(CFG_RUSTC_FLAGS)" \
182                          $$(CTEST_TESTARGS) \
183
184 CFAIL_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
185                   --src-base $$(S)src/test/compile-fail/ \
186                   --build-base test/compile-fail/ \
187                   --mode compile-fail \
188
189 RFAIL_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
190                   --src-base $$(S)src/test/run-fail/ \
191                   --build-base test/run-fail/ \
192                   --mode run-fail \
193                   $$(CTEST_RUNTOOL) \
194
195 RPASS_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
196                   --src-base $$(S)src/test/run-pass/ \
197                   --build-base test/run-pass/ \
198                   --mode run-pass \
199                   $$(CTEST_RUNTOOL) \
200
201 BENCH_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
202                   --src-base $$(S)src/test/bench/ \
203                   --build-base test/bench/ \
204                   --mode run-pass \
205                   $$(CTEST_RUNTOOL) \
206
207 PERF_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
208                   --src-base $$(S)src/test/bench/ \
209                   --build-base test/perf/ \
210                   --mode run-pass \
211                   $$(CTEST_PERF_RUNTOOL) \
212
213 PRETTY_RPASS_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
214                          --src-base $$(S)src/test/run-pass/ \
215                          --build-base test/run-pass/ \
216                          --mode pretty \
217
218 PRETTY_RFAIL_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
219                          --src-base $$(S)src/test/run-fail/ \
220                          --build-base test/run-fail/ \
221                          --mode pretty \
222
223 PRETTY_BENCH_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
224                          --src-base $$(S)src/test/bench/ \
225                          --build-base test/bench/ \
226                          --mode pretty \
227
228 PRETTY_PRETTY_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
229                           --src-base $$(S)src/test/pretty/ \
230                           --build-base test/pretty/ \
231                           --mode pretty \
232
233 check-stage$(1)-cfail-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
234                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
235                                    $$(CFAIL_TESTS)
236         @$$(call E, run: $$<)
237         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(CFAIL_ARGS$(1))
238
239 check-stage$(1)-rfail-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
240                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
241                                $$(RFAIL_TESTS)
242         @$$(call E, run: $$<)
243         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(RFAIL_ARGS$(1))
244
245 check-stage$(1)-rpass-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
246                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
247                                $$(RPASS_TESTS)
248         @$$(call E, run: $$<)
249         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(RPASS_ARGS$(1))
250
251 check-stage$(1)-bench-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
252                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
253                             $$(BENCH_TESTS)
254         @$$(call E, run: $$<)
255         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(BENCH_ARGS$(1))
256
257 check-stage$(1)-perf-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
258                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
259                             $$(BENCH_TESTS)
260         @$$(call E, perf: $$<)
261         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PERF_ARGS$(1))
262
263 check-stage$(1)-pretty-rpass-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
264                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
265                                      $$(RPASS_TESTS)
266         @$$(call E, run: $$<)
267         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_RPASS_ARGS$(1))
268
269 check-stage$(1)-pretty-rfail-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
270                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
271                                      $$(RFAIL_TESTS)
272         @$$(call E, run: $$<)
273         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_RFAIL_ARGS$(1))
274
275 check-stage$(1)-pretty-bench-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
276                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
277                                      $$(BENCH_TESTS)
278         @$$(call E, run: $$<)
279         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_BENCH_ARGS$(1))
280
281 check-stage$(1)-pretty-pretty-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
282                              $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
283                                      $$(PRETTY_TESTS)
284         @$$(call E, run: $$<)
285         $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_PRETTY_ARGS$(1))
286
287 endef
288
289 # Instantiate the template for stage 0, 1, 2, 3
290
291 $(eval $(call TEST_STAGEN,0))
292 $(eval $(call TEST_STAGEN,1))
293 $(eval $(call TEST_STAGEN,2))
294 $(eval $(call TEST_STAGEN,3))
295
296
297 ######################################################################
298 # Fast-test rules
299 ######################################################################
300
301 test/$(FT).rc test/$(FT_DRIVER).rs: $(TEST_RPASS_SOURCES_STAGE2) \
302     $(S)src/etc/combine-tests.py
303         @$(call E, check: building combined stage2 test runner)
304         $(Q)$(S)src/etc/combine-tests.py
305
306 $(TARGET_HOST_LIB2)/$(FT_LIB): test/$(FT).rc $(SREQ2$(CFG_HOST_TRIPLE))
307         @$(call E, compile_and_link: $@)
308         $(STAGE2) --lib -o $@ $<
309
310 test/$(FT_DRIVER)$(X): test/$(FT_DRIVER).rs $(TARGET_HOST_LIB2)/$(FT_LIB) \
311         $(SREQ2$(CFG_HOST_TRIPLE))
312         @$(call E, compile_and_link: $@)
313         $(STAGE2) -L $(HOST_LIB2) -o $@ $<
314
315 test/$(FT_DRIVER).out: test/$(FT_DRIVER)$(X) $(SREQ2$(CFG_HOST_TRIPLE))
316         $(Q)$(call CFG_RUN_TEST, $<)