about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-21 07:40:32 +0000
committerbors <bors@rust-lang.org>2022-07-21 07:40:32 +0000
commit3800933ff00dec0086e379856eb4adac8f890a47 (patch)
tree2e09b7f661e4decb4d96422a8238d0ad285df28d
parent084e02fd0885556fb44e7cb88c94a984ccbcfd3e (diff)
parentecacc56843ae0bd1ba264a9abf95c31ee66a9f8b (diff)
downloadrust-3800933ff00dec0086e379856eb4adac8f890a47.tar.gz
rust-3800933ff00dec0086e379856eb4adac8f890a47.zip
Auto merge of #2383 - rust-lang:dot_mode, r=oli-obk
Print one . character per test instead of one line

`./miri bless -- --quiet` now prints a dot per test, along with the regular Rust unit tests that listen to this flag
-rw-r--r--tests/compiletest.rs14
-rw-r--r--ui_test/src/lib.rs54
-rw-r--r--ui_test/src/tests.rs1
3 files changed, 59 insertions, 10 deletions
diff --git a/tests/compiletest.rs b/tests/compiletest.rs
index 37b9de7327a..72aa140d66a 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -48,8 +48,17 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
         (true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
     };
 
-    // Pass on all arguments as filters.
-    let path_filter = std::env::args().skip(1);
+    // Pass on all unknown arguments as filters.
+    let mut quiet = false;
+    let path_filter = std::env::args().skip(1).filter(|arg| {
+        match &**arg {
+            "--quiet" => {
+                quiet = true;
+                false
+            }
+            _ => true,
+        }
+    });
 
     let use_std = env::var_os("MIRI_NO_STD").is_none();
 
@@ -76,6 +85,7 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
             ],
             envs: vec![],
         }),
+        quiet,
     };
     ui_test::run_tests(config)
 }
diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs
index 4318e8a8e03..06a84cfbf32 100644
--- a/ui_test/src/lib.rs
+++ b/ui_test/src/lib.rs
@@ -46,6 +46,8 @@ pub struct Config {
     /// Can be used to override what command to run instead of `cargo` to build the
     /// dependencies in `manifest_path`
     pub dependency_builder: Option<DependencyBuilder>,
+    /// Print one character per test instead of one line
+    pub quiet: bool,
 }
 
 #[derive(Debug)]
@@ -123,11 +125,50 @@ pub fn run_tests(mut config: Config) -> Result<()> {
             drop(submit);
         });
 
+        // A channel for the messages emitted by the individual test threads.
+        let (finished_files_sender, finished_files_recv) = crossbeam::channel::unbounded();
+        enum TestResult {
+            Ok,
+            Failed,
+            Ignored,
+        }
+
+        s.spawn(|_| {
+            if config.quiet {
+                for (i, (_, result)) in finished_files_recv.into_iter().enumerate() {
+                    // Humans start counting at 1
+                    let i = i + 1;
+                    match result {
+                        TestResult::Ok => eprint!("{}", ".".green()),
+                        TestResult::Failed => eprint!("{}", "F".red().bold()),
+                        TestResult::Ignored => eprint!("{}", "i".yellow()),
+                    }
+                    if i % 100 == 0 {
+                        eprintln!(" {i}");
+                    }
+                }
+            } else {
+                for (msg, result) in finished_files_recv {
+                    eprint!("{msg} ... ");
+                    eprintln!(
+                        "{}",
+                        match result {
+                            TestResult::Ok => "ok".green(),
+                            TestResult::Failed => "FAILED".red().bold(),
+                            TestResult::Ignored => "ignored (in-test comment)".yellow(),
+                        }
+                    );
+                }
+            }
+        });
+
         let mut threads = vec![];
 
         // Create N worker threads that receive files to test.
         for _ in 0..std::thread::available_parallelism().unwrap().get() {
+            let finished_files_sender = finished_files_sender.clone();
             threads.push(s.spawn(|_| -> Result<()> {
+                let finished_files_sender = finished_files_sender;
                 for path in &receive {
                     if !config.path_filter.is_empty() {
                         let path_display = path.display().to_string();
@@ -140,11 +181,8 @@ pub fn run_tests(mut config: Config) -> Result<()> {
                     // Ignore file if only/ignore rules do (not) apply
                     if !test_file_conditions(&comments, &target, &config) {
                         ignored.fetch_add(1, Ordering::Relaxed);
-                        eprintln!(
-                            "{} ... {}",
-                            path.display(),
-                            "ignored (in-test comment)".yellow()
-                        );
+                        finished_files_sender
+                            .send((path.display().to_string(), TestResult::Ignored))?;
                         continue;
                     }
                     // Run the test for all revisions
@@ -159,12 +197,11 @@ pub fn run_tests(mut config: Config) -> Result<()> {
                         if !revision.is_empty() {
                             write!(msg, "(revision `{revision}`) ").unwrap();
                         }
-                        write!(msg, "... ").unwrap();
                         if errors.is_empty() {
-                            eprintln!("{msg}{}", "ok".green());
+                            finished_files_sender.send((msg, TestResult::Ok))?;
                             succeeded.fetch_add(1, Ordering::Relaxed);
                         } else {
-                            eprintln!("{msg}{}", "FAILED".red().bold());
+                            finished_files_sender.send((msg, TestResult::Failed))?;
                             failures.lock().unwrap().push((
                                 path.clone(),
                                 m,
@@ -178,6 +215,7 @@ pub fn run_tests(mut config: Config) -> Result<()> {
                 Ok(())
             }));
         }
+
         for thread in threads {
             thread.join().unwrap()?;
         }
diff --git a/ui_test/src/tests.rs b/ui_test/src/tests.rs
index 8b0bd517a10..2032988ed38 100644
--- a/ui_test/src/tests.rs
+++ b/ui_test/src/tests.rs
@@ -18,6 +18,7 @@ fn config() -> Config {
         output_conflict_handling: OutputConflictHandling::Error,
         dependencies_crate_manifest_path: None,
         dependency_builder: None,
+        quiet: false,
     }
 }