]> git.proxmox.com Git - rustc.git/blob - mk/tests.mk
New upstream version 1.16.0+dfsg1
[rustc.git] / mk / tests.mk
1 # Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11
12 ######################################################################
13 # Test variables
14 ######################################################################
15
16 # The names of crates that must be tested
17
18 # libcore/libstd_unicode tests are in a separate crate
19 DEPS_coretest :=
20 $(eval $(call RUST_CRATE,coretest))
21
22 DEPS_collectionstest :=
23 $(eval $(call RUST_CRATE,collectionstest))
24
25 TEST_TARGET_CRATES = $(filter-out core std_unicode alloc_system libc \
26 alloc_jemalloc panic_unwind \
27 panic_abort,$(TARGET_CRATES)) \
28 collectionstest coretest
29 TEST_DOC_CRATES = $(DOC_CRATES) arena flate fmt_macros getopts graphviz \
30 log rand serialize syntax term test
31 TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve \
32 rustc_trans rustc_lint,\
33 $(HOST_CRATES))
34 TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
35
36 ######################################################################
37 # Environment configuration
38 ######################################################################
39
40 # The arguments to all test runners
41 ifdef TESTNAME
42 TESTARGS += $(TESTNAME)
43 endif
44
45 ifdef CHECK_IGNORED
46 TESTARGS += --ignored
47 endif
48
49 # Arguments to the cfail/rfail/rpass tests
50 ifdef CFG_VALGRIND
51 CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
52 endif
53
54 CTEST_TESTARGS := $(TESTARGS)
55
56 # --bench is only relevant for crate tests, not for the compile tests
57 ifdef PLEASE_BENCH
58 TESTARGS += --bench
59 endif
60
61 ifdef VERBOSE
62 CTEST_TESTARGS += --verbose
63 endif
64
65 # Setting locale ensures that gdb's output remains consistent.
66 # This prevents tests from failing with some locales (fixes #17423).
67 export LC_ALL=C
68
69 TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
70 TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
71
72 define DEF_TARGET_COMMANDS
73
74 ifdef CFG_UNIXY_$(1)
75 CFG_RUN_TEST_$(1)=$$(TARGET_RPATH_VAR$$(2)_T_$$(3)_H_$$(4)) \
76 $$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
77 endif
78
79 ifdef CFG_WINDOWSY_$(1)
80 CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)$$(2)/$$(strip \
81 $$(if $$(findstring stage0,$$(1)), \
82 stage0/$$(CFG_LIBDIR_RELATIVE), \
83 $$(if $$(findstring stage1,$$(1)), \
84 stage1/$$(CFG_LIBDIR_RELATIVE), \
85 $$(if $$(findstring stage2,$$(1)), \
86 stage2/$$(CFG_LIBDIR_RELATIVE), \
87 $$(if $$(findstring stage3,$$(1)), \
88 stage3/$$(CFG_LIBDIR_RELATIVE), \
89 )))))/rustlib/$$(CFG_BUILD)/lib
90 CFG_RUN_TEST_$(1)=$$(TARGET_RPATH_VAR$$(2)_T_$$(3)_H_$$(4)) \
91 $$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(4)),$$(1))
92 endif
93
94 # Run the compiletest runner itself under valgrind
95 ifdef CTEST_VALGRIND
96 CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \
97 $$(call CFG_RUN_TEST_$$(CFG_BUILD),$$(3),$$(4))
98 else
99 CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \
100 $$(call CFG_RUN_$$(CFG_BUILD),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
101 endif
102
103 endef
104
105 $(foreach target,$(CFG_TARGET), \
106 $(eval $(call DEF_TARGET_COMMANDS,$(target))))
107
108 # Target platform specific variables for android
109 define DEF_ADB_DEVICE_STATUS
110 CFG_ADB_DEVICE_STATUS=$(1)
111 endef
112
113 $(foreach target,$(CFG_TARGET), \
114 $(if $(findstring android, $(target)), \
115 $(if $(findstring adb,$(CFG_ADB)), \
116 $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[:_A-Za-z0-9-]+[[:blank:]]+device')), \
117 $(info check: android device attached) \
118 $(eval $(call DEF_ADB_DEVICE_STATUS, true)), \
119 $(info check: android device not attached) \
120 $(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
121 ), \
122 $(info check: adb not found) \
123 $(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
124 ), \
125 ) \
126 )
127
128 ifeq ($(CFG_ADB_DEVICE_STATUS),true)
129 CFG_ADB_TEST_DIR=/data/tmp
130
131 $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
132 $(shell $(CFG_ADB) remount 1>/dev/null) \
133 $(shell $(CFG_ADB) shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
134 $(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)) \
135 $(shell $(CFG_ADB) push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
136 $(foreach target,$(CFG_TARGET), \
137 $(if $(findstring android, $(target)), \
138 $(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/$(target)) \
139 $(foreach crate,$(TARGET_CRATES_$(target)), \
140 $(shell $(CFG_ADB) push $(TLIB2_T_$(target)_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_$(target),$(crate)) \
141 $(CFG_ADB_TEST_DIR)/$(target))), \
142 )))
143 else
144 CFG_ADB_TEST_DIR=
145 endif
146
147 # $(1) - name of doc test
148 # $(2) - file of the test
149 define DOCTEST
150 DOC_NAMES := $$(DOC_NAMES) $(1)
151 DOCFILE_$(1) := $(2)
152 endef
153
154 $(foreach doc,$(DOCS), \
155 $(eval $(call DOCTEST,md-$(doc),$(S)src/doc/$(doc).md)))
156 $(foreach file,$(wildcard $(S)src/doc/book/*.md), \
157 $(eval $(call DOCTEST,$(file:$(S)src/doc/book/%.md=book-%),$(file))))
158 $(foreach file,$(wildcard $(S)src/doc/nomicon/*.md), \
159 $(eval $(call DOCTEST,$(file:$(S)src/doc/nomicon/%.md=nomicon-%),$(file))))
160 ######################################################################
161 # Main test targets
162 ######################################################################
163
164 # The main testing target. Tests lots of stuff.
165 check: check-sanitycheck cleantmptestlogs cleantestlibs all check-stage2 tidy
166 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
167
168 # As above but don't bother running tidy.
169 check-notidy: check-sanitycheck cleantmptestlogs cleantestlibs all check-stage2
170 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
171
172 # A slightly smaller set of tests for smoke testing.
173 check-lite: check-sanitycheck cleantestlibs cleantmptestlogs \
174 $(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate)) \
175 check-stage2-rpass check-stage2-rpass-valgrind \
176 check-stage2-rfail check-stage2-cfail check-stage2-pfail check-stage2-rmake
177 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
178
179 # Only check the 'reference' tests: rpass/cfail/rfail/rmake.
180 check-ref: check-sanitycheck cleantestlibs cleantmptestlogs check-stage2-rpass \
181 check-stage2-rpass-valgrind check-stage2-rfail check-stage2-cfail check-stage2-pfail \
182 check-stage2-rmake
183 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
184
185 # Only check the docs.
186 check-docs: check-sanitycheck cleantestlibs cleantmptestlogs check-stage2-docs
187 $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
188
189 # Some less critical tests that are not prone to breakage.
190 # Not run as part of the normal test suite, but tested by bors on checkin.
191 check-secondary: check-build-compiletest check-build-lexer-verifier check-lexer check-pretty
192
193 .PHONY: check-sanitycheck
194
195 check-sanitycheck:
196 $(Q)$(CFG_PYTHON) $(S)src/etc/check-sanitycheck.py
197
198 # check + check-secondary.
199 #
200 # Issue #17883: build check-secondary first so hidden dependencies in
201 # e.g. building compiletest are exercised (resolve those by adding
202 # deps to rules that need them; not by putting `check` first here).
203 check-all: check-secondary check
204
205 # Pretty-printing tests.
206 check-pretty: check-stage2-T-$(CFG_BUILD)-H-$(CFG_BUILD)-pretty-exec
207
208 define DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE
209 check-stage$(1)-build-compiletest: $$(HBIN$(1)_H_$(CFG_BUILD))/compiletest$$(X_$(CFG_BUILD))
210 endef
211
212 $(foreach stage,$(STAGES), \
213 $(eval $(call DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE,$(stage))))
214
215 check-build-compiletest: \
216 check-stage1-build-compiletest \
217 check-stage2-build-compiletest
218
219 .PHONY: cleantmptestlogs cleantestlibs
220
221 cleantmptestlogs:
222 $(Q)rm -f tmp/*.log
223
224 cleantestlibs:
225 $(Q)find $(CFG_BUILD)/test \
226 -name '*.[odasS]' -o \
227 -name '*.so' -o \
228 -name '*.dylib' -o \
229 -name '*.dll' -o \
230 -name '*.def' -o \
231 -name '*.bc' -o \
232 -name '*.dSYM' -o \
233 -name '*.libaux' -o \
234 -name '*.out' -o \
235 -name '*.err' -o \
236 -name '*.debugger.script' \
237 | xargs rm -rf
238
239
240 ######################################################################
241 # Tidy
242 ######################################################################
243
244 .PHONY: tidy
245 tidy: $(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)) \
246 $(SNAPSHOT_RUSTC_POST_CLEANUP)
247 $(TARGET_RPATH_VAR0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $< $(S)src
248
249 $(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)): \
250 $(TSREQ0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
251 $(TLIB0_T_$(CFG_BUILD)_H_$(CFG_BUILD))/stamp.std \
252 $(call rwildcard,$(S)src/tools/tidy/src,*.rs) \
253 $(SNAPSHOT_RUSTC_POST_CLEANUP) | \
254 $(TLIB0_T_$(CFG_BUILD)_H_$(CFG_BUILD))
255 $(STAGE0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(S)src/tools/tidy/src/main.rs \
256 --out-dir $(@D) --crate-name tidy
257
258 ######################################################################
259 # Sets of tests
260 ######################################################################
261
262 define DEF_TEST_SETS
263
264 check-stage$(1)-T-$(2)-H-$(3)-exec: \
265 check-stage$(1)-T-$(2)-H-$(3)-rpass-exec \
266 check-stage$(1)-T-$(2)-H-$(3)-rfail-exec \
267 check-stage$(1)-T-$(2)-H-$(3)-cfail-exec \
268 check-stage$(1)-T-$(2)-H-$(3)-pfail-exec \
269 check-stage$(1)-T-$(2)-H-$(3)-rpass-valgrind-exec \
270 check-stage$(1)-T-$(2)-H-$(3)-rmake-exec \
271 check-stage$(1)-T-$(2)-H-$(3)-rustdocck-exec \
272 check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
273 check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec \
274 check-stage$(1)-T-$(2)-H-$(3)-debuginfo-gdb-exec \
275 check-stage$(1)-T-$(2)-H-$(3)-debuginfo-lldb-exec \
276 check-stage$(1)-T-$(2)-H-$(3)-incremental-exec \
277 check-stage$(1)-T-$(2)-H-$(3)-ui-exec \
278 check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
279 check-stage$(1)-T-$(2)-H-$(3)-doc-error-index-exec \
280 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec \
281 check-stage$(1)-T-$(2)-H-$(3)-mir-opt-exec
282
283 ifndef CFG_DISABLE_CODEGEN_TESTS
284 check-stage$(1)-T-$(2)-H-$(3)-exec: \
285 check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
286 check-stage$(1)-T-$(2)-H-$(3)-codegen-units-exec
287 endif
288
289 # Only test the compiler-dependent crates when the target is
290 # able to build a compiler (when the target triple is in the set of host triples)
291 ifneq ($$(findstring $(2),$$(CFG_HOST)),)
292
293 check-stage$(1)-T-$(2)-H-$(3)-exec: \
294 check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
295 check-stage$(1)-T-$(2)-H-$(3)-rfail-full-exec \
296 check-stage$(1)-T-$(2)-H-$(3)-cfail-full-exec
297
298 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
299 check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec \
300 check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-full-exec
301
302 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
303 $$(foreach crate,$$(TEST_CRATES), \
304 check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
305
306 else
307
308 check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
309 $$(foreach crate,$$(TEST_TARGET_CRATES), \
310 check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
311
312 endif
313
314 check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec: \
315 $$(foreach crate,$$(TEST_DOC_CRATES), \
316 check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$$(crate)-exec)
317
318 check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
319 $$(foreach docname,$$(DOC_NAMES), \
320 check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec) \
321
322 check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
323 check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
324 check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-valgrind-exec \
325 check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
326 check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
327
328 endef
329
330 $(foreach host,$(CFG_HOST), \
331 $(foreach target,$(CFG_TARGET), \
332 $(foreach stage,$(STAGES), \
333 $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
334
335
336 ######################################################################
337 # Crate testing
338 ######################################################################
339
340 define TEST_RUNNER
341
342 # If NO_REBUILD is set then break the dependencies on everything but
343 # the source files so we can test crates without rebuilding any of the
344 # parent crates.
345 ifeq ($(NO_REBUILD),)
346 TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
347 $$(foreach crate,$$(TARGET_CRATES_$(2)), \
348 $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
349 $$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))
350
351 else
352 TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
353 endif
354
355 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): CFG_COMPILER_HOST_TRIPLE = $(2)
356 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
357 $$(CRATEFILE_$(4)) \
358 $$(TESTDEP_$(1)_$(2)_$(3)_$(4))
359 @$$(call E, rustc: $$@)
360 $(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
361 $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
362 -Cmetadata="test-crate" -L "$$(RT_OUTPUT_DIR_$(2))" \
363 $$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
364 $$(RUSTFLAGS_$(4))
365
366 endef
367
368 $(foreach host,$(CFG_HOST), \
369 $(eval $(foreach target,$(CFG_TARGET), \
370 $(eval $(foreach stage,$(STAGES), \
371 $(eval $(foreach crate,$(TEST_CRATES), \
372 $(eval $(call TEST_RUNNER,$(stage),$(target),$(host),$(crate))))))))))
373
374 define DEF_TEST_CRATE_RULES
375 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
376
377 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
378 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
379 @$$(call E, run: $$<)
380 $$(Q)touch $$@.start_time
381 $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(1),$(2),$(3)) $$(TESTARGS) \
382 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
383 $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) \
384 && touch -r $$@.start_time $$@ && rm $$@.start_time
385 endef
386
387 define DEF_TEST_CRATE_RULES_android
388 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
389
390 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
391 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
392 @$$(call E, run: $$< via adb)
393 $$(Q)touch $$@.start_time
394 $$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
395 $$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=./$(2) \
396 ./$$(notdir $$<) \
397 --logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
398 $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
399 > tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
400 $$(Q)cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
401 $$(Q)touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
402 $$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
403 $$(Q)$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
404 @if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
405 then \
406 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
407 touch -r $$@.start_time $$@ && rm $$@.start_time; \
408 else \
409 rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
410 exit 101; \
411 fi
412 endef
413
414 define DEF_TEST_CRATE_RULES_null
415 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
416
417 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
418 $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
419 @$$(call E, failing: no device for $$< )
420 false
421 endef
422
423 $(foreach host,$(CFG_HOST), \
424 $(foreach target,$(CFG_TARGET), \
425 $(foreach stage,$(STAGES), \
426 $(foreach crate, $(TEST_CRATES), \
427 $(if $(findstring $(target),$(CFG_BUILD)), \
428 $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
429 $(if $(findstring android, $(target)), \
430 $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
431 $(eval $(call DEF_TEST_CRATE_RULES_android,$(stage),$(target),$(host),$(crate))), \
432 $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
433 ), \
434 $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
435 ))))))
436
437 ######################################################################
438 # Rules for the compiletest tests (rpass, rfail, etc.)
439 ######################################################################
440
441 RPASS_RS := $(call rwildcard,$(S)src/test/run-pass/,*.rs)
442 RPASS_VALGRIND_RS := $(call rwildcard,$(S)src/test/run-pass-valgrind/,*.rs)
443 RPASS_FULL_RS := $(call rwildcard,$(S)src/test/run-pass-fulldeps/,*.rs)
444 RFAIL_FULL_RS := $(call rwildcard,$(S)src/test/run-fail-fulldeps/,*.rs)
445 CFAIL_FULL_RS := $(call rwildcard,$(S)src/test/compile-fail-fulldeps/,*.rs)
446 RFAIL_RS := $(call rwildcard,$(S)src/test/run-fail/,*.rs)
447 RFAIL_RS := $(call rwildcard,$(S)src/test/run-fail/,*.rs)
448 CFAIL_RS := $(call rwildcard,$(S)src/test/compile-fail/,*.rs)
449 PFAIL_RS := $(call rwildcard,$(S)src/test/parse-fail/,*.rs)
450 PRETTY_RS := $(call rwildcard,$(S)src/test/pretty/,*.rs)
451 DEBUGINFO_GDB_RS := $(call rwildcard,$(S)src/test/debuginfo/,*.rs)
452 DEBUGINFO_LLDB_RS := $(call rwildcard,$(S)src/test/debuginfo/,*.rs)
453 CODEGEN_RS := $(call rwildcard,$(S)src/test/codegen/,*.rs)
454 CODEGEN_CC := $(call rwildcard,$(S)src/test/codegen/,*.cc)
455 CODEGEN_UNITS_RS := $(call rwildcard,$(S)src/test/codegen-units/,*.rs)
456 INCREMENTAL_RS := $(call rwildcard,$(S)src/test/incremental/,*.rs)
457 RMAKE_RS := $(wildcard $(S)src/test/run-make/*/Makefile)
458 UI_RS := $(call rwildcard,$(S)src/test/ui/,*.rs) \
459 $(call rwildcard,$(S)src/test/ui/,*.stdout) \
460 $(call rwildcard,$(S)src/test/ui/,*.stderr)
461 RUSTDOCCK_RS := $(call rwildcard,$(S)src/test/rustdoc/,*.rs)
462 MIR_OPT_RS := $(call rwildcard,$(S)src/test/mir-opt/,*.rs)
463
464 RPASS_TESTS := $(RPASS_RS)
465 RPASS_VALGRIND_TESTS := $(RPASS_VALGRIND_RS)
466 RPASS_FULL_TESTS := $(RPASS_FULL_RS)
467 RFAIL_FULL_TESTS := $(RFAIL_FULL_RS)
468 CFAIL_FULL_TESTS := $(CFAIL_FULL_RS)
469 RFAIL_TESTS := $(RFAIL_RS)
470 CFAIL_TESTS := $(CFAIL_RS)
471 PFAIL_TESTS := $(PFAIL_RS)
472 PRETTY_TESTS := $(PRETTY_RS)
473 DEBUGINFO_GDB_TESTS := $(DEBUGINFO_GDB_RS)
474 DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
475 CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
476 CODEGEN_UNITS_TESTS := $(CODEGEN_UNITS_RS)
477 INCREMENTAL_TESTS := $(INCREMENTAL_RS)
478 RMAKE_TESTS := $(RMAKE_RS)
479 UI_TESTS := $(UI_RS)
480 MIR_OPT_TESTS := $(MIR_OPT_RS)
481 RUSTDOCCK_TESTS := $(RUSTDOCCK_RS)
482
483 CTEST_SRC_BASE_rpass = run-pass
484 CTEST_BUILD_BASE_rpass = run-pass
485 CTEST_MODE_rpass = run-pass
486 CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
487
488 CTEST_SRC_BASE_rpass-valgrind = run-pass-valgrind
489 CTEST_BUILD_BASE_rpass-valgrind = run-pass-valgrind
490 CTEST_MODE_rpass-valgrind = run-pass-valgrind
491 CTEST_RUNTOOL_rpass-valgrind = $(CTEST_RUNTOOL)
492
493 CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
494 CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps
495 CTEST_MODE_rpass-full = run-pass
496 CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
497
498 CTEST_SRC_BASE_rfail-full = run-fail-fulldeps
499 CTEST_BUILD_BASE_rfail-full = run-fail-fulldeps
500 CTEST_MODE_rfail-full = run-fail
501 CTEST_RUNTOOL_rfail-full = $(CTEST_RUNTOOL)
502
503 CTEST_SRC_BASE_cfail-full = compile-fail-fulldeps
504 CTEST_BUILD_BASE_cfail-full = compile-fail-fulldeps
505 CTEST_MODE_cfail-full = compile-fail
506 CTEST_RUNTOOL_cfail-full = $(CTEST_RUNTOOL)
507
508 CTEST_SRC_BASE_rfail = run-fail
509 CTEST_BUILD_BASE_rfail = run-fail
510 CTEST_MODE_rfail = run-fail
511 CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
512
513 CTEST_SRC_BASE_cfail = compile-fail
514 CTEST_BUILD_BASE_cfail = compile-fail
515 CTEST_MODE_cfail = compile-fail
516 CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
517
518 CTEST_SRC_BASE_pfail = parse-fail
519 CTEST_BUILD_BASE_pfail = parse-fail
520 CTEST_MODE_pfail = parse-fail
521 CTEST_RUNTOOL_pfail = $(CTEST_RUNTOOL)
522
523 CTEST_SRC_BASE_debuginfo-gdb = debuginfo
524 CTEST_BUILD_BASE_debuginfo-gdb = debuginfo-gdb
525 CTEST_MODE_debuginfo-gdb = debuginfo-gdb
526 CTEST_RUNTOOL_debuginfo-gdb = $(CTEST_RUNTOOL)
527
528 CTEST_SRC_BASE_debuginfo-lldb = debuginfo
529 CTEST_BUILD_BASE_debuginfo-lldb = debuginfo-lldb
530 CTEST_MODE_debuginfo-lldb = debuginfo-lldb
531 CTEST_RUNTOOL_debuginfo-lldb = $(CTEST_RUNTOOL)
532
533 CTEST_SRC_BASE_codegen = codegen
534 CTEST_BUILD_BASE_codegen = codegen
535 CTEST_MODE_codegen = codegen
536 CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)
537
538 CTEST_SRC_BASE_codegen-units = codegen-units
539 CTEST_BUILD_BASE_codegen-units = codegen-units
540 CTEST_MODE_codegen-units = codegen-units
541 CTEST_RUNTOOL_codegen-units = $(CTEST_RUNTOOL)
542
543 CTEST_SRC_BASE_incremental = incremental
544 CTEST_BUILD_BASE_incremental = incremental
545 CTEST_MODE_incremental = incremental
546 CTEST_RUNTOOL_incremental = $(CTEST_RUNTOOL)
547
548 CTEST_SRC_BASE_rmake = run-make
549 CTEST_BUILD_BASE_rmake = run-make
550 CTEST_MODE_rmake = run-make
551 CTEST_RUNTOOL_rmake = $(CTEST_RUNTOOL)
552
553 CTEST_SRC_BASE_ui = ui
554 CTEST_BUILD_BASE_ui = ui
555 CTEST_MODE_ui = ui
556 CTEST_RUNTOOL_ui = $(CTEST_RUNTOOL)
557
558 CTEST_SRC_BASE_mir-opt = mir-opt
559 CTEST_BUILD_BASE_mir-opt = mir-opt
560 CTEST_MODE_mir-opt = mir-opt
561 CTEST_RUNTOOL_mir-opt = $(CTEST_RUNTOOL)
562
563 CTEST_SRC_BASE_rustdocck = rustdoc
564 CTEST_BUILD_BASE_rustdocck = rustdoc
565 CTEST_MODE_rustdocck = rustdoc
566 CTEST_RUNTOOL_rustdocck = $(CTEST_RUNTOOL)
567
568 # CTEST_DISABLE_$(TEST_GROUP), if set, will cause the test group to be
569 # disabled and the associated message to be printed as a warning
570 # during attempts to run those tests.
571
572 ifeq ($(CFG_GDB),)
573 CTEST_DISABLE_debuginfo-gdb = "no gdb found"
574 endif
575
576 ifeq ($(CFG_LLDB),)
577 CTEST_DISABLE_debuginfo-lldb = "no lldb found"
578 endif
579
580 ifneq ($(CFG_OSTYPE),apple-darwin)
581 CTEST_DISABLE_debuginfo-lldb = "lldb tests are only run on darwin"
582 endif
583
584 ifeq ($(CFG_OSTYPE),apple-darwin)
585 CTEST_DISABLE_debuginfo-gdb = "gdb on darwin needs root"
586 endif
587
588 ifeq ($(findstring android, $(CFG_TARGET)), android)
589 CTEST_DISABLE_debuginfo-gdb =
590 CTEST_DISABLE_debuginfo-lldb = "lldb tests are disabled on android"
591 endif
592
593 ifeq ($(findstring msvc,$(CFG_TARGET)),msvc)
594 CTEST_DISABLE_debuginfo-gdb = "gdb tests are disabled on MSVC"
595 endif
596
597 # CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that
598 # test group to be disabled *unless* the target is able to build a
599 # compiler (i.e. when the target triple is in the set of host
600 # triples). The associated message will be printed as a warning
601 # during attempts to run those tests.
602
603 define DEF_CTEST_VARS
604
605 # All the per-stage build rules you might want to call from the
606 # command line.
607 #
608 # $(1) is the stage number
609 # $(2) is the target triple to test
610 # $(3) is the host triple to test
611
612 # Prerequisites for compiletest tests
613 TEST_SREQ$(1)_T_$(2)_H_$(3) = \
614 $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
615 $$(SREQ$(1)_T_$(2)_H_$(3))
616
617 # Rules for the cfail/rfail/rpass test runner
618
619 # The tests select when to use debug configuration on their own;
620 # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
621 CTEST_RUSTC_FLAGS := $$(subst -C debug-assertions,,$$(subst -C debug-assertions=on,,$$(CFG_RUSTC_FLAGS)))
622
623 # The tests cannot be optimized while the rest of the compiler is optimized, so
624 # filter out the optimization (if any) from rustc and then figure out if we need
625 # to be optimized
626 CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
627 ifndef CFG_DISABLE_OPTIMIZE_TESTS
628 CTEST_RUSTC_FLAGS += -O
629 endif
630
631 # Analogously to the above, whether to pass `-g` when compiling tests
632 # is a separate choice from whether to pass `-g` when building the
633 # compiler and standard library themselves.
634 CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS))
635 CTEST_RUSTC_FLAGS := $$(subst -Cdebuginfo=1,,$$(CTEST_RUSTC_FLAGS))
636 ifdef CFG_ENABLE_DEBUGINFO_TESTS
637 CTEST_RUSTC_FLAGS += -g
638 endif
639
640 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
641 --compile-lib-path $$(HLIB$(1)_H_$(3)) \
642 --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
643 --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
644 --rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
645 --llvm-filecheck $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin/FileCheck \
646 --stage-id stage$(1)-$(2) \
647 --target $(2) \
648 --host $(3) \
649 --docck-python $$(CFG_PYTHON) \
650 --lldb-python $$(CFG_LLDB_PYTHON) \
651 --gdb="$(CFG_GDB)" \
652 --lldb-version="$(CFG_LLDB_VERSION)" \
653 --llvm-version="$$(LLVM_VERSION_$(3))" \
654 --android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
655 --adb-path=$(CFG_ADB) \
656 --adb-test-dir=$(CFG_ADB_TEST_DIR) \
657 --host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
658 --lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
659 --target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
660 --cc '$$(call FIND_COMPILER,$$(CC_$(2)))' \
661 --cxx '$$(call FIND_COMPILER,$$(CXX_$(2)))' \
662 --cflags "$$(CFG_GCCISH_CFLAGS_$(2))" \
663 --llvm-components "$$(LLVM_ALL_COMPONENTS_$(2))" \
664 --llvm-cxxflags "$$(LLVM_CXXFLAGS_$(2))" \
665 $$(CTEST_TESTARGS)
666
667 ifdef CFG_VALGRIND_RPASS
668 ifdef GOOD_VALGRIND_$(2)
669 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) += --valgrind-path "$(CFG_VALGRIND_RPASS)"
670 endif
671 endif
672
673 ifndef CFG_DISABLE_VALGRIND_RPASS
674 ifdef GOOD_VALGRIND_$(2)
675 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) += --force-valgrind
676 endif
677 endif
678
679 CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
680 CTEST_DEPS_rpass-valgrind_$(1)-T-$(2)-H-$(3) = $$(RPASS_VALGRIND_TESTS)
681 CTEST_DEPS_rpass-full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
682 CTEST_DEPS_rfail-full_$(1)-T-$(2)-H-$(3) = $$(RFAIL_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
683 CTEST_DEPS_cfail-full_$(1)-T-$(2)-H-$(3) = $$(CFAIL_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
684 CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
685 CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
686 CTEST_DEPS_pfail_$(1)-T-$(2)-H-$(3) = $$(PFAIL_TESTS)
687 CTEST_DEPS_debuginfo-gdb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_GDB_TESTS)
688 CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
689 $(S)src/etc/lldb_batchmode.py \
690 $(S)src/etc/lldb_rust_formatters.py
691 CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
692 CTEST_DEPS_codegen-units_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_UNITS_TESTS)
693 CTEST_DEPS_incremental_$(1)-T-$(2)-H-$(3) = $$(INCREMENTAL_TESTS)
694 CTEST_DEPS_rmake_$(1)-T-$(2)-H-$(3) = $$(RMAKE_TESTS) \
695 $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
696 CTEST_DEPS_ui_$(1)-T-$(2)-H-$(3) = $$(UI_TESTS)
697 CTEST_DEPS_mir-opt_$(1)-T-$(2)-H-$(3) = $$(MIR_OPT_TESTS)
698 CTEST_DEPS_rustdocck_$(1)-T-$(2)-H-$(3) = $$(RUSTDOCCK_TESTS) \
699 $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
700 $$(CSREQ$(1)_T_$(3)_H_$(3)) \
701 $$(SREQ$(1)_T_$(3)_H_$(3)) \
702 $(S)src/etc/htmldocck.py
703
704 endef
705
706 $(foreach host,$(CFG_HOST), \
707 $(eval $(foreach target,$(CFG_TARGET), \
708 $(eval $(foreach stage,$(STAGES), \
709 $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
710
711 define DEF_RUN_COMPILETEST
712
713 CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) = \
714 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
715 --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
716 --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
717 --mode $$(CTEST_MODE_$(4)) \
718 $$(CTEST_RUNTOOL_$(4))
719
720 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
721
722 # CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)
723 # Goal: leave this variable as empty string if we should run the test.
724 # Otherwise, set it to the reason we are not running the test.
725 # (Encoded as a separate variable because GNU make does not have a
726 # good way to express OR on ifeq commands)
727
728 ifneq ($$(CTEST_DISABLE_$(4)),)
729 # Test suite is disabled for all configured targets.
730 CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4) := $$(CTEST_DISABLE_$(4))
731 else
732 # else, check if non-self-hosted target (i.e. target not-in hosts) ...
733 ifeq ($$(findstring $(2),$$(CFG_HOST)),)
734 # ... if so, then check if this test suite is disabled for non-selfhosts.
735 ifneq ($$(CTEST_DISABLE_NONSELFHOST_$(4)),)
736 # Test suite is disabled for this target.
737 CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4) := $$(CTEST_DISABLE_NONSELFHOST_$(4))
738 endif
739 endif
740 # Neither DISABLE nor DISABLE_NONSELFHOST is set ==> okay, run the test.
741 endif
742
743 ifeq ($$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)),)
744 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
745 export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
746 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
747 export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
748 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
749 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
750 $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
751 @$$(call E, run $(4) [$(2)]: $$<)
752 $$(Q)touch $$@.start_time
753 $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
754 $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
755 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
756 && touch -r $$@.start_time $$@ && rm $$@.start_time
757
758 else
759
760 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)):
761 @$$(call E, run $(4) [$(2)]: $$<)
762 @$$(call E, warning: tests disabled: $$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)))
763 touch $$@
764
765 endif
766
767 endef
768
769 CTEST_NAMES = rpass rpass-valgrind rpass-full rfail-full cfail-full rfail cfail pfail \
770 debuginfo-gdb debuginfo-lldb codegen codegen-units rustdocck incremental \
771 rmake ui mir-opt
772
773 $(foreach host,$(CFG_HOST), \
774 $(eval $(foreach target,$(CFG_TARGET), \
775 $(eval $(foreach stage,$(STAGES), \
776 $(eval $(foreach name,$(CTEST_NAMES), \
777 $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
778
779 PRETTY_NAMES = pretty-rpass pretty-rpass-valgrind pretty-rpass-full pretty-rfail-full pretty-rfail \
780 pretty-pretty
781 PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
782 PRETTY_DEPS_pretty-rpass-valgrind = $(RPASS_VALGRIND_TESTS)
783 PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
784 PRETTY_DEPS_pretty-rfail-full = $(RFAIL_FULL_TESTS)
785 PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
786 PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
787 PRETTY_DIRNAME_pretty-rpass = run-pass
788 PRETTY_DIRNAME_pretty-rpass-valgrind = run-pass-valgrind
789 PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
790 PRETTY_DIRNAME_pretty-rfail-full = run-fail-fulldeps
791 PRETTY_DIRNAME_pretty-rfail = run-fail
792 PRETTY_DIRNAME_pretty-pretty = pretty
793
794 define DEF_PRETTY_FULLDEPS
795 PRETTY_DEPS$(1)_T_$(2)_H_$(3)_pretty-rpass-full = $$(CSREQ$(1)_T_$(3)_H_$(3))
796 PRETTY_DEPS$(1)_T_$(2)_H_$(3)_pretty-rfail-full = $$(CSREQ$(1)_T_$(3)_H_$(3))
797 endef
798
799 $(foreach host,$(CFG_HOST), \
800 $(foreach target,$(CFG_TARGET), \
801 $(foreach stage,$(STAGES), \
802 $(eval $(call DEF_PRETTY_FULLDEPS,$(stage),$(target),$(host))))))
803
804 define DEF_RUN_PRETTY_TEST
805
806 PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) = \
807 $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
808 --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
809 --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
810 --mode pretty
811
812 check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
813
814 $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
815 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
816 $$(PRETTY_DEPS_$(4)) \
817 $$(PRETTY_DEPS$(1)_T_$(2)_H_$(3)_$(4))
818 @$$(call E, run pretty-rpass [$(2)]: $$<)
819 $$(Q)touch $$@.start_time
820 $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
821 $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
822 --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
823 && touch -r $$@.start_time $$@ && rm $$@.start_time
824
825 endef
826
827 $(foreach host,$(CFG_HOST), \
828 $(foreach target,$(CFG_TARGET), \
829 $(foreach stage,$(STAGES), \
830 $(foreach pretty-name,$(PRETTY_NAMES), \
831 $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
832
833
834 ######################################################################
835 # Crate & freestanding documentation tests
836 ######################################################################
837
838 define DEF_RUSTDOC
839 RUSTDOC_EXE_$(1)_T_$(2)_H_$(3) := $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
840 RUSTDOC_$(1)_T_$(2)_H_$(3) := $$(RPATH_VAR$(1)_T_$(2)_H_$(3)) $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
841 endef
842
843 $(foreach host,$(CFG_HOST), \
844 $(foreach target,$(CFG_TARGET), \
845 $(foreach stage,$(STAGES), \
846 $(eval $(call DEF_RUSTDOC,$(stage),$(target),$(host))))))
847
848 # Freestanding
849
850 define DEF_DOC_TEST
851
852 check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
853
854 # If NO_REBUILD is set then break the dependencies on everything but
855 # the source files so we can test documentation without rebuilding
856 # rustdoc etc.
857 ifeq ($(NO_REBUILD),)
858 DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
859 $$(DOCFILE_$(4)) \
860 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
861 $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
862 else
863 DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(DOCFILE_$(4))
864 endif
865
866 ifeq ($(2),$$(CFG_BUILD))
867 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
868 @$$(call E, run doc-$(4) [$(2)])
869 $$(Q)touch $$@.start_time
870 $$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --cfg dox --test $$< \
871 --test-args "$$(TESTARGS)" && \
872 touch -r $$@.start_time $$@ && rm $$@.start_time
873 else
874 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)):
875 touch $$@
876 endif
877 endef
878
879 $(foreach host,$(CFG_HOST), \
880 $(foreach target,$(CFG_TARGET), \
881 $(foreach stage,$(STAGES), \
882 $(foreach docname,$(DOC_NAMES), \
883 $(eval $(call DEF_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
884
885 # Crates
886
887 define DEF_CRATE_DOC_TEST
888
889 # If NO_REBUILD is set then break the dependencies on everything but
890 # the source files so we can test crate documentation without
891 # rebuilding any of the parent crates.
892 ifeq ($(NO_REBUILD),)
893 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
894 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
895 $$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
896 $$(RUSTDOC_EXE_$(1)_T_$(2)_H_$(3))
897 else
898 CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
899 endif
900
901 check-stage$(1)-T-$(2)-H-$(3)-doc-crate-$(4)-exec: \
902 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4))
903
904 ifeq ($(2),$$(CFG_BUILD))
905 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
906 @$$(call E, run doc-crate-$(4) [$(2)])
907 $$(Q)touch $$@.start_time
908 $$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
909 $$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
910 $$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && \
911 touch -r $$@.start_time $$@ && rm $$@.start_time
912 else
913 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)):
914 touch $$@
915 endif
916
917 endef
918
919 $(foreach host,$(CFG_HOST), \
920 $(foreach target,$(CFG_TARGET), \
921 $(foreach stage,$(STAGES), \
922 $(foreach crate,$(TEST_DOC_CRATES), \
923 $(eval $(call DEF_CRATE_DOC_TEST,$(stage),$(target),$(host),$(crate)))))))
924
925 define DEF_DOC_TEST_ERROR_INDEX
926
927 check-stage$(1)-T-$(2)-H-$(3)-doc-error-index-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-error-index)
928
929 ifeq ($(2),$$(CFG_BUILD))
930 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-error-index): \
931 $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
932 doc/error-index.md
933 $$(Q)touch $$@.start_time
934 $$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test doc/error-index.md
935 $$(Q)touch -r $$@.start_time $$@ && rm $$@.start_time
936 else
937 $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-error-index):
938 $$(Q)touch $$@
939 endif
940 endef
941
942 $(foreach host,$(CFG_HOST), \
943 $(foreach target,$(CFG_TARGET), \
944 $(foreach stage,$(STAGES), \
945 $(eval $(call DEF_DOC_TEST_ERROR_INDEX,$(stage),$(target),$(host))))))
946
947 ######################################################################
948 # Shortcut rules
949 ######################################################################
950
951 TEST_GROUPS = \
952 crates \
953 $(foreach crate,$(TEST_CRATES),$(crate)) \
954 $(foreach crate,$(TEST_DOC_CRATES),doc-crate-$(crate)) \
955 rpass \
956 rpass-valgrind \
957 rpass-full \
958 rfail-full \
959 cfail-full \
960 rfail \
961 cfail \
962 pfail \
963 rmake \
964 rustdocck \
965 debuginfo-gdb \
966 debuginfo-lldb \
967 codegen \
968 codegen-units \
969 incremental \
970 ui \
971 doc \
972 $(foreach docname,$(DOC_NAMES),doc-$(docname)) \
973 pretty \
974 pretty-rpass \
975 pretty-rpass-valgrind \
976 pretty-rpass-full \
977 pretty-rfail-full \
978 pretty-rfail \
979 pretty-pretty \
980 mir-opt \
981 $(NULL)
982
983 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
984 check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
985 endef
986
987 $(foreach stage,$(STAGES), \
988 $(foreach target,$(CFG_TARGET), \
989 $(foreach host,$(CFG_HOST), \
990 $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
991
992 define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
993 check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
994 endef
995
996 $(foreach stage,$(STAGES), \
997 $(foreach target,$(CFG_TARGET), \
998 $(foreach host,$(CFG_HOST), \
999 $(foreach group,$(TEST_GROUPS), \
1000 $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
1001
1002 define DEF_CHECK_FOR_STAGE
1003 check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD)
1004 check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET), \
1005 check-stage$(1)-H-$$(target))
1006 endef
1007
1008 $(foreach stage,$(STAGES), \
1009 $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
1010
1011 define DEF_CHECK_FOR_STAGE_AND_GROUP
1012 check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD)-$(2)
1013 check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET), \
1014 check-stage$(1)-H-$$(target)-$(2))
1015 endef
1016
1017 $(foreach stage,$(STAGES), \
1018 $(foreach group,$(TEST_GROUPS), \
1019 $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
1020
1021
1022 define DEF_CHECK_FOR_STAGE_AND_HOSTS
1023 check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET), \
1024 check-stage$(1)-T-$$(target)-H-$(2))
1025 endef
1026
1027 $(foreach stage,$(STAGES), \
1028 $(foreach host,$(CFG_HOST), \
1029 $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
1030
1031 define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
1032 check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET), \
1033 check-stage$(1)-T-$$(target)-H-$(2)-$(3))
1034 endef
1035
1036 $(foreach stage,$(STAGES), \
1037 $(foreach host,$(CFG_HOST), \
1038 $(foreach group,$(TEST_GROUPS), \
1039 $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
1040
1041 define DEF_CHECK_DOC_FOR_STAGE
1042 check-stage$(1)-docs: $$(foreach docname,$$(DOC_NAMES), \
1043 check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-$$(docname)) \
1044 $$(foreach crate,$$(TEST_DOC_CRATES), \
1045 check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-crate-$$(crate)) \
1046 check-stage$(1)-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-doc-error-index-exec
1047 endef
1048
1049 $(foreach stage,$(STAGES), \
1050 $(eval $(call DEF_CHECK_DOC_FOR_STAGE,$(stage))))
1051
1052 define DEF_CHECK_CRATE
1053 check-$(1): check-stage2-T-$$(CFG_BUILD)-H-$$(CFG_BUILD)-$(1)-exec
1054 endef
1055
1056 $(foreach crate,$(TEST_CRATES), \
1057 $(eval $(call DEF_CHECK_CRATE,$(crate))))