]> git.lizzy.rs Git - rust.git/commitdiff
compiletest: Test `--pretty expanded`
authorklutzy <klutzytheklutzy@gmail.com>
Wed, 16 Apr 2014 05:29:02 +0000 (14:29 +0900)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 14 May 2014 00:24:08 +0000 (17:24 -0700)
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
src/test/run-fail/run-unexported-tests.rs
src/test/run-fail/test-fail.rs
src/test/run-fail/test-tasks-invalid-value.rs
src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs
src/test/run-pass/hygienic-labels-in-let.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/shebang.rs
src/test/run-pass/test-ignore-cfg.rs
src/test/run-pass/test-runner-hides-main.rs

index 66bebaff014817a4a4e6833ca02146a173cfdabb..bd909c8f0693f4e80cbec70ac88761c390b3fdca 100644 (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))
     }
 
index b8941275591613ee28c12433df1124316102d31e..70ef4a0c0c3d307e9895ccbe78cc4560f8977ce6 100644 (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() { }
index 77d87c22c6f1cfe84a81ef9fbb60920c6f7aa264..b628f101fd5766b67e7315d0d5d8291ff5ee2aef 100644 (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() {
index 74531deb58ef6c8d18529151437202ffdd868e76..8c9cd2d63cb4758f4c29f40e3e2435294872a126 100644 (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() {}
index 5025cc12b4a64083806f5ae325ca9aca172458a5..2d5bbd43e826f23b38212dc5f4e7bf00333546f5 100644 (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)]
 
index 22523f5e6ccb7e39631195f76cf48aca7b0f1151..ee90cfd3475b1a87adb269be2f0f71a80173e20f 100644 (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 {
index 12fb8dcccc8dcacb091f85a6b258adf2db1d05b8..4d445db302b0bffb2191520020bdd71616ec1f2f 100644 (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)]
index b6451c57772666d32c979de52a86efc548cf252d..2f78513b95cf9c7f132ca72c4d5ecb226d190b7a 100644 (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"); }
index e8d36dad2087749cb185065697aae3009764c568..309325ab7db4a1fca09d2efbc931833e2f8a8124 100644 (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))]
index 954d88c0bdc5e6095d464397ec64f2653be3619c..05d5506f0a6b0df599d135befd9596f544789979 100644 (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