Skip to content

Commit ce8c467

Browse files
klutzyalexcrichton
authored andcommitted
compiletest: Test --pretty expanded
After testing `--pretty normal`, it tries to run `--pretty expanded` and typecheck output. Here we don't check convergence since it really diverges: for every iteration, some extra lines (e.g.`extern crate std`) are inserted. Some tests are `ignore-pretty`-ed since they cause various issues with `--pretty expanded`.
1 parent 96eeda9 commit ce8c467

File tree

10 files changed

+31
-6
lines changed

10 files changed

+31
-6
lines changed

src/compiletest/runtest.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
157157
let mut round = 0;
158158
while round < rounds {
159159
logv(config, format!("pretty-printing round {}", round));
160-
let proc_res = print_source(config,
161-
testfile,
162-
(*srcs.get(round)).clone());
160+
let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "normal");
163161

164162
if !proc_res.status.success() {
165163
fatal_ProcRes(format!("pretty-printing failed in round {}", round),
@@ -197,10 +195,27 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
197195
fatal_ProcRes("pretty-printed source does not typecheck".to_owned(), &proc_res);
198196
}
199197

198+
// additionally, run `--pretty expanded` and try to build it.
199+
let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded");
200+
if !proc_res.status.success() {
201+
fatal_ProcRes(format!("pretty-printing (expanded) failed"), &proc_res);
202+
}
203+
204+
let ProcRes{ stdout: expanded_src, .. } = proc_res;
205+
let proc_res = typecheck_source(config, props, testfile, expanded_src);
206+
if !proc_res.status.success() {
207+
fatal_ProcRes(format!("pretty-printed source (expanded) does not typecheck"), &proc_res);
208+
}
209+
200210
return;
201211

202-
fn print_source(config: &Config, testfile: &Path, src: ~str) -> ProcRes {
203-
compose_and_run(config, testfile, make_pp_args(config, testfile),
212+
fn print_source(config: &Config,
213+
props: &TestProps,
214+
testfile: &Path,
215+
src: ~str,
216+
pretty_type: &str) -> ProcRes {
217+
compose_and_run(config, testfile,
218+
make_pp_args(config, props, testfile, pretty_type.to_owned()),
204219
Vec::new(), config.compile_lib_path, Some(src))
205220
}
206221

src/test/run-fail/run-unexported-tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// error-pattern:runned an unexported test
1212
// compile-flags:--test
1313
// check-stdout
14+
// ignore-pretty: does not work well with `--test`
1415

1516
mod m {
1617
pub fn exported() { }

src/test/run-fail/test-fail.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// check-stdout
1212
// error-pattern:task 'test_foo' failed at
1313
// compile-flags: --test
14+
// ignore-pretty: does not work well with `--test`
1415

1516
#[test]
1617
fn test_foo() {

src/test/run-fail/test-tasks-invalid-value.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// error-pattern:should be a positive integer
1515
// compile-flags: --test
1616
// exec-env:RUST_TEST_TASKS=foo
17+
// ignore-pretty: does not work well with `--test`
1718

1819
#[test]
1920
fn do_nothing() {}

src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// except according to those terms.
1010

1111
// ignore-android
12+
// ignore-pretty: does not work well with `--test`
13+
1214
#![feature(quote)]
1315
#![deny(unused_variable)]
1416

src/test/run-pass/hygienic-labels-in-let.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-pretty: pprust doesn't print hygiene output
12+
1113
#![feature(macro_rules)]
1214

1315
macro_rules! loop_x {

src/test/run-pass/ifmt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-pretty: `--pretty expand` creates unnecessary `unsafe` block
1112

1213
#![feature(macro_rules, managed_boxes)]
1314
#![deny(warnings)]

src/test/run-pass/shebang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
// option. This file may not be copied, modified, or distributed
1010
// except according to those terms.
1111

12-
// pp-exact
12+
// ignore-pretty: `expand` addes some preludes before shebang
1313

1414
pub fn main() { println!("Hello World"); }

src/test/run-pass/test-ignore-cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// compile-flags: --test --cfg ignorecfg
12+
// ignore-pretty: does not work well with `--test`
1213

1314
#[test]
1415
#[ignore(cfg(ignorecfg))]

src/test/run-pass/test-runner-hides-main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// compile-flags:--test
1212
// ignore-win32 #10872
13+
// ignore-pretty: does not work well with `--test`
1314

1415
// Building as a test runner means that a synthetic main will be run,
1516
// not ours

0 commit comments

Comments
 (0)