1 ######################################################################
3 ######################################################################
5 ALL_TEST_INPUTS = $(wildcard $(S)src/test/*/*.rs \
6 $(S)src/test/*/*/*.rs \
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)
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)
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)
30 FT_LIB := $(call CFG_LIB_NAME,$(FT))
31 FT_DRIVER := $(FT)_driver
32 GENERATED += test/$(FT).rc test/$(FT_DRIVER).rs
34 # The arguments to all test runners
36 TESTARGS += $(TESTNAME)
43 # Arguments to the cfail/rfail/rpass/bench tests
45 CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
48 # Arguments to the perf tests
50 CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
53 CTEST_TESTARGS := $(TESTARGS)
56 CTEST_TESTARGS += --verbose
59 # The standard library test crate
60 STDTEST_CRATE := $(S)src/test/stdtest/stdtest.rc
61 STDTEST_INPUTS := $(wildcard $(S)src/test/stdtest/*rs)
63 # Run the compiletest runner itself under valgrind
65 CFG_RUN_CTEST=$(call CFG_RUN_TEST,$(2))
67 CFG_RUN_CTEST=$(call CFG_RUN,$(TARGET_HOST_LIB$(1)),$(2))
70 ######################################################################
72 ######################################################################
74 check: tidy check-stage2 \
76 check-full: tidy check-stage1 check-stage2 check-stage3 \
79 check-stage2-rustc check-stage2-std \
80 test/$(FT_DRIVER).out \
83 @$(call E, check: formatting)
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)) \
94 $(COMPILETEST_CRATE) \
95 $(COMPILETEST_INPUTS) \
97 | xargs -n 10 python $(S)src/etc/tidy.py
100 ######################################################################
101 # Rules for the test runners
102 ######################################################################
106 # All the per-stage build rules you might want to call from the
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
118 check-stage$(1)-std: check-stage$(1)-std-dummy
120 check-stage$(1)-rustc: check-stage$(1)-rustc-dummy
122 check-stage$(1)-cfail: check-stage$(1)-cfail-dummy
124 check-stage$(1)-rfail: check-stage$(1)-rfail-dummy
126 check-stage$(1)-rpass: check-stage$(1)-rpass-dummy
128 check-stage$(1)-bench: check-stage$(1)-bench-dummy
130 check-stage$(1)-perf: check-stage$(1)-perf-dummy
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
137 check-stage$(1)-pretty-rpass: check-stage$(1)-pretty-rpass-dummy
139 check-stage$(1)-pretty-rfail: check-stage$(1)-pretty-rfail-dummy
141 check-stage$(1)-pretty-bench: check-stage$(1)-pretty-bench-dummy
143 check-stage$(1)-pretty-pretty: check-stage$(1)-pretty-pretty-dummy
146 # Rules for the standard library test runner
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
153 check-stage$(1)-std-dummy: test/stdtest.stage$(1)$$(X)
154 @$$(call E, run: $$<)
155 $$(Q)$$(call CFG_RUN_TEST,$$<) $$(TESTARGS)
158 # Rules for the rustc test runner
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
169 check-stage$(1)-rustc-dummy: test/rustctest.stage$(1)$$(X)
170 @$$(call E, run: $$<)
171 $$(Q)$$(call CFG_RUN_TEST,$$<) \
175 # Rules for the cfail/rfail/rpass/bench/perf test runner
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)" \
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 \
189 RFAIL_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
190 --src-base $$(S)src/test/run-fail/ \
191 --build-base test/run-fail/ \
195 RPASS_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
196 --src-base $$(S)src/test/run-pass/ \
197 --build-base test/run-pass/ \
201 BENCH_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
202 --src-base $$(S)src/test/bench/ \
203 --build-base test/bench/ \
207 PERF_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
208 --src-base $$(S)src/test/bench/ \
209 --build-base test/perf/ \
211 $$(CTEST_PERF_RUNTOOL) \
213 PRETTY_RPASS_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
214 --src-base $$(S)src/test/run-pass/ \
215 --build-base test/run-pass/ \
218 PRETTY_RFAIL_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
219 --src-base $$(S)src/test/run-fail/ \
220 --build-base test/run-fail/ \
223 PRETTY_BENCH_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
224 --src-base $$(S)src/test/bench/ \
225 --build-base test/bench/ \
228 PRETTY_PRETTY_ARGS$(1) := $$(CTEST_COMMON_ARGS$(1)) \
229 --src-base $$(S)src/test/pretty/ \
230 --build-base test/pretty/ \
233 check-stage$(1)-cfail-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
234 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
236 @$$(call E, run: $$<)
237 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(CFAIL_ARGS$(1))
239 check-stage$(1)-rfail-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
240 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
242 @$$(call E, run: $$<)
243 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(RFAIL_ARGS$(1))
245 check-stage$(1)-rpass-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
246 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
248 @$$(call E, run: $$<)
249 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(RPASS_ARGS$(1))
251 check-stage$(1)-bench-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
252 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
254 @$$(call E, run: $$<)
255 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(BENCH_ARGS$(1))
257 check-stage$(1)-perf-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
258 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
260 @$$(call E, perf: $$<)
261 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PERF_ARGS$(1))
263 check-stage$(1)-pretty-rpass-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
264 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
266 @$$(call E, run: $$<)
267 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_RPASS_ARGS$(1))
269 check-stage$(1)-pretty-rfail-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
270 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
272 @$$(call E, run: $$<)
273 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_RFAIL_ARGS$(1))
275 check-stage$(1)-pretty-bench-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
276 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
278 @$$(call E, run: $$<)
279 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_BENCH_ARGS$(1))
281 check-stage$(1)-pretty-pretty-dummy: $$(HOST_BIN$(1))/compiletest$$(X) \
282 $$(SREQ$(1)$$(CFG_HOST_TRIPLE)) \
284 @$$(call E, run: $$<)
285 $$(Q)$$(call CFG_RUN_CTEST,$(1),$$<) $$(PRETTY_PRETTY_ARGS$(1))
289 # Instantiate the template for stage 0, 1, 2, 3
291 $(eval $(call TEST_STAGEN,0))
292 $(eval $(call TEST_STAGEN,1))
293 $(eval $(call TEST_STAGEN,2))
294 $(eval $(call TEST_STAGEN,3))
297 ######################################################################
299 ######################################################################
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
306 $(TARGET_HOST_LIB2)/$(FT_LIB): test/$(FT).rc $(SREQ2$(CFG_HOST_TRIPLE))
307 @$(call E, compile_and_link: $@)
308 $(STAGE2) --lib -o $@ $<
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 $@ $<
315 test/$(FT_DRIVER).out: test/$(FT_DRIVER)$(X) $(SREQ2$(CFG_HOST_TRIPLE))
316 $(Q)$(call CFG_RUN_TEST, $<)