tests.mk 30.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

11

G
Graydon Hoare 已提交
12
######################################################################
13
# Test variables
G
Graydon Hoare 已提交
14 15
######################################################################

16
# The names of crates that must be tested
17 18 19
TEST_TARGET_CRATES = $(TARGET_CRATES)
TEST_DOC_CRATES = $(DOC_CRATES)
TEST_HOST_CRATES = $(HOST_CRATES)
20
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
G
Graydon Hoare 已提交
21

22
# Markdown files under doc/ that should have their code extracted and run
23
DOC_TEST_NAMES = tutorial guide-ffi guide-macros guide-lifetimes \
A
Alex Crichton 已提交
24
                 guide-tasks guide-container guide-pointers \
25
                 complement-cheatsheet guide-runtime \
26
                 rust
27

28 29 30
######################################################################
# Environment configuration
######################################################################
31

B
Brian Anderson 已提交
32 33 34 35 36
# The arguments to all test runners
ifdef TESTNAME
  TESTARGS += $(TESTNAME)
endif

37
ifdef CHECK_IGNORED
B
Brian Anderson 已提交
38 39 40
  TESTARGS += --ignored
endif

41
TEST_BENCH = --bench
42

B
Brian Anderson 已提交
43 44 45
# Arguments to the cfail/rfail/rpass/bench tests
ifdef CFG_VALGRIND
  CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
46
  TEST_BENCH =
B
Brian Anderson 已提交
47
endif
48

49 50
ifdef NO_BENCH
  TEST_BENCH =
B
Brian Anderson 已提交
51
endif
52

53 54 55 56 57
# Arguments to the perf tests
ifdef CFG_PERF_TOOL
  CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
endif

B
Brian Anderson 已提交
58
CTEST_TESTARGS := $(TESTARGS)
G
Graydon Hoare 已提交
59

B
Brian Anderson 已提交
60 61 62
ifdef VERBOSE
  CTEST_TESTARGS += --verbose
endif
63

64 65 66 67 68 69 70
# If we're running perf then set this environment variable
# to put the benchmarks into 'hard mode'
ifeq ($(MAKECMDGOALS),perf)
  RUST_BENCH=1
  export RUST_BENCH
endif

71 72
TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
73

74 75 76 77 78
TEST_RATCHET_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4)-metrics.json
TEST_RATCHET_NOISE_PERCENT=10.0

# Whether to ratchet or merely save benchmarks
ifdef CFG_RATCHET_BENCH
79
CRATE_TEST_EXTRA_ARGS=\
80
  --test $(TEST_BENCH) \
81 82 83
  --ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
  --ratchet-noise-percent $(TEST_RATCHET_NOISE_PERCENT)
else
84
CRATE_TEST_EXTRA_ARGS=\
85
  --test $(TEST_BENCH) \
86 87 88
  --save-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4))
endif

89 90 91 92 93 94 95 96
# If we're sharding the testsuite between parallel testers,
# pass this argument along to the compiletest and crate test
# invocations.
ifdef TEST_SHARD
  CTEST_TESTARGS += --test-shard=$(TEST_SHARD)
  CRATE_TEST_EXTRA_ARGS += --test-shard=$(TEST_SHARD)
endif

97 98 99 100 101 102 103
define DEF_TARGET_COMMANDS

ifdef CFG_UNIXY_$(1)
  CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
endif

ifdef CFG_WINDOWSY_$(1)
C
Chris Morgan 已提交
104
  CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)$$(2)/$$(strip \
105
   $$(if $$(findstring stage0,$$(1)), \
106
       stage0/$$(CFG_LIBDIR_RELATIVE), \
107
      $$(if $$(findstring stage1,$$(1)), \
108
           stage1/$$(CFG_LIBDIR_RELATIVE), \
109
          $$(if $$(findstring stage2,$$(1)), \
110
               stage2/$$(CFG_LIBDIR_RELATIVE), \
111
               $$(if $$(findstring stage3,$$(1)), \
112
                    stage3/$$(CFG_LIBDIR_RELATIVE), \
113
               )))))/$$(CFG_RUSTLIBDIR)/$$(CFG_BUILD)/lib
114 115 116 117 118
  CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
endif

# Run the compiletest runner itself under valgrind
ifdef CTEST_VALGRIND
119 120
CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \
      $$(call CFG_RUN_TEST_$$(CFG_BUILD),$$(2),$$(3))
