]> git.lizzy.rs Git - rust.git/blobdiff - tests/compile-test.rs
Change explicit_counter_loop's message to add parentheses if necessary
[rust.git] / tests / compile-test.rs
index 236cce0dbb7ccca1fe9dda389a3bb73429436c75..b6a4beff0469864781aeadb9bf019fe9f13c6eb9 100644 (file)
@@ -1,12 +1,12 @@
 #![feature(test)]
 
-extern crate compiletest_rs as compiletest;
+use compiletest_rs as compiletest;
 extern crate test;
 
-use std::io;
+use std::env::{set_var, var};
 use std::ffi::OsStr;
 use std::fs;
-use std::env::{set_var, var};
+use std::io;
 use std::path::{Path, PathBuf};
 
 fn clippy_driver_path() -> PathBuf {
@@ -46,7 +46,10 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config {
         config.run_lib_path = rustc_lib_path();
         config.compile_lib_path = rustc_lib_path();
     }
-    config.target_rustcflags = Some(format!("-L {0} -L {0}/deps -Dwarnings", host_libs().display()));
+    config.target_rustcflags = Some(format!(
+        "-L {0} -L {0}/deps -Dwarnings -Zui-testing",
+        host_libs().display()
+    ));
 
     config.mode = cfg_mode;
     config.build_base = if rustc_test_suite().is_some() {
@@ -65,7 +68,10 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config {
 }
 
 fn run_mode(mode: &str, dir: PathBuf) {
-    compiletest::run_tests(&config(mode, dir));
+    let cfg = config(mode, dir);
+    // clean rmeta data, otherwise "cargo check; cargo test" fails (#2896)
+    cfg.clean_rmeta();
+    compiletest::run_tests(&cfg);
 }
 
 fn run_ui_toml_tests(config: &compiletest::Config, mut tests: Vec<test::TestDescAndFn>) -> Result<bool, io::Error> {
@@ -93,12 +99,11 @@ fn run_ui_toml_tests(config: &compiletest::Config, mut tests: Vec<test::TestDesc
                 relative_dir: dir_path.file_name().unwrap().into(),
             };
             let test_name = compiletest::make_test_name(&config, &paths);
-            let index = tests.iter()
+            let index = tests
+                .iter()
                 .position(|test| test.desc.name == test_name)
                 .expect("The test should be in there");
-            result &= test::run_tests_console(
-                &opts,
-                vec![tests.swap_remove(index)])?;
+            result &= test::run_tests_console(&opts, vec![tests.swap_remove(index)])?;
         }
     }
     Ok(result)
@@ -111,11 +116,11 @@ fn run_ui_toml() {
 
     let res = run_ui_toml_tests(&config, tests);
     match res {
-        Ok(true) => {}
+        Ok(true) => {},
         Ok(false) => panic!("Some tests failed"),
         Err(e) => {
             println!("I/O failure during tests: {:?}", e);
-        }
+        },
     }
 }
 
@@ -128,7 +133,6 @@ fn prepare_env() {
 #[test]
 fn compile_test() {
     prepare_env();
-    run_mode("run-pass", "tests/run-pass".into());
     run_mode("ui", "tests/ui".into());
     run_ui_toml();
 }