PageRenderTime 50ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/mk/tests.mk

https://github.com/pnkfelix/rust
Makefile | 704 lines | 491 code | 150 blank | 63 comment | 4 complexity | 99b5b0d2438a2b7559f980997867de86 MD5 | raw file
Possible License(s): MIT, JSON, Apache-2.0
  1. # Copyright 2012 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. # Test variables
  12. ######################################################################
  13. # The names of crates that must be tested
  14. TEST_TARGET_CRATES = core std
  15. TEST_HOST_CRATES = syntax rustc rustdoc rusti rust rustpkg
  16. TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
  17. # Markdown files under doc/ that should have their code extracted and run
  18. DOC_TEST_NAMES = tutorial tutorial-ffi tutorial-macros tutorial-borrowed-ptr tutorial-tasks rust
  19. ######################################################################
  20. # Environment configuration
  21. ######################################################################
  22. # The arguments to all test runners
  23. ifdef TESTNAME
  24. TESTARGS += $(TESTNAME)
  25. endif
  26. ifdef CHECK_XFAILS
  27. TESTARGS += --ignored
  28. endif
  29. # Arguments to the cfail/rfail/rpass/bench tests
  30. ifdef CFG_VALGRIND
  31. CTEST_RUNTOOL = --runtool "$(CFG_VALGRIND)"
  32. endif
  33. # Arguments to the perf tests
  34. ifdef CFG_PERF_TOOL
  35. CTEST_PERF_RUNTOOL = --runtool "$(CFG_PERF_TOOL)"
  36. endif
  37. CTEST_TESTARGS := $(TESTARGS)
  38. ifdef VERBOSE
  39. CTEST_TESTARGS += --verbose
  40. endif
  41. # If we're running perf then set this environment variable
  42. # to put the benchmarks into 'hard mode'
  43. ifeq ($(MAKECMDGOALS),perf)
  44. RUST_BENCH=1
  45. export RUST_BENCH
  46. endif
  47. TEST_LOG_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
  48. TEST_OK_FILE=tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).ok
  49. define DEF_TARGET_COMMANDS
  50. ifdef CFG_UNIXY_$(1)
  51. CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),,$$(CFG_VALGRIND) $$(1))
  52. endif
  53. ifdef CFG_WINDOWSY_$(1)
  54. CFG_TESTLIB_$(1)=$$(CFG_BUILD_DIR)/$$(2)/$$(strip \
  55. $$(if $$(findstring stage0,$$(1)), \
  56. stage0/$$(CFG_LIBDIR), \
  57. $$(if $$(findstring stage1,$$(1)), \
  58. stage1/$$(CFG_LIBDIR), \
  59. $$(if $$(findstring stage2,$$(1)), \
  60. stage2/$$(CFG_LIBDIR), \
  61. $$(if $$(findstring stage3,$$(1)), \
  62. stage3/$$(CFG_LIBDIR), \
  63. )))))/rustc/$$(CFG_BUILD_TRIPLE)/$$(CFG_LIBDIR)
  64. CFG_RUN_TEST_$(1)=$$(call CFG_RUN_$(1),$$(call CFG_TESTLIB_$(1),$$(1),$$(3)),$$(1))
  65. endif
  66. # Run the compiletest runner itself under valgrind
  67. ifdef CTEST_VALGRIND
  68. CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD_TRIPLE),$$(2),$$(3))
  69. else
  70. CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD_TRIPLE),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2))
  71. endif
  72. endef
  73. $(foreach target,$(CFG_TARGET_TRIPLES), \
  74. $(eval $(call DEF_TARGET_COMMANDS,$(target))))
  75. ######################################################################
  76. # Main test targets
  77. ######################################################################
  78. check: cleantestlibs cleantmptestlogs tidy all check-stage2
  79. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  80. check-notidy: cleantestlibs cleantmptestlogs all check-stage2
  81. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  82. check-full: cleantestlibs cleantmptestlogs tidy \
  83. all check-stage1 check-stage2 check-stage3
  84. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  85. check-test: cleantestlibs cleantmptestlogs all check-stage2-rfail
  86. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  87. check-lite: cleantestlibs cleantmptestlogs \
  88. check-stage2-core check-stage2-std check-stage2-rpass \
  89. check-stage2-rfail check-stage2-cfail
  90. $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
  91. .PHONY: cleantmptestlogs cleantestlibs
  92. cleantmptestlogs:
  93. $(Q)rm -f tmp/*.log
  94. cleantestlibs:
  95. $(Q)find $(CFG_BUILD_TRIPLE)/test \
  96. -name '*.[odasS]' -o \
  97. -name '*.so' -o \
  98. -name '*.dylib' -o \
  99. -name '*.dll' -o \
  100. -name '*.def' -o \
  101. -name '*.bc' -o \
  102. -name '*.dSYM' -o \
  103. -name '*.libaux' -o \
  104. -name '*.out' -o \
  105. -name '*.err' -o \
  106. -name '*.debugger.script' \
  107. | xargs rm -rf
  108. ######################################################################
  109. # Tidy
  110. ######################################################################
  111. ifdef CFG_NOTIDY
  112. tidy:
  113. else
  114. ALL_CS := $(wildcard $(S)src/rt/*.cpp \
  115. $(S)src/rt/*/*.cpp \
  116. $(S)src/rt/*/*/*.cpp \
  117. $(S)srcrustllvm/*.cpp)
  118. ALL_CS := $(filter-out $(S)src/rt/bigint/bigint_ext.cpp \
  119. $(S)src/rt/bigint/bigint_int.cpp \
  120. $(S)src/rt/miniz.cpp \
  121. $(S)src/rt/linenoise/linenoise.c \
  122. $(S)src/rt/linenoise/utf8.c \
  123. ,$(ALL_CS))
  124. ALL_HS := $(wildcard $(S)src/rt/*.h \
  125. $(S)src/rt/*/*.h \
  126. $(S)src/rt/*/*/*.h \
  127. $(S)srcrustllvm/*.h)
  128. ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
  129. $(S)src/rt/vg/memcheck.h \
  130. $(S)src/rt/uthash/uthash.h \
  131. $(S)src/rt/uthash/utlist.h \
  132. $(S)src/rt/msvc/typeof.h \
  133. $(S)src/rt/msvc/stdint.h \
  134. $(S)src/rt/msvc/inttypes.h \
  135. $(S)src/rt/bigint/bigint.h \
  136. $(S)src/rt/linenoise/linenoise.h \
  137. $(S)src/rt/linenoise/utf8.h \
  138. ,$(ALL_HS))
  139. # Run the tidy script in multiple parts to avoid huge 'echo' commands
  140. tidy:
  141. @$(call E, check: formatting)
  142. $(Q)find $(S)src -name '*.r[sc]' \
  143. | grep '^$(S)src/test' -v \
  144. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  145. $(Q)find $(S)src/etc -name '*.py' \
  146. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  147. $(Q)echo $(ALL_CS) \
  148. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  149. $(Q)echo $(ALL_HS) \
  150. | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
  151. endif
  152. ######################################################################
  153. # Sets of tests
  154. ######################################################################
  155. define DEF_TEST_SETS
  156. check-stage$(1)-T-$(2)-H-$(3)-exec: \
  157. check-stage$(1)-T-$(2)-H-$(3)-rpass-exec \
  158. check-stage$(1)-T-$(2)-H-$(3)-rfail-exec \
  159. check-stage$(1)-T-$(2)-H-$(3)-cfail-exec \
  160. check-stage$(1)-T-$(2)-H-$(3)-rpass-full-exec \
  161. check-stage$(1)-T-$(2)-H-$(3)-crates-exec \
  162. check-stage$(1)-T-$(2)-H-$(3)-bench-exec \
  163. check-stage$(1)-T-$(2)-H-$(3)-debuginfo-exec \
  164. check-stage$(1)-T-$(2)-H-$(3)-doc-exec \
  165. check-stage$(1)-T-$(2)-H-$(3)-pretty-exec
  166. # Only test the compiler-dependent crates when the target is
  167. # able to build a compiler (when the target triple is in the set of host triples)
  168. ifneq ($$(findstring $(2),$$(CFG_HOST_TRIPLES)),)
  169. check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
  170. $$(foreach crate,$$(TEST_CRATES), \
  171. check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
  172. else
  173. check-stage$(1)-T-$(2)-H-$(3)-crates-exec: \
  174. $$(foreach crate,$$(TEST_TARGET_CRATES), \
  175. check-stage$(1)-T-$(2)-H-$(3)-$$(crate)-exec)
  176. endif
  177. check-stage$(1)-T-$(2)-H-$(3)-doc-exec: \
  178. $$(foreach docname,$$(DOC_TEST_NAMES), \
  179. check-stage$(1)-T-$(2)-H-$(3)-doc-$$(docname)-exec)
  180. check-stage$(1)-T-$(2)-H-$(3)-pretty-exec: \
  181. check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-exec \
  182. check-stage$(1)-T-$(2)-H-$(3)-pretty-rpass-full-exec \
  183. check-stage$(1)-T-$(2)-H-$(3)-pretty-rfail-exec \
  184. check-stage$(1)-T-$(2)-H-$(3)-pretty-bench-exec \
  185. check-stage$(1)-T-$(2)-H-$(3)-pretty-pretty-exec
  186. endef
  187. $(foreach host,$(CFG_HOST_TRIPLES), \
  188. $(foreach target,$(CFG_TARGET_TRIPLES), \
  189. $(foreach stage,$(STAGES), \
  190. $(eval $(call DEF_TEST_SETS,$(stage),$(target),$(host))))))
  191. ######################################################################
  192. # Crate testing
  193. ######################################################################
  194. define TEST_RUNNER
  195. $(3)/test/coretest.stage$(1)-$(2)$$(X_$(2)): \
  196. $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
  197. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
  198. @$$(call E, compile_and_link: $$@)
  199. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  200. $(3)/test/stdtest.stage$(1)-$(2)$$(X_$(2)): \
  201. $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
  202. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
  203. @$$(call E, compile_and_link: $$@)
  204. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  205. $(3)/test/syntaxtest.stage$(1)-$(2)$$(X_$(2)): \
  206. $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
  207. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
  208. @$$(call E, compile_and_link: $$@)
  209. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  210. $(3)/test/rustctest.stage$(1)-$(2)$$(X_$(2)): \
  211. $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
  212. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \
  213. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2))
  214. @$$(call E, compile_and_link: $$@)
  215. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  216. $(3)/test/rustpkgtest.stage$(1)-$(2)$$(X_$(2)): \
  217. $$(RUSTPKG_LIB) $$(RUSTPKG_INPUTS) \
  218. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  219. @$$(call E, compile_and_link: $$@)
  220. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  221. $(3)/test/rustitest.stage$(1)-$(2)$$(X_$(2)): \
  222. $$(RUSTI_LIB) $$(RUSTI_INPUTS) \
  223. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  224. @$$(call E, compile_and_link: $$@)
  225. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  226. $(3)/test/rusttest.stage$(1)-$(2)$$(X_$(2)): \
  227. $$(RUST_LIB) $$(RUST_INPUTS) \
  228. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  229. @$$(call E, compile_and_link: $$@)
  230. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  231. $(3)/test/rustdoctest.stage$(1)-$(2)$$(X_$(2)): \
  232. $$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
  233. $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
  234. @$$(call E, compile_and_link: $$@)
  235. $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
  236. endef
  237. $(foreach host,$(CFG_HOST_TRIPLES), \
  238. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  239. $(eval $(foreach stage,$(STAGES), \
  240. $(eval $(call TEST_RUNNER,$(stage),$(target),$(host))))))))
  241. define DEF_TEST_CRATE_RULES
  242. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  243. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  244. $(3)/test/$(4)test.stage$(1)-$(2)$$(X_$(2))
  245. @$$(call E, run: $$<)
  246. $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
  247. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  248. && touch $$@
  249. endef
  250. $(foreach host,$(CFG_HOST_TRIPLES), \
  251. $(foreach target,$(CFG_TARGET_TRIPLES), \
  252. $(foreach stage,$(STAGES), \
  253. $(foreach crate, $(TEST_CRATES), \
  254. $(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate)))))))
  255. ######################################################################
  256. # Rules for the compiletest tests (rpass, rfail, etc.)
  257. ######################################################################
  258. RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
  259. RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
  260. RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
  261. RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
  262. RFAIL_RC := $(wildcard $(S)src/test/run-fail/*.rc)
  263. RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
  264. CFAIL_RC := $(wildcard $(S)src/test/compile-fail/*.rc)
  265. CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
  266. BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
  267. PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
  268. DEBUGINFO_RS := $(wildcard $(S)src/test/debug-info/*.rs)
  269. # perf tests are the same as bench tests only they run under
  270. # a performance monitor.
  271. PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
  272. RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
  273. RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
  274. RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
  275. CFAIL_TESTS := $(CFAIL_RC) $(CFAIL_RS)
  276. BENCH_TESTS := $(BENCH_RS)
  277. PERF_TESTS := $(PERF_RS)
  278. PRETTY_TESTS := $(PRETTY_RS)
  279. DEBUGINFO_TESTS := $(DEBUGINFO_RS)
  280. CTEST_SRC_BASE_rpass = run-pass
  281. CTEST_BUILD_BASE_rpass = run-pass
  282. CTEST_MODE_rpass = run-pass
  283. CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
  284. CTEST_SRC_BASE_rpass-full = run-pass-full
  285. CTEST_BUILD_BASE_rpass-full = run-pass-full
  286. CTEST_MODE_rpass-full = run-pass
  287. CTEST_RUNTOOL_rpass-full = $(CTEST_RUNTOOL)
  288. CTEST_SRC_BASE_rfail = run-fail
  289. CTEST_BUILD_BASE_rfail = run-fail
  290. CTEST_MODE_rfail = run-fail
  291. CTEST_RUNTOOL_rfail = $(CTEST_RUNTOOL)
  292. CTEST_SRC_BASE_cfail = compile-fail
  293. CTEST_BUILD_BASE_cfail = compile-fail
  294. CTEST_MODE_cfail = compile-fail
  295. CTEST_RUNTOOL_cfail = $(CTEST_RUNTOOL)
  296. CTEST_SRC_BASE_bench = bench
  297. CTEST_BUILD_BASE_bench = bench
  298. CTEST_MODE_bench = run-pass
  299. CTEST_RUNTOOL_bench = $(CTEST_RUNTOOL)
  300. CTEST_SRC_BASE_perf = bench
  301. CTEST_BUILD_BASE_perf = perf
  302. CTEST_MODE_perf = run-pass
  303. CTEST_RUNTOOL_perf = $(CTEST_PERF_RUNTOOL)
  304. CTEST_SRC_BASE_debuginfo = debug-info
  305. CTEST_BUILD_BASE_debuginfo = debug-info
  306. CTEST_MODE_debuginfo = debug-info
  307. CTEST_RUNTOOL_debuginfo = $(CTEST_RUNTOOL)
  308. ifeq ($(CFG_GDB),)
  309. CTEST_DISABLE_debuginfo = "no gdb found"
  310. endif
  311. ifeq ($(CFG_OSTYPE),apple-darwin)
  312. CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
  313. endif
  314. define DEF_CTEST_VARS
  315. # All the per-stage build rules you might want to call from the
  316. # command line.
  317. #
  318. # $(1) is the stage number
  319. # $(2) is the target triple to test
  320. # $(3) is the host triple to test
  321. # Prerequisites for compiletest tests
  322. TEST_SREQ$(1)_T_$(2)_H_$(3) = \
  323. $$(HBIN$(1)_H_$(3))/compiletest$$(X_$(3)) \
  324. $$(SREQ$(1)_T_$(2)_H_$(3))
  325. # Rules for the cfail/rfail/rpass/bench/perf test runner
  326. CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
  327. --compile-lib-path $$(HLIB$(1)_H_$(3)) \
  328. --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
  329. --rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
  330. --aux-base $$(S)src/test/auxiliary/ \
  331. --stage-id stage$(1)-$(2) \
  332. --rustcflags "$(RUSTC_FLAGS_$(2)) $$(CFG_RUSTC_FLAGS) --target=$(2)" \
  333. $$(CTEST_TESTARGS)
  334. CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
  335. CTEST_DEPS_rpass_full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
  336. CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
  337. CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
  338. CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
  339. CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
  340. CTEST_DEPS_debuginfo_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_TESTS)
  341. endef
  342. $(foreach host,$(CFG_HOST_TRIPLES), \
  343. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  344. $(eval $(foreach stage,$(STAGES), \
  345. $(eval $(call DEF_CTEST_VARS,$(stage),$(target),$(host))))))))
  346. define DEF_RUN_COMPILETEST
  347. CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
  348. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  349. --src-base $$(S)src/test/$$(CTEST_SRC_BASE_$(4))/ \
  350. --build-base $(3)/test/$$(CTEST_BUILD_BASE_$(4))/ \
  351. --mode $$(CTEST_MODE_$(4)) \
  352. $$(CTEST_RUNTOOL_$(4))
  353. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  354. ifeq ($$(CTEST_DISABLE_$(4)),)
  355. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  356. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  357. $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
  358. @$$(call E, run $(4): $$<)
  359. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  360. $$(CTEST_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
  361. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  362. && touch $$@
  363. else
  364. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  365. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  366. $$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
  367. @$$(call E, run $(4): $$<)
  368. @$$(call E, warning: tests disabled: $$(CTEST_DISABLE_$(4)))
  369. touch $$@
  370. endif
  371. endef
  372. CTEST_NAMES = rpass rpass-full rfail cfail bench perf debuginfo
  373. $(foreach host,$(CFG_HOST_TRIPLES), \
  374. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  375. $(eval $(foreach stage,$(STAGES), \
  376. $(eval $(foreach name,$(CTEST_NAMES), \
  377. $(eval $(call DEF_RUN_COMPILETEST,$(stage),$(target),$(host),$(name))))))))))
  378. PRETTY_NAMES = pretty-rpass pretty-rpass-full pretty-rfail pretty-bench pretty-pretty
  379. PRETTY_DEPS_pretty-rpass = $(RPASS_TESTS)
  380. PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
  381. PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
  382. PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
  383. PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
  384. PRETTY_DIRNAME_pretty-rpass = run-pass
  385. PRETTY_DIRNAME_pretty-rpass-full = run-pass-full
  386. PRETTY_DIRNAME_pretty-rfail = run-fail
  387. PRETTY_DIRNAME_pretty-bench = bench
  388. PRETTY_DIRNAME_pretty-pretty = pretty
  389. define DEF_RUN_PRETTY_TEST
  390. PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4) := \
  391. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  392. --src-base $$(S)src/test/$$(PRETTY_DIRNAME_$(4))/ \
  393. --build-base $(3)/test/$$(PRETTY_DIRNAME_$(4))/ \
  394. --mode pretty
  395. check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
  396. $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
  397. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  398. $$(PRETTY_DEPS_$(4))
  399. @$$(call E, run pretty-rpass: $$<)
  400. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  401. $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
  402. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
  403. && touch $$@
  404. endef
  405. $(foreach host,$(CFG_HOST_TRIPLES), \
  406. $(foreach target,$(CFG_TARGET_TRIPLES), \
  407. $(foreach stage,$(STAGES), \
  408. $(foreach pretty-name,$(PRETTY_NAMES), \
  409. $(eval $(call DEF_RUN_PRETTY_TEST,$(stage),$(target),$(host),$(pretty-name)))))))
  410. define DEF_RUN_DOC_TEST
  411. DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4) := \
  412. $$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
  413. --src-base $(3)/test/doc-$(4)/ \
  414. --build-base $(3)/test/doc-$(4)/ \
  415. --mode run-pass
  416. check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
  417. $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
  418. $$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
  419. doc-$(4)-extract$(3)
  420. @$$(call E, run doc-$(4): $$<)
  421. $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
  422. $$(DOC_TEST_ARGS$(1)-T-$(2)-H-$(3)-doc-$(4)) \
  423. --logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),doc-$(4)) \
  424. && touch $$@
  425. endef
  426. $(foreach host,$(CFG_HOST_TRIPLES), \
  427. $(foreach target,$(CFG_TARGET_TRIPLES), \
  428. $(foreach stage,$(STAGES), \
  429. $(foreach docname,$(DOC_TEST_NAMES), \
  430. $(eval $(call DEF_RUN_DOC_TEST,$(stage),$(target),$(host),$(docname)))))))
  431. ######################################################################
  432. # Extracting tests for docs
  433. ######################################################################
  434. EXTRACT_TESTS := "$(CFG_PYTHON)" $(S)src/etc/extract-tests.py
  435. define DEF_DOC_TEST_HOST
  436. doc-$(2)-extract$(1):
  437. @$$(call E, extract: $(2) tests)
  438. $$(Q)rm -f $(1)/test/doc-$(2)/*.rs
  439. $$(Q)$$(EXTRACT_TESTS) $$(S)doc/$(2).md $(1)/test/doc-$(2)
  440. endef
  441. $(foreach host,$(CFG_HOST_TRIPLES), \
  442. $(foreach docname,$(DOC_TEST_NAMES), \
  443. $(eval $(call DEF_DOC_TEST_HOST,$(host),$(docname)))))
  444. ######################################################################
  445. # Shortcut rules
  446. ######################################################################
  447. TEST_GROUPS = \
  448. crates \
  449. $(foreach crate,$(TEST_CRATES),$(crate)) \
  450. rpass \
  451. rpass-full \
  452. rfail \
  453. cfail \
  454. bench \
  455. perf \
  456. debuginfo \
  457. doc \
  458. $(foreach docname,$(DOC_TEST_NAMES),$(docname)) \
  459. pretty \
  460. pretty-rpass \
  461. pretty-rpass-full \
  462. pretty-rfail \
  463. pretty-bench \
  464. pretty-pretty \
  465. $(NULL)
  466. define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST
  467. check-stage$(1)-T-$(2)-H-$(3): check-stage$(1)-T-$(2)-H-$(3)-exec
  468. endef
  469. $(foreach stage,$(STAGES), \
  470. $(foreach target,$(CFG_TARGET_TRIPLES), \
  471. $(foreach host,$(CFG_HOST_TRIPLES), \
  472. $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST,$(stage),$(target),$(host))))))
  473. define DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP
  474. check-stage$(1)-T-$(2)-H-$(3)-$(4): check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec
  475. endef
  476. $(foreach stage,$(STAGES), \
  477. $(foreach target,$(CFG_TARGET_TRIPLES), \
  478. $(foreach host,$(CFG_HOST_TRIPLES), \
  479. $(foreach group,$(TEST_GROUPS), \
  480. $(eval $(call DEF_CHECK_FOR_STAGE_AND_TARGET_AND_HOST_AND_GROUP,$(stage),$(target),$(host),$(group)))))))
  481. define DEF_CHECK_FOR_STAGE
  482. check-stage$(1): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)
  483. check-stage$(1)-H-all: $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  484. check-stage$(1)-H-$$(target))
  485. endef
  486. $(foreach stage,$(STAGES), \
  487. $(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
  488. define DEF_CHECK_FOR_STAGE_AND_GROUP
  489. check-stage$(1)-$(2): check-stage$(1)-H-$$(CFG_BUILD_TRIPLE)-$(2)
  490. check-stage$(1)-H-all-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  491. check-stage$(1)-H-$$(target)-$(2))
  492. endef
  493. $(foreach stage,$(STAGES), \
  494. $(foreach group,$(TEST_GROUPS), \
  495. $(eval $(call DEF_CHECK_FOR_STAGE_AND_GROUP,$(stage),$(group)))))
  496. define DEF_CHECK_FOR_STAGE_AND_HOSTS
  497. check-stage$(1)-H-$(2): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  498. check-stage$(1)-T-$$(target)-H-$(2))
  499. endef
  500. $(foreach stage,$(STAGES), \
  501. $(foreach host,$(CFG_HOST_TRIPLES), \
  502. $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS,$(stage),$(host)))))
  503. define DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP
  504. check-stage$(1)-H-$(2)-$(3): $$(foreach target,$$(CFG_TARGET_TRIPLES), \
  505. check-stage$(1)-T-$$(target)-H-$(2)-$(3))
  506. endef
  507. $(foreach stage,$(STAGES), \
  508. $(foreach host,$(CFG_HOST_TRIPLES), \
  509. $(foreach group,$(TEST_GROUPS), \
  510. $(eval $(call DEF_CHECK_FOR_STAGE_AND_HOSTS_AND_GROUP,$(stage),$(host),$(group))))))
  511. ######################################################################
  512. # check-fast rules
  513. ######################################################################
  514. FT := run_pass_stage2
  515. FT_LIB := $(call CFG_LIB_NAME_$(CFG_BUILD_TRIPLE),$(FT))
  516. FT_DRIVER := $(FT)_driver
  517. GENERATED += tmp/$(FT).rc tmp/$(FT_DRIVER).rs
  518. tmp/$(FT).rc tmp/$(FT_DRIVER).rs: \
  519. $(RPASS_TESTS) \
  520. $(S)src/etc/combine-tests.py
  521. @$(call E, check: building combined stage2 test runner)
  522. $(Q)$(CFG_PYTHON) $(S)src/etc/combine-tests.py
  523. define DEF_CHECK_FAST_FOR_T_H
  524. # $(1) unused
  525. # $(2) target triple
  526. # $(3) host triple
  527. $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
  528. tmp/$$(FT).rc \
  529. $$(SREQ2_T_$(2)_H_$(3))
  530. @$$(call E, compile_and_link: $$@)
  531. $$(STAGE2_T_$(2)_H_$(3)) --lib -o $$@ $$<
  532. $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
  533. tmp/$$(FT_DRIVER).rs \
  534. $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
  535. $$(SREQ2_T_$(2)_H_$(3))
  536. @$$(call E, compile_and_link: $$@ $$<)
  537. $$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$<
  538. $(3)/test/$$(FT_DRIVER)-$(2).out: \
  539. $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)) \
  540. $$(SREQ2_T_$(2)_H_$(3))
  541. $$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) \
  542. --logfile tmp/$$(FT_DRIVER)-$(2).log
  543. check-fast-T-$(2)-H-$(3): \
  544. $(3)/test/$$(FT_DRIVER)-$(2).out
  545. endef
  546. $(foreach host,$(CFG_HOST_TRIPLES), \
  547. $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
  548. $(eval $(call DEF_CHECK_FAST_FOR_T_H,,$(target),$(host))))))
  549. check-fast: tidy check-fast-H-$(CFG_BUILD_TRIPLE)
  550. define DEF_CHECK_FAST_FOR_H
  551. check-fast-H-$(1): check-fast-T-$(1)-H-$(1)
  552. endef
  553. $(foreach host,$(CFG_HOST_TRIPLES), \
  554. $(eval $(call DEF_CHECK_FAST_FOR_H,$(host))))