From ce8c467bd2062edc1410f54c8efafbc5ae245358 Mon Sep 17 00:00:00 2001 From: klutzy Date: Wed, 16 Apr 2014 14:29:02 +0900 Subject: [PATCH] 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`. --- src/compiletest/runtest.rs | 25 +++++++++++++++---- src/test/run-fail/run-unexported-tests.rs | 1 + src/test/run-fail/test-fail.rs | 1 + src/test/run-fail/test-tasks-invalid-value.rs | 1 + .../quote-unused-sp-no-warning.rs | 2 ++ src/test/run-pass/hygienic-labels-in-let.rs | 2 ++ src/test/run-pass/ifmt.rs | 1 + src/test/run-pass/shebang.rs | 2 +- src/test/run-pass/test-ignore-cfg.rs | 1 + src/test/run-pass/test-runner-hides-main.rs | 1 + 10 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 66bebaff0148..bd909c8f0693 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -157,9 +157,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) { let mut round = 0; while round < rounds { logv(config, format!("pretty-printing round {}", round)); - let proc_res = print_source(config, - testfile, - (*srcs.get(round)).clone()); + let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "normal"); if !proc_res.status.success() { fatal_ProcRes(format!("pretty-printing failed in round {}", round), @@ -197,10 +195,27 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) { fatal_ProcRes("pretty-printed source does not typecheck".to_owned(), &proc_res); } + // additionally, run `--pretty expanded` and try to build it. + let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded"); + if !proc_res.status.success() { + fatal_ProcRes(format!("pretty-printing (expanded) failed"), &proc_res); + } + + let ProcRes{ stdout: expanded_src, .. } = proc_res; + let proc_res = typecheck_source(config, props, testfile, expanded_src); + if !proc_res.status.success() { + fatal_ProcRes(format!("pretty-printed source (expanded) does not typecheck"), &proc_res); + } + return; - fn print_source(config: &Config, testfile: &Path, src: ~str) -> ProcRes { - compose_and_run(config, testfile, make_pp_args(config, testfile), + fn print_source(config: &Config, + props: &TestProps, + testfile: &Path, + src: ~str, + pretty_type: &str) -> ProcRes { + compose_and_run(config, testfile, + make_pp_args(config, props, testfile, pretty_type.to_owned()), Vec::new(), config.compile_lib_path, Some(src)) } diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index b89412755916..70ef4a0c0c3d 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -11,6 +11,7 @@ // error-pattern:runned an unexported test // compile-flags:--test // check-stdout +// ignore-pretty: does not work well with `--test` mod m { pub fn exported() { } diff --git a/src/test/run-fail/test-fail.rs b/src/test/run-fail/test-fail.rs index 77d87c22c6f1..b628f101fd57 100644 --- a/src/test/run-fail/test-fail.rs +++ b/src/test/run-fail/test-fail.rs @@ -11,6 +11,7 @@ // check-stdout // error-pattern:task 'test_foo' failed at // compile-flags: --test +// ignore-pretty: does not work well with `--test` #[test] fn test_foo() { diff --git a/src/test/run-fail/test-tasks-invalid-value.rs b/src/test/run-fail/test-tasks-invalid-value.rs index 74531deb58ef..8c9cd2d63cb4 100644 --- a/src/test/run-fail/test-tasks-invalid-value.rs +++ b/src/test/run-fail/test-tasks-invalid-value.rs @@ -14,6 +14,7 @@ // error-pattern:should be a positive integer // compile-flags: --test // exec-env:RUST_TEST_TASKS=foo +// ignore-pretty: does not work well with `--test` #[test] fn do_nothing() {} diff --git a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs index 5025cc12b4a6..2d5bbd43e826 100644 --- a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs +++ b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs @@ -9,6 +9,8 @@ // except according to those terms. // ignore-android +// ignore-pretty: does not work well with `--test` + #![feature(quote)] #![deny(unused_variable)] diff --git a/src/test/run-pass/hygienic-labels-in-let.rs b/src/test/run-pass/hygienic-labels-in-let.rs index 22523f5e6ccb..ee90cfd3475b 100644 --- a/src/test/run-pass/hygienic-labels-in-let.rs +++ b/src/test/run-pass/hygienic-labels-in-let.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-pretty: pprust doesn't print hygiene output + #![feature(macro_rules)] macro_rules! loop_x { diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 12fb8dcccc8d..4d445db302b0 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-pretty: `--pretty expand` creates unnecessary `unsafe` block #![feature(macro_rules, managed_boxes)] #![deny(warnings)] diff --git a/src/test/run-pass/shebang.rs b/src/test/run-pass/shebang.rs index b6451c577726..2f78513b95cf 100644 --- a/src/test/run-pass/shebang.rs +++ b/src/test/run-pass/shebang.rs @@ -9,6 +9,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pp-exact +// ignore-pretty: `expand` addes some preludes before shebang pub fn main() { println!("Hello World"); } diff --git a/src/test/run-pass/test-ignore-cfg.rs b/src/test/run-pass/test-ignore-cfg.rs index e8d36dad2087..309325ab7db4 100644 --- a/src/test/run-pass/test-ignore-cfg.rs +++ b/src/test/run-pass/test-ignore-cfg.rs @@ -9,6 +9,7 @@ // except according to those terms. // compile-flags: --test --cfg ignorecfg +// ignore-pretty: does not work well with `--test` #[test] #[ignore(cfg(ignorecfg))] diff --git a/src/test/run-pass/test-runner-hides-main.rs b/src/test/run-pass/test-runner-hides-main.rs index 954d88c0bdc5..05d5506f0a6b 100644 --- a/src/test/run-pass/test-runner-hides-main.rs +++ b/src/test/run-pass/test-runner-hides-main.rs @@ -10,6 +10,7 @@ // compile-flags:--test // ignore-win32 #10872 +// ignore-pretty: does not work well with `--test` // Building as a test runner means that a synthetic main will be run, // not ours