121
else
122 123
CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \
      $$(call CFG_RUN_$$(CFG_BUILD),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
124 125 126 127
endif

endef

H
Heather 已提交
128
$(foreach target,$(CFG_TARGET), \
129 130
  $(eval $(call DEF_TARGET_COMMANDS,$(target))))

D
Daniel Micay 已提交
131
# Target platform specific variables
132
# for arm-linux-androidabi
133 134
define DEF_ADB_DEVICE_STATUS
CFG_ADB_DEVICE_STATUS=$(1)
135 136
endef

H
Heather 已提交
137
$(foreach target,$(CFG_TARGET), \
138 139
  $(if $(findstring $(target),"arm-linux-androideabi"), \
    $(if $(findstring adb,$(CFG_ADB)), \
140
      $(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[:_A-Za-z0-9-]+[[:blank:]]+device')), \
141 142 143 144
        $(info check: android device attached) \
        $(eval $(call DEF_ADB_DEVICE_STATUS, true)), \
        $(info check: android device not attached) \
        $(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
145
      ), \
146 147
      $(info check: adb not found) \
      $(eval $(call DEF_ADB_DEVICE_STATUS, false)) \
148
    ), \
149 150 151
  ) \
)

152 153
ifeq ($(CFG_ADB_DEVICE_STATUS),true)
CFG_ADB_TEST_DIR=/data/tmp
154

155
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
156 157 158 159 160
 $(shell $(CFG_ADB) remount 1>/dev/null) \
 $(shell $(CFG_ADB) shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
 $(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)) \
 $(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
 $(shell $(CFG_ADB) push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
A
Alex Crichton 已提交
161 162 163
 $(foreach crate,$(TARGET_CRATES),\
    $(shell $(CFG_ADB) push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_arm-linux-androideabi,$(crate)) \
                    $(CFG_ADB_TEST_DIR)))\
164
 )
165 166
else
CFG_ADB_TEST_DIR=
167
endif
168 169


B
Brian Anderson 已提交
170 171 172 173
######################################################################
# Main test targets
######################################################################

174 175 176 177 178 179 180 181 182 183 184 185 186 187
check: cleantestlibs cleantmptestlogs tidy all check-stage2
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-notidy: cleantestlibs cleantmptestlogs all check-stage2
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-full: cleantestlibs cleantmptestlogs tidy \
            all check-stage1 check-stage2 check-stage3
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-test: cleantestlibs cleantmptestlogs all check-stage2-rfail
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

check-lite: cleantestlibs cleantmptestlogs \
188 189
	$(foreach crate,$(TARGET_CRATES),check-stage2-$(crate)) \
	check-stage2-rpass \
A
Alex Crichton 已提交
190
	check-stage2-rfail check-stage2-cfail check-stage2-rmake
191 192
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

193 194 195 196
check-ref: cleantestlibs cleantmptestlogs check-stage2-rpass \
	check-stage2-rfail check-stage2-cfail check-stage2-rmake
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

197 198
.PHONY: cleantmptestlogs cleantestlibs

199 200
cleantmptestlogs:
	$(Q)rm -f tmp/*.log
201

202
cleantestlibs:
H
Heather 已提交
203
	$(Q)find $(CFG_BUILD)/test \
204 205 206 207 208 209 210
         -name '*.[odasS]' -o \
         -name '*.so' -o      \
         -name '*.dylib' -o   \
         -name '*.dll' -o     \
         -name '*.def' -o     \
         -name '*.bc' -o      \
         -name '*.dSYM' -o    \
211
         -name '*.libaux' -o      \
212
         -name '*.out' -o     \
B
Brian Leibig 已提交
213 214
         -name '*.err' -o     \
	 -name '*.debugger.script' \
215
         | xargs rm -rf
216

217

218 219 220
######################################################################
# Tidy
######################################################################
B
Brian Anderson 已提交
221

222
ifdef CFG_NOTIDY
B
Brian Anderson 已提交
223
tidy:
224
else
225 226 227 228

ALL_CS := $(wildcard $(S)src/rt/*.cpp \
                     $(S)src/rt/*/*.cpp \
                     $(S)src/rt/*/*/*.cpp \
229
                     $(S)src/rustllvm/*.cpp)
230
ALL_CS := $(filter-out $(S)src/rt/miniz.cpp \
A
Alex Crichton 已提交
231 232
		       $(wildcard $(S)src/rt/sundown/src/*.c) \
		       $(wildcard $(S)src/rt/sundown/html/*.c) \
233 234 235 236
	,$(ALL_CS))
ALL_HS := $(wildcard $(S)src/rt/*.h \
                     $(S)src/rt/*/*.h \
                     $(S)src/rt/*/*/*.h \
237
                     $(S)src/rustllvm/*.h)
238 239 240 241 242
ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
                       $(S)src/rt/vg/memcheck.h \
                       $(S)src/rt/msvc/typeof.h \
                       $(S)src/rt/msvc/stdint.h \
                       $(S)src/rt/msvc/inttypes.h \
A
Alex Crichton 已提交
243 244
		       $(wildcard $(S)src/rt/sundown/src/*.h) \
		       $(wildcard $(S)src/rt/sundown/html/*.h) \
245 246
	,$(ALL_HS))

247
# Run the tidy script in multiple parts to avoid huge 'echo' commands
248 249
tidy:
		@$(call E, check: formatting)
250
		$(Q)find $(S)src -name '*.r[sc]' \
251 252
		| grep '^$(S)src/libuv' -v \
		| grep '^$(S)src/llvm' -v \
253
		| grep '^$(S)src/gyp' -v \
254
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
255
		$(Q)find $(S)src/etc -name '*.py' \
256
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
257
		$(Q)echo $(ALL_CS) \
258
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
259
		$(Q)echo $(ALL_HS) \
260
		| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
261 262 263 264 265 266 267
		$(Q)find $(S)src -type f -perm +111 \
		    -not -name '*.rs' -and -not -name '*.py' \
		    -and -not -name '*.sh' \
		| grep '^$(S)src/llvm' -v \
		| grep '^$(S)src/libuv' -v \
		| grep '^$(S)src/gyp' -v \
		| grep '^$(S)src/etc' -v \
268
		| grep '^$(S)src/doc' -v \
269
		| grep '^$(S)src/compiler-rt' -v \
270
		| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
271

272
endif
273

274

B
Brian Anderson 已提交
275
######################################################################
276
# Sets of tests
B
Brian Anderson 已提交
277 278
######################################################################

279 280 281 282 283 284 285
define DEF_TEST_SETS

check-stage$(1)-T-$(2)-H-$(3)-exec:     				\
	check-stage$(1)-T-$(2)-H-$(3)-rpass-exec			\
	check-stage$(1)-T-$(2)-H-$(3)-rfail-exec			\
	check-stage$(1)-T-$(2)-H-$(3)-cfail-exec			\
	check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec			\
A
Alex Crichton 已提交
286 287
	check-stage$(1)-T-$(2)-H-$(3)-rmake-exec			\
        check-stage$(1)-T-$(2)-H-$(3)-crates-exec                       \
288
        check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec                   \
289
	check-stage$(1)-T-$(2)-H-$(3)-bench-exec			\
290
	check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \
291
	check-stage$(1)-T-$(2)-H-$(3)-codegen-exec \
292 293 294
	check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
	check-stage$(1)-T-$(2)-H-$(3)-pretty-exec

295 296
# Only test the compiler-dependent crates when the target is
# able to build a compiler (when the target triple is in the set of host triples)
H
Heather 已提交
297
ifneq ($$(findstring $(2),$$(CFG_HOST)),)
298

299 300 301 302
check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
	$$(foreach crate,$$(TEST_CRATES), \
           check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)

303 304 305 306 307 308 309 310
else

check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
	$$(foreach crate,$$(TEST_TARGET_CRATES), \
           check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)

endif

311 312 313 314
check-stage$(1)-T-$(2)-H-$(3)-doc-crates-exec: \
        $$(foreach crate,$$(TEST_DOC_CRATES), \
           check-stage$(1)-T-$(2)-H-$(3)-doc-$$(crate)-exec)

315 316 317 318 319 320 321 322 323 324
check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
        $$(foreach docname,$$(DOC_TEST_NAMES), \
           check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)

check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
	check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec	\
	check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
325

B
Brian Anderson 已提交
326 327
endef

H
Heather 已提交
328 329
$(foreach host,$(CFG_HOST), \
 $(foreach target,$(CFG_TARGET), \
330 331 332
  $(foreach stage,$(STAGES), \
    $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))

B
Brian Anderson 已提交
333

334
######################################################################
335
# Crate testing
336 337
######################################################################

338
define TEST_RUNNER
339

340 341 342
# If NO_REBUILD is set then break the dependencies on everything but
# the source files so we can test crates without rebuilding any of the
# parent crates.
343
ifeq ($(NO_REBUILD),)
344
TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
A
Alex Crichton 已提交
345
			    $$(foreach crate,$$(TARGET_CRATES),\
346 347
				$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
				$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))
348
else
349
TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
350 351
endif

352 353
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): CFG_COMPILER = $(2)
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)):				\
354 355
		$$(CRATEFILE_$(4)) \
		$$(TESTDEP_$(1)_$(2)_$(3)_$(4))
356
	@$$(call E, oxidize: $$@)
357 358 359
	$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test	\
		-L "$$(RT_OUTPUT_DIR_$(2))"		\
		-L "$$(LLVM_LIBDIR_$(2))"
360

361 362
endef

H
Heather 已提交
363 364
$(foreach host,$(CFG_HOST), \
 $(eval $(foreach target,$(CFG_TARGET), \
365
  $(eval $(foreach stage,$(STAGES), \
366 367
   $(eval $(foreach crate,$(TEST_CRATES), \
    $(eval $(call TEST_RUNNER,$(stage),$(target),$(host),$(crate))))))))))
368 369

define DEF_TEST_CRATE_RULES
370 371
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

372 373
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

374
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
A
Alex Crichton 已提交
375
		$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
376
	@$$(call E, run: $$<)
377 378 379 380
	$$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
	    --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
	    $$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) \
	    && touch $$@
381
endef
382

383 384 385 386
define DEF_TEST_CRATE_RULES_arm-linux-androideabi
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
A
Alex Crichton 已提交
387
		$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
388
	@$$(call E, run: $$< via adb)
389 390
	$$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
	$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
391
		./$$(notdir $$<) \
392
		--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
393
		$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
394
		> tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
395 396 397 398 399
	$$(Q)cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
	$$(Q)touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
	$$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
	$$(Q)$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
	$$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/$$(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) tmp/
400 401 402 403 404 405 406 407 408 409 410 411 412 413
	@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
	then \
		rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
		touch $$@; \
	else \
		rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
		exit 101; \
	fi
endef

define DEF_TEST_CRATE_RULES_null
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
A
Alex Crichton 已提交
414
		$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
415 416
	@$$(call E, failing: no device for $$< )
	false
417 418
endef

H
Heather 已提交
419 420
$(foreach host,$(CFG_HOST), \
 $(foreach target,$(CFG_TARGET), \
421 422
  $(foreach stage,$(STAGES), \
   $(foreach crate, $(TEST_CRATES), \
H
Heather 已提交
423
    $(if $(findstring $(target),$(CFG_BUILD)), \
424 425
     $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
     $(if $(findstring $(target),"arm-linux-androideabi"), \
426
      $(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
427 428 429
       $(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
       $(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
      ), \
430
      $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \
D
Daniel Micay 已提交
431
     ))))))
432

433 434 435 436 437 438 439 440 441 442 443 444
######################################################################
# Rules for the compiletest tests (rpass, rfail, etc.)
######################################################################

RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
445
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
446
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
B
Brian Anderson 已提交
447
DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
448 449
CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
450

451 452
# perf tests are the same as bench tests only they run under
# a performance monitor.
453
PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
454

455 456 457 458 459 460 461
RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
BENCH_TESTS := $(BENCH_RS)
PERF_TESTS := $(PERF_RS)
PRETTY_TESTS := $(PRETTY_RS)
B
Brian Leibig 已提交
462
DEBUGINFO_TESTS := $(DEBUGINFO_RS)
463
CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
B
Brian Anderson 已提交
464

465 466 467 468
CTEST_SRC_BASE_rpass = run-pass
CTEST_BUILD_BASE_rpass = run-pass
CTEST_MODE_rpass = run-pass
CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
B
Brian Anderson 已提交
469

470 471
CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps
472 473 474 475 476 477 478 479 480 481 482 483 484
CTEST_MODE_rpass-full = run-pass
CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)

CTEST_SRC_BASE_rfail = run-fail
CTEST_BUILD_BASE_rfail = run-fail
CTEST_MODE_rfail = run-fail
CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)

CTEST_SRC_BASE_cfail = compile-fail
CTEST_BUILD_BASE_cfail = compile-fail
CTEST_MODE_cfail = compile-fail
CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)

485
CTEST_SRC_BASE_bench = bench
486 487 488 489 490 491 492 493 494
CTEST_BUILD_BASE_bench = bench
CTEST_MODE_bench = run-pass
CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)

CTEST_SRC_BASE_perf = bench
CTEST_BUILD_BASE_perf = perf
CTEST_MODE_perf = run-pass
CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)

B
Brian Leibig 已提交
495 496 497 498 499
CTEST_SRC_BASE_debuginfo = debug-info
CTEST_BUILD_BASE_debuginfo = debug-info
CTEST_MODE_debuginfo = debug-info
CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)

500 501 502 503 504
CTEST_SRC_BASE_codegen = codegen
CTEST_BUILD_BASE_codegen = codegen
CTEST_MODE_codegen = codegen
CTEST_RUNTOOL_codegen = $(CTEST_RUNTOOL)

505 506 507 508
ifeq ($(CFG_GDB),)
CTEST_DISABLE_debuginfo = "no gdb found"
endif

509 510 511 512
ifeq ($(CFG_CLANG),)
CTEST_DISABLE_codegen = "no clang found"
endif

513 514 515 516
ifeq ($(CFG_OSTYPE),apple-darwin)
CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
endif

517 518 519 520 521 522 523 524 525 526 527
define DEF_CTEST_VARS

# All the per-stage build rules you might want to call from the
# command line.
#
# $(1) is the stage number
# $(2) is the target triple to test
# $(3) is the host triple to test

# Prerequisites for compiletest tests
TEST_SREQ$(1)_T_$(2)_H_$(3) = \
528
	$$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
529
	$$(SREQ$(1)_T_$(2)_H_$(3))
B
Brian Anderson 已提交
530

B
Brian Anderson 已提交
531
# Rules for the cfail/rfail/rpass/bench/perf test runner
532

533 534
# The tests select when to use debug configuration on their own;
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
535
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
536

537 538
# There's no need our entire test suite to take up gigabytes of space on disk
# including copies of libstd/libextra all over the place
539
CTEST_RUSTC_FLAGS := $$(CTEST_RUSTC_FLAGS) -C prefer-dynamic
540

541 542 543 544 545 546 547
# The tests can not be optimized while the rest of the compiler is optimized, so
# filter out the optimization (if any) from rustc and then figure out if we need
# to be optimized
CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
ifndef CFG_DISABLE_OPTIMIZE_TESTS
CTEST_RUSTC_FLAGS += -O
endif
548

N
Niko Matsakis 已提交
549
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) :=						\
N
Niko Matsakis 已提交
550 551
		--compile-lib-path $$(HLIB$(1)_H_$(3))				\
        --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3))			\
552
        --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))			\
553
        --clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
H
Heather 已提交
554
        --llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
555
        --aux-base $$(S)src/test/auxiliary/                 \
N
Niko Matsakis 已提交
556
        --stage-id stage$(1)-$(2)							\
557
        --target $(2)                                       \
558
        --host $(3)                                       \
559
        --adb-path=$(CFG_ADB)                          \
560
        --adb-test-dir=$(CFG_ADB_TEST_DIR)                  \
L
Luqman Aden 已提交
561 562
        --host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
        --target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
N
Niko Matsakis 已提交
563 564
        $$(CTEST_TESTARGS)

565 566 567 568 569 570
CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
B
Brian Leibig 已提交
571
CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
572
CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
N
Niko Matsakis 已提交
573

574
endef
N
Niko Matsakis 已提交
575

H
Heather 已提交
576 577
$(foreach host,$(CFG_HOST), \
 $(eval $(foreach target,$(CFG_TARGET), \
578 579
  $(eval $(foreach stage,$(STAGES), \
   $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
N
Niko Matsakis 已提交
580

581
define DEF_RUN_COMPILETEST
582

583 584
CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
        $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3))	\
585
        --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
586
        --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
587
        --ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
588 589
        --mode $$(CTEST_MODE_$(4)) \
	$$(CTEST_RUNTOOL_$(4))
N
Niko Matsakis 已提交
590

591 592
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

593 594
ifeq ($$(CTEST_DISABLE_$(4)),)

595
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
596 597
		$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
                $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
598
	@$$(call E, run $(4) [$(2)]: $$<)
599
	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
600
		$$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
601 602
		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
                && touch $$@
N
Niko Matsakis 已提交
603

604 605 606 607 608
else

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
		$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
                $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
609
	@$$(call E, run $(4) [$(2)]: $$<)
610 611 612 613 614
	@$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
	touch $$@

endif

615
endef
N
Niko Matsakis 已提交
616

617
CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo codegen
618

H
Heather 已提交
619 620
$(foreach host,$(CFG_HOST), \
 $(eval $(foreach target,$(CFG_TARGET), \
621 622 623 624 625 626 627 628 629 630 631
  $(eval $(foreach stage,$(STAGES), \
   $(eval $(foreach name,$(CTEST_NAMES), \
   $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))

PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
PRETTY_DIRNAME_pretty-rpass = run-pass
632
PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
633 634 635 636 637 638 639
PRETTY_DIRNAME_pretty-rfail = run-fail
PRETTY_DIRNAME_pretty-bench = bench
PRETTY_DIRNAME_pretty-pretty = pretty

define DEF_RUN_PRETTY_TEST

PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) :=			\
N
Niko Matsakis 已提交
640
		$$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3))	\
641 642
        --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
        --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
N
Niko Matsakis 已提交
643 644
        --mode pretty

645 646 647
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))

$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
648 649
	        $$(TEST_SREQ$(1)_T_$(2)_H_$(3))		\
	        $$(PRETTY_DEPS_$(4))
650
	@$$(call E, run pretty-rpass [$(2)]: $$<)
651
	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
652
		$$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
653 654
		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
                && touch $$@
N
Niko Matsakis 已提交
655

656
endef
N
Niko Matsakis 已提交
657

H
Heather 已提交
658 659
$(foreach host,$(CFG_HOST), \
 $(foreach target,$(CFG_TARGET), \
660 661 662
  $(foreach stage,$(STAGES), \
   $(foreach pretty-name,$(PRETTY_NAMES), \
    $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
B
Brian Anderson 已提交
663

664
define DEF_RUN_DOC_TEST
665

666
DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4) := \
667 668 669
        $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3))	\
        --src-base $(3)/test/doc-$(4)/	\
        --build-base $(3)/test/doc-$(4)/	\
670 671
        --mode run-pass

672
check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
673

674
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
675 676
	        $$(TEST_SREQ$(1)_T_$(2)_H_$(3))		\
                doc-$(4)-extract$(3)
677
	@$$(call E, run doc-$(4) [$(2)]: $$<)
678
	$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
679
                $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
680 681
		--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \
                && touch $$@
682

683
endef
684

H
Heather 已提交
685 686
$(foreach host,$(CFG_HOST), \
 $(foreach target,$(CFG_TARGET), \
687 688 689
  $(foreach stage,$(STAGES), \
   $(foreach docname,$(DOC_TEST_NAMES), \
    $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
690

691 692
define DEF_CRATE_DOC_TEST

693 694 695 696 697 698 699 700 701 702 703 704
# If NO_REBUILD is set then break the dependencies on everything but
# the source files so we can test crate documentation without
# rebuilding any of the parent crates.
ifeq ($(NO_REBUILD),)
DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
	$$(TEST_SREQ$(1)_T_$(2)_H_$(3))				\
	$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))		\
	$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
else
DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
endif

705
check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
706

707
ifeq ($(2),$$(CFG_BUILD))
708
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
709 710
	@$$(call E, run doc-$(4) [$(2)])
	$$(Q)$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) --test \
711
	    $$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@
712 713 714 715
else
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)):
	touch $$@
endif
716 717 718 719

endef

$(foreach host,$(CFG_HOST), \
720 721 722 723
 $(foreach target,$(CFG_TARGET), \
  $(foreach stage,$(STAGES), \
   $(foreach crate,$(TEST_DOC_CRATES), \
    $(eval $(call DEF_CRATE_DOC_TEST,$(stage),$(target),$(host),$(crate)))))))
724

725 726 727
######################################################################
# Extracting tests for docs
######################################################################
B
Brian Anderson 已提交
728

729
EXTRACT_TESTS := "$(CFG_PYTHON)" $(S)src/etc/extract-tests.py
B
Brian Anderson 已提交
730

731
define DEF_DOC_TEST_HOST
732

733 734 735
doc-$(2)-extract$(1):
	@$$(call E, extract: $(2) tests)
	$$(Q)rm -f $(1)/test/doc-$(2)/*.rs
736
	$$(Q)$$(EXTRACT_TESTS) $$(D)/$(2).md $(1)/test/doc-$(2)
737

738
endef
739

H
Heather 已提交
740
$(foreach host,$(CFG_HOST), \
741 742
 $(foreach docname,$(DOC_TEST_NAMES), \
  $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
743

744

745 746 747
######################################################################
# Shortcut rules
######################################################################
748

749 750 751
TEST_GROUPS = \
	crates \
	$(foreach crate,$(TEST_CRATES),$(crate)) \
752
	$(foreach crate,$(TEST_DOC_CRATES),doc-$(crate)) \
753 754 755 756 757 758
	rpass \
	rpass-full \
	rfail \
	cfail \
	bench \
	perf \
A
Alex Crichton 已提交
759
	rmake \
B
Brian Leibig 已提交
760
	debuginfo \
761
	codegen \
762
	doc \
763
	$(foreach docname,$(DOC_TEST_NAMES),doc-$(docname)) \
764 765 766 767 768 769 770 771 772 773 774
	pretty \
	pretty-rpass \
	pretty-rpass-full \
	pretty-rfail \
	pretty-bench \
	pretty-pretty \
	$(NULL)

define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
endef
775

776
$(foreach stage,$(STAGES), \
H
Heather 已提交
777 778
 $(foreach target,$(CFG_TARGET), \
  $(foreach host,$(CFG_HOST), \
779
   $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
780

781 782 783
define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
endef
B
Brian Anderson 已提交
784

785
$(foreach stage,$(STAGES), \
H
Heather 已提交
786 787
 $(foreach target,$(CFG_TARGET), \
  $(foreach host,$(CFG_HOST), \
788 789
   $(foreach group,$(TEST_GROUPS), \
    $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
790

791
define DEF_CHECK_FOR_STAGE
H
Heather 已提交
792 793
check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD)
check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET), \
794 795
                           check-stage$(1)-H-$$(target))
endef
796

797 798
$(foreach stage,$(STAGES), \
 $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
799

800
define DEF_CHECK_FOR_STAGE_AND_GROUP
H
Heather 已提交
801 802
check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD)-$(2)
check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET), \
803 804
                               check-stage$(1)-H-$$(target)-$(2))
endef
805

806 807 808
$(foreach stage,$(STAGES), \
 $(foreach group,$(TEST_GROUPS), \
  $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
809

810 811

define DEF_CHECK_FOR_STAGE_AND_HOSTS
H
Heather 已提交
812
check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET), \
813
                           check-stage$(1)-T-$$(target)-H-$(2))
B
Brian Anderson 已提交
814
endef
815

816
$(foreach stage,$(STAGES), \
H
Heather 已提交
817
 $(foreach host,$(CFG_HOST), \
818 819 820
  $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))

define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
H
Heather 已提交
821
check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET), \
822 823 824 825
                                check-stage$(1)-T-$$(target)-H-$(2)-$(3))
endef

$(foreach stage,$(STAGES), \
H
Heather 已提交
826
 $(foreach host,$(CFG_HOST), \
827 828
  $(foreach group,$(TEST_GROUPS), \
   $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
829

N
Niko Matsakis 已提交
830
######################################################################
831
# check-fast rules
N
Niko Matsakis 已提交
832
######################################################################
833

834
FT := run_pass_stage2
H
Heather 已提交
835
FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD),$(FT))
836 837
FT_DRIVER := $(FT)_driver

838
GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
N
Niko Matsakis 已提交
839

N
Niko Matsakis 已提交
840
tmp/$(FT).rc tmp/$(FT_DRIVER).rs: \
841
		$(RPASS_TESTS) \
N
Niko Matsakis 已提交
842 843
		$(S)src/etc/combine-tests.py
	@$(call E, check: building combined stage2 test runner)
844
	$(Q)$(CFG_PYTHON) $(S)src/etc/combine-tests.py
N
Niko Matsakis 已提交
845 846 847 848 849 850 851 852 853

define DEF_CHECK_FAST_FOR_T_H
# $(1) unused
# $(2) target triple
# $(3) host triple

$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
		tmp/$$(FT).rc \
		$$(SREQ2_T_$(2)_H_$(3))
854
	@$$(call E, oxidize: $$@)
A
Alex Crichton 已提交
855
	$$(STAGE2_T_$(2)_H_$(3)) --crate-type=dylib --out-dir $$(@D) $$< \
A
Alex Crichton 已提交
856
	  -L "$$(RT_OUTPUT_DIR_$(2))"
N
Niko Matsakis 已提交
857

858
$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
N
Niko Matsakis 已提交
859 860 861
		tmp/$$(FT_DRIVER).rs \
		$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
		$$(SREQ2_T_$(2)_H_$(3))
862
	@$$(call E, oxidize: $$@ $$<)
A
Alex Crichton 已提交
863 864
	$$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$< \
	  -L "$$(RT_OUTPUT_DIR_$(2))"
N
Niko Matsakis 已提交
865

N
Niko Matsakis 已提交
866
$(3)/test/$$(FT_DRIVER)-$(2).out: \
867
		$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)) \
N
Niko Matsakis 已提交
868
		$$(SREQ2_T_$(2)_H_$(3))
869
	$$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) \
870
	--logfile tmp/$$(FT_DRIVER)-$(2).log
N
Niko Matsakis 已提交
871

872
check-fast-T-$(2)-H-$(3):     			\
N
Niko Matsakis 已提交
873
	$(3)/test/$$(FT_DRIVER)-$(2).out
N
Niko Matsakis 已提交
874 875 876

endef

H
Heather 已提交
877 878
$(foreach host,$(CFG_HOST), \
 $(eval $(foreach target,$(CFG_TARGET), \
N
Niko Matsakis 已提交
879 880
   $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))

881 882
check-fast: tidy check-fast-H-$(CFG_BUILD) \
	    $(foreach crate,$(TARGET_CRATES),check-stage2-$(crate))
883
	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
N
Niko Matsakis 已提交
884 885 886 887 888 889

define DEF_CHECK_FAST_FOR_H

check-fast-H-$(1): 		check-fast-T-$(1)-H-$(1)

endef
N
Niko Matsakis 已提交
890

H
Heather 已提交
891
$(foreach host,$(CFG_HOST),			\
892
 $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))
A
Alex Crichton 已提交
893 894 895 896 897 898 899 900 901

RMAKE_TESTS := $(shell ls -d $(S)src/test/run-make/*/)
RMAKE_TESTS := $(RMAKE_TESTS:$(S)src/test/run-make/%/=%)

define DEF_RMAKE_FOR_T_H
# $(1) the stage
# $(2) target triple
# $(3) host triple

902 903

ifeq ($(2)$(3),$$(CFG_BUILD)$$(CFG_BUILD))
A
Alex Crichton 已提交
904 905 906 907 908 909 910 911 912
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec: \
		$$(call TEST_OK_FILE,$(1),$(2),$(3),rmake)

$$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
		$$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
	@touch $$@

$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
		$(S)src/test/run-make/%/Makefile \
C
Corey Richardson 已提交
913
		$$(CSREQ$(1)_T_$(2)_H_$(3))
A
Alex Crichton 已提交
914 915
	@rm -rf $(3)/test/run-make/$$*
	@mkdir -p $(3)/test/run-make/$$*
916
	$$(Q)$$(CFG_PYTHON) $(S)src/etc/maketest.py $$(dir $$<) \
A
Alex Crichton 已提交
917
	    $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
A
Alex Crichton 已提交
918
	    $(3)/test/run-make/$$* \
C
Corey Richardson 已提交
919
	    "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" \
920 921
	    $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
	    "$$(TESTNAME)"
A
Alex Crichton 已提交
922
	@touch $$@
923 924 925 926 927 928 929
else
# FIXME #11094 - The above rule doesn't work right for multiple targets
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec:
	@true

endif

A
Alex Crichton 已提交
930 931 932 933 934 935 936

endef

$(foreach stage,$(STAGES), \
 $(foreach target,$(CFG_TARGET), \
  $(foreach host,$(CFG_HOST), \
   $(eval $(call DEF_RMAKE_FOR_T_H,$(stage),$(target),$(host))))))