From 4e8ab8b3a8fa324754023feeb4406482c4643feb Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 30 Jul 2011 21:44:30 -0700 Subject: [PATCH] Introduce pretty-print testing mode to compiletest. Issue #789 --- mk/tests.mk | 13 +++++++++++++ src/test/compiletest/common.rs | 7 ++++++- src/test/compiletest/compiletest.rs | 9 ++++++++- src/test/compiletest/runtest.rs | 5 +++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 23aac391e860..11101e9c020b 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -142,6 +142,8 @@ check-stage$(2)-rpass: test/run-pass.stage$(2).out \ check-stage$(2)-bench: test/bench.stage$(2).out \ +check-stage$(2)-pretty: test/pretty.stage$(2).out \ + CTEST_COMMON_ARGS$(2) := --compile-lib-path stage$(2) \ --run-lib-path stage$(2)/lib \ --rustc-path stage$(2)/rustc$$(X) \ @@ -172,6 +174,11 @@ BENCH_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ --mode run-pass \ $$(CTEST_RUNTOOL) \ +PRETTY_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ + --src-base $$(S)src/test/run-pass/ \ + --build-base test/run-pass/ \ + --mode pretty \ + test/compiletest.stage$(2)$$(X): $$(COMPILETEST_CRATE) \ $$(COMPILETEST_INPUTS) \ $$(SREQ$(2)) @@ -202,6 +209,12 @@ test/bench.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \ $$(Q)$$(call CFG_RUN_TEST,$$<) $$(BENCH_ARGS$(2)) $$(Q)touch $$@ +test/pretty.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \ + $$(RPASS_TESTS) + @$$(call E, run: $$<) + $$(Q)$$(call CFG_RUN_TEST,$$<) $$(PRETTY_ARGS$(2)) + $$(Q)touch $$@ + endef # Instantiate the template for stage 0, 1, 2, 3 diff --git a/src/test/compiletest/common.rs b/src/test/compiletest/common.rs index d0fe2ebb1cf9..f5a60bd0261b 100644 --- a/src/test/compiletest/common.rs +++ b/src/test/compiletest/common.rs @@ -1,6 +1,11 @@ import std::option; -tag mode { mode_compile_fail; mode_run_fail; mode_run_pass; } +tag mode { + mode_compile_fail; + mode_run_fail; + mode_run_pass; + mode_pretty; +} type config = { // The library paths required for running the compiler diff --git a/src/test/compiletest/compiletest.rs b/src/test/compiletest/compiletest.rs index a96dab380ef5..8e90c921fa65 100644 --- a/src/test/compiletest/compiletest.rs +++ b/src/test/compiletest/compiletest.rs @@ -12,6 +12,7 @@ import common::config; import common::mode_run_pass; import common::mode_run_fail; import common::mode_compile_fail; +import common::mode_pretty; import common::mode; import util::logv; @@ -89,6 +90,7 @@ fn str_mode(s: str) -> mode { "compile-fail" { mode_compile_fail } "run-fail" { mode_run_fail } "run-pass" { mode_run_pass } + "pretty" { mode_pretty } _ { fail "invalid mode" } } } @@ -98,6 +100,7 @@ fn mode_str(mode: mode) -> str { mode_compile_fail. { "compile-fail" } mode_run_fail. { "run-fail" } mode_run_pass. { "run-pass" } + mode_pretty. { "pretty" } } } @@ -136,11 +139,15 @@ fn is_test(testfile: &str) -> bool { fn make_test(cx: &cx, testfile: &str, configport: &port[str]) -> test::test_desc { - {name: testfile, + {name: make_test_name(cx.config, testfile), fn: make_test_closure(testfile, chan(configport)), ignore: header::is_test_ignored(cx.config.stage_id, testfile)} } +fn make_test_name(config: &config, testfile: &str) -> str { + #fmt("[%s] %s", mode_str(config.mode), testfile) +} + /* So this is kind of crappy: diff --git a/src/test/compiletest/runtest.rs b/src/test/compiletest/runtest.rs index 9355ed5620e0..117d5651bca8 100644 --- a/src/test/compiletest/runtest.rs +++ b/src/test/compiletest/runtest.rs @@ -10,6 +10,7 @@ import std::test; import common::mode_run_pass; import common::mode_run_fail; import common::mode_compile_fail; +import common::mode_pretty; import common::cx; import common::config; import header::load_props; @@ -30,6 +31,7 @@ fn run(cx: &cx, testfile: &str) { mode_compile_fail. { run_cfail_test(cx, props, testfile); } mode_run_fail. { run_rfail_test(cx, props, testfile); } mode_run_pass. { run_rpass_test(cx, props, testfile); } + mode_pretty. { run_pretty_test(cx, props, testfile); } } } @@ -72,6 +74,9 @@ fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) { if procres.status != 0 { fatal_procres("test run failed!", procres); } } +fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) { +} + fn check_error_patterns(props: &test_props, testfile: &str, procres: &procres) { if ivec::is_empty(props.error_patterns) {