Skip to content

Commit 4e8ab8b

Browse files
committed
Introduce pretty-print testing mode to compiletest. Issue #789
1 parent af2eecd commit 4e8ab8b

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

mk/tests.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ check-stage$(2)-rpass: test/run-pass.stage$(2).out \
142142

143143
check-stage$(2)-bench: test/bench.stage$(2).out \
144144

145+
check-stage$(2)-pretty: test/pretty.stage$(2).out \
146+
145147
CTEST_COMMON_ARGS$(2) := --compile-lib-path stage$(2) \
146148
--run-lib-path stage$(2)/lib \
147149
--rustc-path stage$(2)/rustc$$(X) \
@@ -172,6 +174,11 @@ BENCH_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
172174
--mode run-pass \
173175
$$(CTEST_RUNTOOL) \
174176

177+
PRETTY_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
178+
--src-base $$(S)src/test/run-pass/ \
179+
--build-base test/run-pass/ \
180+
--mode pretty \
181+
175182
test/compiletest.stage$(2)$$(X): $$(COMPILETEST_CRATE) \
176183
$$(COMPILETEST_INPUTS) \
177184
$$(SREQ$(2))
@@ -202,6 +209,12 @@ test/bench.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \
202209
$$(Q)$$(call CFG_RUN_TEST,$$<) $$(BENCH_ARGS$(2))
203210
$$(Q)touch $$@
204211

212+
test/pretty.stage$(2).out.tmp: test/compiletest.stage$(2)$$(X) \
213+
$$(RPASS_TESTS)
214+
@$$(call E, run: $$<)
215+
$$(Q)$$(call CFG_RUN_TEST,$$<) $$(PRETTY_ARGS$(2))
216+
$$(Q)touch $$@
217+
205218
endef
206219

207220
# Instantiate the template for stage 0, 1, 2, 3

src/test/compiletest/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import std::option;
22

3-
tag mode { mode_compile_fail; mode_run_fail; mode_run_pass; }
3+
tag mode {
4+
mode_compile_fail;
5+
mode_run_fail;
6+
mode_run_pass;
7+
mode_pretty;
8+
}
49

510
type config = {
611
// The library paths required for running the compiler

src/test/compiletest/compiletest.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import common::config;
1212
import common::mode_run_pass;
1313
import common::mode_run_fail;
1414
import common::mode_compile_fail;
15+
import common::mode_pretty;
1516
import common::mode;
1617
import util::logv;
1718

@@ -89,6 +90,7 @@ fn str_mode(s: str) -> mode {
8990
"compile-fail" { mode_compile_fail }
9091
"run-fail" { mode_run_fail }
9192
"run-pass" { mode_run_pass }
93+
"pretty" { mode_pretty }
9294
_ { fail "invalid mode" }
9395
}
9496
}
@@ -98,6 +100,7 @@ fn mode_str(mode: mode) -> str {
98100
mode_compile_fail. { "compile-fail" }
99101
mode_run_fail. { "run-fail" }
100102
mode_run_pass. { "run-pass" }
103+
mode_pretty. { "pretty" }
101104
}
102105
}
103106

@@ -136,11 +139,15 @@ fn is_test(testfile: &str) -> bool {
136139

137140
fn make_test(cx: &cx, testfile: &str, configport: &port[str]) ->
138141
test::test_desc {
139-
{name: testfile,
142+
{name: make_test_name(cx.config, testfile),
140143
fn: make_test_closure(testfile, chan(configport)),
141144
ignore: header::is_test_ignored(cx.config.stage_id, testfile)}
142145
}
143146

147+
fn make_test_name(config: &config, testfile: &str) -> str {
148+
#fmt("[%s] %s", mode_str(config.mode), testfile)
149+
}
150+
144151
/*
145152
So this is kind of crappy:
146153

src/test/compiletest/runtest.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import std::test;
1010
import common::mode_run_pass;
1111
import common::mode_run_fail;
1212
import common::mode_compile_fail;
13+
import common::mode_pretty;
1314
import common::cx;
1415
import common::config;
1516
import header::load_props;
@@ -30,6 +31,7 @@ fn run(cx: &cx, testfile: &str) {
3031
mode_compile_fail. { run_cfail_test(cx, props, testfile); }
3132
mode_run_fail. { run_rfail_test(cx, props, testfile); }
3233
mode_run_pass. { run_rpass_test(cx, props, testfile); }
34+
mode_pretty. { run_pretty_test(cx, props, testfile); }
3335
}
3436
}
3537

@@ -72,6 +74,9 @@ fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) {
7274
if procres.status != 0 { fatal_procres("test run failed!", procres); }
7375
}
7476

77+
fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
78+
}
79+
7580
fn check_error_patterns(props: &test_props, testfile: &str,
7681
procres: &procres) {
7782
if ivec::is_empty(props.error_patterns) {

0 commit comments

Comments
 (0)