Skip to content

Commit

Permalink
compiletest: Test --pretty expanded
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
klutzy authored and alexcrichton committed May 14, 2014
1 parent 96eeda9 commit ce8c467
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 6 deletions.
25 changes: 20 additions & 5 deletions src/compiletest/runtest.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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))
}

Expand Down
1 change: 1 addition & 0 deletions src/test/run-fail/run-unexported-tests.rs
Expand Up @@ -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() { }
Expand Down
1 change: 1 addition & 0 deletions src/test/run-fail/test-fail.rs
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-fail/test-tasks-invalid-value.rs
Expand Up @@ -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() {}
2 changes: 2 additions & 0 deletions src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs
Expand Up @@ -9,6 +9,8 @@
// except according to those terms.

// ignore-android
// ignore-pretty: does not work well with `--test`

#![feature(quote)]
#![deny(unused_variable)]

Expand Down
2 changes: 2 additions & 0 deletions src/test/run-pass/hygienic-labels-in-let.rs
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/ifmt.rs
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/shebang.rs
Expand Up @@ -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"); }
1 change: 1 addition & 0 deletions src/test/run-pass/test-ignore-cfg.rs
Expand Up @@ -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))]
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/test-runner-hides-main.rs
Expand Up @@ -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
Expand Down

0 comments on commit ce8c467

Please sign in to comment.