diff --git a/src/runtest.rs b/src/runtest.rs index d8f338a..35c8c0b 100644 --- a/src/runtest.rs +++ b/src/runtest.rs @@ -263,6 +263,12 @@ impl<'test> TestCx<'test> { } } + #[cfg(feature = "stable")] + fn run_pretty_test(&self) { + self.fatal("pretty-printing tests can only be used with nightly Rust".into()); + } + + #[cfg(not(feature = "stable"))] fn run_pretty_test(&self) { if self.props.pp_exact.is_some() { logv(self.config, "testing for exact pretty-printing".to_owned()); @@ -344,8 +350,7 @@ impl<'test> TestCx<'test> { let mut rustc = Command::new(&self.config.rustc_path); rustc.arg("-") - .arg("-Zunstable-options") - .args(&["--unpretty", &pretty_type]) + .args(&["-Z", &format!("unpretty={}", pretty_type)]) .args(&["--target", &self.config.target]) .arg("-L").arg(&aux_dir) .args(self.split_maybe_args(&self.config.target_rustcflags)) diff --git a/test-project/tests/pretty/macro.pp b/test-project/tests/pretty/macro.pp new file mode 100644 index 0000000..0001bfd --- /dev/null +++ b/test-project/tests/pretty/macro.pp @@ -0,0 +1,13 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use std::prelude::v1::*; +#[macro_use] +extern crate std; +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:macro.pp + +macro_rules! square(( $ x : expr ) => { $ x * $ x } ;); + +fn f() -> i8 { 5 * 5 } diff --git a/test-project/tests/pretty/macro.rs b/test-project/tests/pretty/macro.rs new file mode 100644 index 0000000..e019d91 --- /dev/null +++ b/test-project/tests/pretty/macro.rs @@ -0,0 +1,13 @@ +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:macro.pp + +macro_rules! square { + ($x:expr) => { + $x * $x + }; +} + +fn f() -> i8 { + square!(5) +} diff --git a/test-project/tests/tests.rs b/test-project/tests/tests.rs index e59e14f..d5c92a8 100644 --- a/test-project/tests/tests.rs +++ b/test-project/tests/tests.rs @@ -19,4 +19,7 @@ fn run_mode(mode: &'static str) { fn compile_test() { run_mode("compile-fail"); run_mode("run-pass"); + + #[cfg(not(feature = "stable"))] + run_mode("pretty"); }