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