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`.
This commit is contained in:
klutzy 2014-04-16 14:29:02 +09:00 committed by Alex Crichton
parent 96eeda9708
commit ce8c467bd2
10 changed files with 31 additions and 6 deletions

View File

@ -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))
}

View File

@ -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() { }

View File

@ -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() {

View File

@ -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() {}

View File

@ -9,6 +9,8 @@
// except according to those terms.
// ignore-android
// ignore-pretty: does not work well with `--test`
#![feature(quote)]
#![deny(unused_variable)]

View File

@ -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 {

View File

@ -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)]

View File

@ -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"); }

View File

@ -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))]

View File

@ -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