From 0432fcb70530741667f5a4c0fd4f72a8b7a4f061 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 12:42:21 +0200 Subject: [PATCH 01/12] Make progress bar reflect the actually tested items --- src/status_emitter.rs | 88 +++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index 320a6ab5..387088e2 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -21,10 +21,7 @@ use std::{ num::NonZeroUsize, panic::{AssertUnwindSafe, RefUnwindSafe}, path::{Path, PathBuf}, - sync::{ - atomic::{AtomicUsize, Ordering}, - Arc, - }, + sync::Arc, thread::JoinHandle, time::Duration, }; @@ -182,19 +179,24 @@ impl Drop for JoinOnDrop { } } +#[derive(Debug)] +enum PopStyle { + Erase, + Abort, + Replace(String), +} + #[derive(Debug)] enum Msg { Pop { msg: String, - new_leftover_msg: Option, + new_leftover_msg: PopStyle, parent: String, }, Push { parent: String, msg: String, }, - Inc, - IncLength, Finish, } @@ -203,9 +205,15 @@ impl Text { let (sender, receiver) = crossbeam_channel::unbounded(); let handle = std::thread::spawn(move || { let bars = MultiProgress::new(); - let mut progress = None; + let progress = match progress { + OutputVerbosity::Progress => Some(bars.add(ProgressBar::new(0))), + OutputVerbosity::DiffOnly | OutputVerbosity::Full => None, + }; // The bools signal whether the progress bar is done (used for sanity assertions only) let mut threads: HashMap> = HashMap::new(); + + let mut aborted = false; + 'outer: loop { std::thread::sleep(Duration::from_millis(100)); loop { @@ -213,9 +221,20 @@ impl Text { Ok(val) => match val { Msg::Pop { msg, - new_leftover_msg: new_msg, + new_leftover_msg, parent, } => { + let new_msg = match new_leftover_msg { + PopStyle::Erase => { + progress.as_ref().unwrap().inc(1); + None + } + PopStyle::Abort => { + aborted = true; + None + } + PopStyle::Replace(msg) => Some(msg), + }; let Some(children) = threads.get_mut(&parent) else { // This can happen when a test was not run at all, because it failed directly during // comment parsing. @@ -265,6 +284,9 @@ impl Text { } Msg::Push { parent, msg } => { + if let Some(progress) = &progress { + progress.inc_length(1); + } let children = threads.entry(parent.clone()).or_default(); if !msg.is_empty() { let parent = &children @@ -302,14 +324,6 @@ impl Text { children.insert(msg, (spinner, false)); }; } - Msg::IncLength => { - progress - .get_or_insert_with(|| bars.add(ProgressBar::new(0))) - .inc_length(1); - } - Msg::Inc => { - progress.as_ref().unwrap().inc(1); - } Msg::Finish => break 'outer, }, // Sender panicked, skip asserts @@ -334,8 +348,12 @@ impl Text { } if let Some(progress) = progress { progress.tick(); - progress.finish(); - assert_eq!(Some(progress.position()), progress.length()); + if aborted { + progress.abandon(); + } else { + assert_eq!(Some(progress.position()), progress.length()); + progress.finish(); + } } }); Self { @@ -381,23 +399,15 @@ struct TextTest { parent: String, path: PathBuf, revision: String, - /// Increased whenever a revision or sub-path is registered - /// Decreased whenever `done` is called - /// On increase from 0 to 1, adds 1 to the progress bar length - /// On decrease from 1 to 0, removes 1 from progress bar length - inc_counter: Arc, style: RevisionStyle, } impl TestStatus for TextTest { fn done(&self, result: &TestResult, aborted: bool) { - let new_leftover_msg = if self.text.is_quiet_output() { - if self.inc_counter.fetch_sub(1, Ordering::Relaxed) == 1 { - self.text.sender.send(Msg::Inc).unwrap(); - } - None - } else if aborted { - None + let new_leftover_msg = if aborted { + PopStyle::Abort + } else if self.text.is_quiet_output() { + PopStyle::Erase } else { let result = match result { Ok(TestOk::Ok) => "ok".green(), @@ -419,7 +429,7 @@ impl TestStatus for TextTest { } std::io::stdout().flush().unwrap(); } - Some(msg) + PopStyle::Replace(msg) }; self.text .sender @@ -486,16 +496,11 @@ impl TestStatus for TextTest { } fn for_revision(&self, revision: &str, style: RevisionStyle) -> Box { - if self.text.is_quiet_output() { - self.inc_counter.fetch_add(1, Ordering::Relaxed); - } - let text = Self { text: self.text.clone(), path: self.path.clone(), parent: self.parent.clone(), revision: revision.to_owned(), - inc_counter: self.inc_counter.clone(), style, }; self.text @@ -514,16 +519,11 @@ impl TestStatus for TextTest { } fn for_path(&self, path: &Path) -> Box { - if self.text.is_quiet_output() { - self.inc_counter.fetch_add(1, Ordering::Relaxed); - } - let text = Self { text: self.text.clone(), path: path.to_path_buf(), parent: self.parent.clone(), revision: String::new(), - inc_counter: self.inc_counter.clone(), style: RevisionStyle::Show, }; @@ -544,15 +544,11 @@ impl TestStatus for TextTest { impl StatusEmitter for Text { fn register_test(&self, path: PathBuf) -> Box { - if self.is_quiet_output() { - self.sender.send(Msg::IncLength).unwrap(); - } Box::new(TextTest { text: self.clone(), parent: display(&path), path, revision: String::new(), - inc_counter: Default::default(), style: RevisionStyle::Show, }) } From 39eae8f84aa0151ef4913b6008b336f56aeb056f Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 21:24:15 +0200 Subject: [PATCH 02/12] instead of sleeping for 10ms and hoping for the best, just join the thread --- src/status_emitter.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index 387088e2..7a69ec4c 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -19,9 +19,9 @@ use std::{ fmt::{Debug, Display, Write as _}, io::Write as _, num::NonZeroUsize, - panic::{AssertUnwindSafe, RefUnwindSafe}, + panic::RefUnwindSafe, path::{Path, PathBuf}, - sync::Arc, + sync::{Arc, Mutex}, thread::JoinHandle, time::Duration, }; @@ -164,18 +164,27 @@ enum OutputVerbosity { pub struct Text { sender: Sender, progress: OutputVerbosity, - _handle: Arc, + handle: Arc, } -struct JoinOnDrop(AssertUnwindSafe>>); +struct JoinOnDrop(Mutex>>); impl From> for JoinOnDrop { fn from(handle: JoinHandle<()>) -> Self { - Self(AssertUnwindSafe(Some(handle))) + Self(Mutex::new(Some(handle))) } } impl Drop for JoinOnDrop { fn drop(&mut self) { - let _ = self.0 .0.take().unwrap().join(); + self.join(); + } +} + +impl JoinOnDrop { + fn join(&self) { + let Ok(Some(handle)) = self.0.try_lock().map(|mut g| g.take()) else { + return; + }; + let _ = handle.join(); } } @@ -359,7 +368,7 @@ impl Text { Self { sender, progress, - _handle: Arc::new(handle.into()), + handle: Arc::new(handle.into()), } } @@ -562,9 +571,8 @@ impl StatusEmitter for Text { aborted: bool, ) -> Box { self.sender.send(Msg::Finish).unwrap(); - while !self.sender.is_empty() { - std::thread::sleep(Duration::from_millis(10)); - } + + self.handle.join(); if !ProgressDrawTarget::stdout().is_hidden() { // The progress bars do not have a trailing newline, so let's // add it here. From a3d7be1dc637cf83edaa99fe6f3de60b5863d435 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 21:42:16 +0200 Subject: [PATCH 03/12] Clippy likes snake case names --- src/custom_flags/rustfix.rs | 2 +- tests/integrations/basic-fail/Cargo.stdout | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/custom_flags/rustfix.rs b/src/custom_flags/rustfix.rs index b2b96759..d03a462b 100644 --- a/src/custom_flags/rustfix.rs +++ b/src/custom_flags/rustfix.rs @@ -216,7 +216,7 @@ fn compile_fixed( }; let mut cmd = fixed_config.build_command(build_manager)?; cmd.arg("--crate-name") - .arg(format!("{crate_name}_________{}", i + 1)); + .arg(format!("__{crate_name}_{}", i + 1)); build_manager.add_new_job(move || { let output = cmd.output().unwrap(); let result = if fixed_config.aborted() { diff --git a/tests/integrations/basic-fail/Cargo.stdout b/tests/integrations/basic-fail/Cargo.stdout index 9ded112f..034c4e87 100644 --- a/tests/integrations/basic-fail/Cargo.stdout +++ b/tests/integrations/basic-fail/Cargo.stdout @@ -962,7 +962,7 @@ full stdout: FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.a.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "rustfix_fail_revisions_________1" +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.a.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1" error: test got exit status: 1, but expected 0 --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9 @@ -993,7 +993,7 @@ full stdout: FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.b.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "rustfix_fail_revisions_________1" +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.b.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1" error: test got exit status: 1, but expected 0 --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9 @@ -1024,7 +1024,7 @@ full stdout: FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "rustfix_fail_________1" +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_1" error: test got exit status: 1, but expected 0 --> tests/actual_tests_bless/rustfix-fail.fixed:1:9 @@ -1091,7 +1091,7 @@ tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed ... FAILED tests/actual_tests_bless_yolo/rustfix-multiple-fail.3.fixed ... ok FAILED TEST: tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "rustfix_multiple_fail_________2" +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_multiple_fail_2" error: test got exit status: 1, but expected 0 --> tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed:1:8 From 2050919aa58bce6d2ef3d15a58732b6a8ee3515d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 22:02:43 +0200 Subject: [PATCH 04/12] Don't panic on `//` with no chars after them --- src/parser.rs | 6 +++--- tests/integrations/basic/tests/actual_tests/foomp.rs | 1 + tests/integrations/basic/tests/actual_tests/foomp.stderr | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index c38dfec5..18507f09 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -474,9 +474,9 @@ impl CommentParser { if let Some((_, comment)) = line.split_once_str(self.comment_start) - .filter(|(pre, c)| match c[0] { - b'@' => pre.is_empty(), - b'~' => true, + .filter(|(pre, c)| match &c[..] { + [b'@', ..] => pre.is_empty(), + [b'~', ..] => true, _ => false, }) { diff --git a/tests/integrations/basic/tests/actual_tests/foomp.rs b/tests/integrations/basic/tests/actual_tests/foomp.rs index a851f369..43cfa53f 100644 --- a/tests/integrations/basic/tests/actual_tests/foomp.rs +++ b/tests/integrations/basic/tests/actual_tests/foomp.rs @@ -1,6 +1,7 @@ use basic::add; fn main() { + // add("42", 3); //~^ ERROR: mismatched types } diff --git a/tests/integrations/basic/tests/actual_tests/foomp.stderr b/tests/integrations/basic/tests/actual_tests/foomp.stderr index 9fe5222c..2163d1c5 100644 --- a/tests/integrations/basic/tests/actual_tests/foomp.stderr +++ b/tests/integrations/basic/tests/actual_tests/foomp.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> tests/actual_tests/foomp.rs:4:9 + --> tests/actual_tests/foomp.rs:5:9 | -4 | add("42", 3); +5 | add("42", 3); | --- ^^^^ expected `usize`, found `&str` | | | arguments to this function are incorrect From 5c8b077504c7d05a9317c8e64e51edb69fe7cd46 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 22:11:38 +0200 Subject: [PATCH 05/12] Always have a progress bar, just hide it --- src/status_emitter.rs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index 7a69ec4c..ac284d86 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -215,8 +215,10 @@ impl Text { let handle = std::thread::spawn(move || { let bars = MultiProgress::new(); let progress = match progress { - OutputVerbosity::Progress => Some(bars.add(ProgressBar::new(0))), - OutputVerbosity::DiffOnly | OutputVerbosity::Full => None, + OutputVerbosity::Progress => bars.add(ProgressBar::new(0)), + OutputVerbosity::DiffOnly | OutputVerbosity::Full => { + ProgressBar::with_draw_target(Some(0), ProgressDrawTarget::hidden()) + } }; // The bools signal whether the progress bar is done (used for sanity assertions only) let mut threads: HashMap> = HashMap::new(); @@ -234,10 +236,7 @@ impl Text { parent, } => { let new_msg = match new_leftover_msg { - PopStyle::Erase => { - progress.as_ref().unwrap().inc(1); - None - } + PopStyle::Erase => None, PopStyle::Abort => { aborted = true; None @@ -249,6 +248,7 @@ impl Text { // comment parsing. continue; }; + progress.inc(1); let Some((spinner, done)) = children.get_mut(&msg) else { panic!("pop: {parent}({msg}): {children:#?}") }; @@ -293,9 +293,7 @@ impl Text { } Msg::Push { parent, msg } => { - if let Some(progress) = &progress { - progress.inc_length(1); - } + progress.inc_length(1); let children = threads.entry(parent.clone()).or_default(); if !msg.is_empty() { let parent = &children @@ -345,9 +343,7 @@ impl Text { spinner.tick(); } } - if let Some(progress) = &progress { - progress.tick() - } + progress.tick() } for (key, children) in threads.iter() { for (sub_key, (child, done)) in children { @@ -355,14 +351,12 @@ impl Text { assert!(done, "{key} ({sub_key}) not finished"); } } - if let Some(progress) = progress { - progress.tick(); - if aborted { - progress.abandon(); - } else { - assert_eq!(Some(progress.position()), progress.length()); - progress.finish(); - } + progress.tick(); + if aborted { + progress.abandon(); + } else { + assert_eq!(Some(progress.position()), progress.length(), "{threads:#?}"); + progress.finish(); } }); Self { From 544d062ac89486bcfc12b8ecf45847d459448027 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 22:30:58 +0200 Subject: [PATCH 06/12] Less unnecessary ticking --- src/status_emitter.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index ac284d86..c1fc51b9 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -339,19 +339,18 @@ impl Text { } } for children in threads.values() { - for (spinner, _done) in children.values() { - spinner.tick(); + for (spinner, done) in children.values() { + if !done { + spinner.tick(); + } } } - progress.tick() } for (key, children) in threads.iter() { - for (sub_key, (child, done)) in children { - child.tick(); + for (sub_key, (_child, done)) in children { assert!(done, "{key} ({sub_key}) not finished"); } } - progress.tick(); if aborted { progress.abandon(); } else { From d5a3276d7ecaa6f48e1900283d95447a6a23060b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Sat, 17 Aug 2024 22:43:22 +0200 Subject: [PATCH 07/12] Refactor progress bar handling into a struct with methods --- src/status_emitter.rs | 256 +++++++++++++++++++++++------------------- 1 file changed, 143 insertions(+), 113 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index c1fc51b9..c68d1980 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -220,10 +220,147 @@ impl Text { ProgressBar::with_draw_target(Some(0), ProgressDrawTarget::hidden()) } }; - // The bools signal whether the progress bar is done (used for sanity assertions only) - let mut threads: HashMap> = HashMap::new(); - let mut aborted = false; + struct ProgressHandler { + // The bools signal whether the progress bar is done (used for sanity assertions only) + threads: HashMap>, + aborted: bool, + bars: MultiProgress, + progress: ProgressBar, + } + + impl ProgressHandler { + fn pop(&mut self, msg: String, new_leftover_msg: PopStyle, parent: String) { + let new_msg = match new_leftover_msg { + PopStyle::Erase => None, + PopStyle::Abort => { + self.aborted = true; + None + } + PopStyle::Replace(msg) => Some(msg), + }; + let Some(children) = self.threads.get_mut(&parent) else { + // This can happen when a test was not run at all, because it failed directly during + // comment parsing. + return; + }; + self.progress.inc(1); + let Some((spinner, done)) = children.get_mut(&msg) else { + panic!("pop: {parent}({msg}): {children:#?}") + }; + *done = true; + let spinner = spinner.clone(); + + let print = new_msg.is_some(); + + if let Some(new_msg) = new_msg { + spinner.finish_with_message(new_msg); + } else { + spinner.finish(); + } + let parent = children[""].0.clone(); + if !msg.is_empty() { + parent.inc(1); + } + if children.values().all(|&(_, done)| done) { + self.bars.remove(&parent); + if print { + self.bars + .println(format!("{} {}", parent.prefix(), parent.message())) + .unwrap(); + } + for (msg, (child, _)) in children.iter() { + if !msg.is_empty() { + self.bars.remove(child); + if print { + self.bars + .println(format!( + " {} {}", + child.prefix(), + child.message() + )) + .unwrap(); + } + } + } + } + } + + fn push(&mut self, parent: String, msg: String) { + self.progress.inc_length(1); + let children = self.threads.entry(parent.clone()).or_default(); + if !msg.is_empty() { + let parent = &children + .entry(String::new()) + .or_insert_with(|| { + let spinner = self + .bars + .add(ProgressBar::new_spinner().with_prefix(parent)); + spinner.set_style( + ProgressStyle::with_template("{prefix} {pos}/{len} {msg}") + .unwrap(), + ); + (spinner, true) + }) + .0; + parent.inc_length(1); + let spinner = self.bars.insert_after( + parent, + ProgressBar::new_spinner().with_prefix(msg.clone()), + ); + spinner.set_style( + ProgressStyle::with_template(" {prefix} {spinner} {msg}").unwrap(), + ); + children.insert(msg, (spinner, false)); + } else { + let spinner = self + .bars + .add(ProgressBar::new_spinner().with_prefix(parent)); + spinner.set_style( + ProgressStyle::with_template("{prefix} {spinner} {msg}").unwrap(), + ); + children.insert(msg, (spinner, false)); + }; + } + + fn tick(&self) { + for children in self.threads.values() { + for (spinner, done) in children.values() { + if !done { + spinner.tick(); + } + } + } + } + } + + impl Drop for ProgressHandler { + fn drop(&mut self) { + for (key, children) in self.threads.iter() { + for (sub_key, (_child, done)) in children { + assert!(done, "{key} ({sub_key}) not finished"); + } + } + if self.aborted { + self.progress.abandon(); + } else { + assert_eq!( + Some(self.progress.position()), + self.progress.length(), + "{:#?}", + self.threads + ); + self.progress.finish(); + } + } + } + + let mut handler = ProgressHandler { + threads: Default::default(), + aborted: false, + bars, + progress, + }; 'outer: loop { std::thread::sleep(Duration::from_millis(100)); @@ -235,101 +372,11 @@ impl Text { new_leftover_msg, parent, } => { - let new_msg = match new_leftover_msg { - PopStyle::Erase => None, - PopStyle::Abort => { - aborted = true; - None - } - PopStyle::Replace(msg) => Some(msg), - }; - let Some(children) = threads.get_mut(&parent) else { - // This can happen when a test was not run at all, because it failed directly during - // comment parsing. - continue; - }; - progress.inc(1); - let Some((spinner, done)) = children.get_mut(&msg) else { - panic!("pop: {parent}({msg}): {children:#?}") - }; - *done = true; - let spinner = spinner.clone(); - - let print = new_msg.is_some(); - - if let Some(new_msg) = new_msg { - spinner.finish_with_message(new_msg); - } else { - spinner.finish(); - } - let parent = children[""].0.clone(); - if !msg.is_empty() { - parent.inc(1); - } - if children.values().all(|&(_, done)| done) { - bars.remove(&parent); - if print { - bars.println(format!( - "{} {}", - parent.prefix(), - parent.message() - )) - .unwrap(); - } - for (msg, (child, _)) in children.iter() { - if !msg.is_empty() { - bars.remove(child); - if print { - bars.println(format!( - " {} {}", - child.prefix(), - child.message() - )) - .unwrap(); - } - } - } - } + handler.pop(msg, new_leftover_msg, parent); } Msg::Push { parent, msg } => { - progress.inc_length(1); - let children = threads.entry(parent.clone()).or_default(); - if !msg.is_empty() { - let parent = &children - .entry(String::new()) - .or_insert_with(|| { - let spinner = bars.add( - ProgressBar::new_spinner().with_prefix(parent), - ); - spinner.set_style( - ProgressStyle::with_template( - "{prefix} {pos}/{len} {msg}", - ) - .unwrap(), - ); - (spinner, true) - }) - .0; - parent.inc_length(1); - let spinner = bars.insert_after( - parent, - ProgressBar::new_spinner().with_prefix(msg.clone()), - ); - spinner.set_style( - ProgressStyle::with_template(" {prefix} {spinner} {msg}") - .unwrap(), - ); - children.insert(msg, (spinner, false)); - } else { - let spinner = - bars.add(ProgressBar::new_spinner().with_prefix(parent)); - spinner.set_style( - ProgressStyle::with_template("{prefix} {spinner} {msg}") - .unwrap(), - ); - children.insert(msg, (spinner, false)); - }; + handler.push(parent, msg); } Msg::Finish => break 'outer, }, @@ -338,24 +385,7 @@ impl Text { Err(TryRecvError::Empty) => break, } } - for children in threads.values() { - for (spinner, done) in children.values() { - if !done { - spinner.tick(); - } - } - } - } - for (key, children) in threads.iter() { - for (sub_key, (_child, done)) in children { - assert!(done, "{key} ({sub_key}) not finished"); - } - } - if aborted { - progress.abandon(); - } else { - assert_eq!(Some(progress.position()), progress.length(), "{threads:#?}"); - progress.finish(); + handler.tick() } }); Self { From 788ba87afaa0aeb231305bb6832b99bdf49acb83 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Aug 2024 17:14:12 +0200 Subject: [PATCH 08/12] Don't track progress of individual parents, it's inconsistent and not very useful --- src/status_emitter.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index c68d1980..037837b9 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -259,9 +259,6 @@ impl Text { spinner.finish(); } let parent = children[""].0.clone(); - if !msg.is_empty() { - parent.inc(1); - } if children.values().all(|&(_, done)| done) { self.bars.remove(&parent); if print { @@ -297,13 +294,11 @@ impl Text { .bars .add(ProgressBar::new_spinner().with_prefix(parent)); spinner.set_style( - ProgressStyle::with_template("{prefix} {pos}/{len} {msg}") - .unwrap(), + ProgressStyle::with_template("{prefix} {msg}").unwrap(), ); (spinner, true) }) .0; - parent.inc_length(1); let spinner = self.bars.insert_after( parent, ProgressBar::new_spinner().with_prefix(msg.clone()), From d01712dc13b867b21dfa2ffc7c24c159f75970dd Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Aug 2024 17:17:10 +0200 Subject: [PATCH 09/12] Don't carry the information about erasing entries in every message --- src/status_emitter.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index 037837b9..4fd99f06 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -190,7 +190,6 @@ impl JoinOnDrop { #[derive(Debug)] enum PopStyle { - Erase, Abort, Replace(String), } @@ -232,7 +231,6 @@ impl Text { impl ProgressHandler { fn pop(&mut self, msg: String, new_leftover_msg: PopStyle, parent: String) { let new_msg = match new_leftover_msg { - PopStyle::Erase => None, PopStyle::Abort => { self.aborted = true; None @@ -251,17 +249,16 @@ impl Text { *done = true; let spinner = spinner.clone(); - let print = new_msg.is_some(); - if let Some(new_msg) = new_msg { spinner.finish_with_message(new_msg); } else { - spinner.finish(); + spinner.finish_and_clear(); + return; } let parent = children[""].0.clone(); if children.values().all(|&(_, done)| done) { self.bars.remove(&parent); - if print { + if self.progress.is_hidden() { self.bars .println(format!("{} {}", parent.prefix(), parent.message())) .unwrap(); @@ -269,7 +266,7 @@ impl Text { for (msg, (child, _)) in children.iter() { if !msg.is_empty() { self.bars.remove(child); - if print { + if self.progress.is_hidden() { self.bars .println(format!( " {} {}", @@ -403,10 +400,6 @@ impl Text { Self::start_thread(OutputVerbosity::Progress) } - fn is_quiet_output(&self) -> bool { - matches!(self.progress, OutputVerbosity::Progress) - } - fn is_full_output(&self) -> bool { matches!(self.progress, OutputVerbosity::Full) } @@ -433,8 +426,6 @@ impl TestStatus for TextTest { fn done(&self, result: &TestResult, aborted: bool) { let new_leftover_msg = if aborted { PopStyle::Abort - } else if self.text.is_quiet_output() { - PopStyle::Erase } else { let result = match result { Ok(TestOk::Ok) => "ok".green(), From 513a4fd4f7bd339fb0aede6dfc4f5ddbf673f67d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Aug 2024 17:22:18 +0200 Subject: [PATCH 10/12] Avoid an intermediate Option --- src/status_emitter.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index 4fd99f06..f3779387 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -230,13 +230,6 @@ impl Text { impl ProgressHandler { fn pop(&mut self, msg: String, new_leftover_msg: PopStyle, parent: String) { - let new_msg = match new_leftover_msg { - PopStyle::Abort => { - self.aborted = true; - None - } - PopStyle::Replace(msg) => Some(msg), - }; let Some(children) = self.threads.get_mut(&parent) else { // This can happen when a test was not run at all, because it failed directly during // comment parsing. @@ -248,12 +241,13 @@ impl Text { }; *done = true; let spinner = spinner.clone(); - - if let Some(new_msg) = new_msg { - spinner.finish_with_message(new_msg); - } else { - spinner.finish_and_clear(); - return; + match new_leftover_msg { + PopStyle::Replace(new_msg) => spinner.finish_with_message(new_msg), + PopStyle::Abort => { + self.aborted = true; + spinner.finish_and_clear(); + return; + } } let parent = children[""].0.clone(); if children.values().all(|&(_, done)| done) { From 2fb14f5992f2e96d45f42fd45a39ae020271fa5a Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Aug 2024 17:26:00 +0200 Subject: [PATCH 11/12] Leave an `... aborted` message on all aborted tests --- src/status_emitter.rs | 66 ++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 39 deletions(-) diff --git a/src/status_emitter.rs b/src/status_emitter.rs index f3779387..fd5eb8ee 100644 --- a/src/status_emitter.rs +++ b/src/status_emitter.rs @@ -188,17 +188,11 @@ impl JoinOnDrop { } } -#[derive(Debug)] -enum PopStyle { - Abort, - Replace(String), -} - #[derive(Debug)] enum Msg { Pop { msg: String, - new_leftover_msg: PopStyle, + new_leftover_msg: String, parent: String, }, Push { @@ -206,6 +200,7 @@ enum Msg { msg: String, }, Finish, + Abort, } impl Text { @@ -229,7 +224,7 @@ impl Text { } impl ProgressHandler { - fn pop(&mut self, msg: String, new_leftover_msg: PopStyle, parent: String) { + fn pop(&mut self, msg: String, new_leftover_msg: String, parent: String) { let Some(children) = self.threads.get_mut(&parent) else { // This can happen when a test was not run at all, because it failed directly during // comment parsing. @@ -241,14 +236,7 @@ impl Text { }; *done = true; let spinner = spinner.clone(); - match new_leftover_msg { - PopStyle::Replace(new_msg) => spinner.finish_with_message(new_msg), - PopStyle::Abort => { - self.aborted = true; - spinner.finish_and_clear(); - return; - } - } + spinner.finish_with_message(new_leftover_msg); let parent = children[""].0.clone(); if children.values().all(|&(_, done)| done) { self.bars.remove(&parent); @@ -365,6 +353,7 @@ impl Text { handler.push(parent, msg); } Msg::Finish => break 'outer, + Msg::Abort => handler.aborted = true, }, // Sender panicked, skip asserts Err(TryRecvError::Disconnected) => return, @@ -418,31 +407,30 @@ struct TextTest { impl TestStatus for TextTest { fn done(&self, result: &TestResult, aborted: bool) { - let new_leftover_msg = if aborted { - PopStyle::Abort - } else { - let result = match result { - Ok(TestOk::Ok) => "ok".green(), - Err(Errored { .. }) => "FAILED".bright_red().bold(), - Ok(TestOk::Ignored) => "ignored (in-test comment)".yellow(), - }; - let msg = format!("... {result}"); - if ProgressDrawTarget::stdout().is_hidden() { - match self.style { - RevisionStyle::Separate => println!("{} {msg}", self.revision), - RevisionStyle::Show => { - let revision = if self.revision.is_empty() { - String::new() - } else { - format!(" (revision `{}`)", self.revision) - }; - println!("{}{revision} {msg}", display(&self.path)); - } + if aborted { + self.text.sender.send(Msg::Abort).unwrap(); + } + let result = match result { + _ if aborted => "aborted".white(), + Ok(TestOk::Ok) => "ok".green(), + Err(Errored { .. }) => "FAILED".bright_red().bold(), + Ok(TestOk::Ignored) => "ignored (in-test comment)".yellow(), + }; + let new_leftover_msg = format!("... {result}"); + if ProgressDrawTarget::stdout().is_hidden() { + match self.style { + RevisionStyle::Separate => println!("{} {new_leftover_msg}", self.revision), + RevisionStyle::Show => { + let revision = if self.revision.is_empty() { + String::new() + } else { + format!(" (revision `{}`)", self.revision) + }; + println!("{}{revision} {new_leftover_msg}", display(&self.path)); } - std::io::stdout().flush().unwrap(); } - PopStyle::Replace(msg) - }; + std::io::stdout().flush().unwrap(); + } self.text .sender .send(Msg::Pop { From 753fc1bf5d81787a0d01868113a155a80d1ca7c7 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Aug 2024 22:30:53 +0200 Subject: [PATCH 12/12] Run subtests before entirely new tests --- src/core.rs | 13 +- src/lib.rs | 26 +- tests/integrations/basic-fail/Cargo.stdout | 390 ++++++++++----------- tests/integrations/basic/Cargo.stdout | 24 +- 4 files changed, 235 insertions(+), 218 deletions(-) diff --git a/src/core.rs b/src/core.rs index 8bdbc81a..30fe888e 100644 --- a/src/core.rs +++ b/src/core.rs @@ -94,14 +94,17 @@ pub enum CrateType { /// A generic multithreaded runner that has a thread for producing work, /// a thread for collecting work, and `num_threads` threads for doing the work. -pub fn run_and_collect( +pub fn run_and_collect( num_threads: NonZeroUsize, - submitter: impl FnOnce(Sender) + Send, - runner: impl Sync + Fn(&Receiver, Sender) -> Result<()>, + submitter: impl FnOnce([Sender; N]) + Send, + runner: impl Sync + Fn(&[Receiver; N], Sender) -> Result<()>, collector: impl FnOnce(Receiver) + Send, ) -> Result<()> { // A channel for files to process - let (submit, receive) = unbounded(); + let (submit, receive): (Vec<_>, Vec<_>) = std::iter::repeat_with(unbounded).take(N).unzip(); + let receive = receive[..].try_into().unwrap(); + let mut submit = submit.into_iter(); + let submit = std::array::from_fn(|_| submit.next().unwrap()); thread::scope(|s| { // Create a thread that is in charge of walking the directory and submitting jobs. @@ -119,7 +122,7 @@ pub fn run_and_collect( // Create N worker threads that receive files to test. for _ in 0..num_threads.get() { let finished_files_sender = finished_files_sender.clone(); - threads.push(s.spawn(|| runner(&receive, finished_files_sender))); + threads.push(s.spawn(|| runner(receive, finished_files_sender))); } for thread in threads { diff --git a/src/lib.rs b/src/lib.rs index fda064f8..d125a3a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,7 @@ pub use color_eyre::eyre::Result; pub use core::run_and_collect; pub use core::CrateType; use crossbeam_channel::Sender; +use crossbeam_channel::TryRecvError; pub use filter::Match; use per_test_config::TestConfig; use spanned::Spanned; @@ -198,12 +199,12 @@ pub fn run_tests_generic( let mut filtered = 0; core::run_and_collect( num_threads, - |submit| { + |[submit, priority_submit]| { let mut todo = VecDeque::new(); let configs: Vec<_> = configs .into_iter() - .map(|config| Arc::new(BuildManager::new(config, submit.clone()))) + .map(|config| Arc::new(BuildManager::new(config, priority_submit.clone()))) .collect(); for build_manager in &configs { todo.push_back(( @@ -287,11 +288,24 @@ pub fn run_tests_generic( } } }, - |receive, finished_files_sender| -> Result<()> { - for closure in receive { - closure(&finished_files_sender)?; + |[receive, priority_receive], finished_files_sender| -> Result<()> { + loop { + for closure in priority_receive.try_iter() { + closure(&finished_files_sender)?; + } + match receive.try_recv() { + Ok(closure) => { + closure(&finished_files_sender)?; + } + Err(TryRecvError::Empty) => {} + Err(TryRecvError::Disconnected) => { + for closure in priority_receive { + closure(&finished_files_sender)?; + } + return Ok(()); + } + } } - Ok(()) }, |finished_files_recv| { for run in finished_files_recv { diff --git a/tests/integrations/basic-fail/Cargo.stdout b/tests/integrations/basic-fail/Cargo.stdout index 034c4e87..d325427e 100644 --- a/tests/integrations/basic-fail/Cargo.stdout +++ b/tests/integrations/basic-fail/Cargo.stdout @@ -6,6 +6,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini Building dependencies ... ok tests/actual_tests/bad_pattern.rs ... FAILED tests/actual_tests/executable.rs ... ok +tests/actual_tests/executable.rs (revision `run`) ... FAILED tests/actual_tests/executable_compile_err.rs ... FAILED tests/actual_tests/exit_code_fail.rs ... FAILED tests/actual_tests/filters.rs ... FAILED @@ -19,7 +20,6 @@ tests/actual_tests/pattern_too_many_arrow_above.rs ... FAILED tests/actual_tests/rustc_ice.rs ... FAILED tests/actual_tests/touching_above_below.rs ... FAILED tests/actual_tests/touching_above_below_chain.rs ... FAILED -tests/actual_tests/executable.rs (revision `run`) ... FAILED FAILED TEST: tests/actual_tests/bad_pattern.rs command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/bad_pattern.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" @@ -76,6 +76,24 @@ full stdout: +FAILED TEST: tests/actual_tests/executable.rs (revision `run`) +command: "$CMD" + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/executable.run.stdout` to the actual output +--- tests/actual_tests/executable.run.stdout ++++ +-69 ++42 + + +full stderr: + +full stdout: +42 + + + FAILED TEST: tests/actual_tests/executable_compile_err.rs command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/executable_compile_err.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" @@ -417,26 +435,9 @@ full stderr: full stdout: - -FAILED TEST: tests/actual_tests/executable.rs (revision `run`) -command: "$CMD" - -error: actual output differed from expected -Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/executable.run.stdout` to the actual output ---- tests/actual_tests/executable.run.stdout -+++ --69 -+42 - - -full stderr: - -full stdout: -42 - - FAILURES: tests/actual_tests/bad_pattern.rs + tests/actual_tests/executable.rs (revision run) tests/actual_tests/executable_compile_err.rs tests/actual_tests/exit_code_fail.rs tests/actual_tests/filters.rs @@ -450,12 +451,12 @@ FAILURES: tests/actual_tests/rustc_ice.rs tests/actual_tests/touching_above_below.rs tests/actual_tests/touching_above_below_chain.rs - tests/actual_tests/executable.rs (revision run) test result: FAIL. 15 failed; 1 passed Building dependencies ... ok tests/actual_tests_bless/abort.rs ... ok +tests/actual_tests_bless/abort.rs (revision `run`) ... FAILED tests/actual_tests_bless/aux_build_not_found.rs ... FAILED tests/actual_tests_bless/aux_proc_macro_misuse.rs ... FAILED Building aux file tests/actual_tests_bless/auxiliary/the_proc_macro.rs ... ok @@ -463,6 +464,7 @@ tests/actual_tests_bless/aux_proc_macro_no_main.rs ... FAILED tests/actual_tests_bless/compile_flags_quotes.rs ... FAILED tests/actual_tests_bless/compiletest-rs-command.rs ... FAILED tests/actual_tests_bless/failing_executable.rs ... ok +tests/actual_tests_bless/failing_executable.rs (revision `run`) ... FAILED Building aux file tests/actual_tests_bless/auxiliary/foomp.rs ... ok tests/actual_tests_bless/foomp_aux.rs ... ok Building aux file tests/actual_tests_bless/auxiliary/nested.rs ... ok @@ -476,8 +478,12 @@ tests/actual_tests_bless/pass_with_annotation.rs ... FAILED tests/actual_tests_bless/revised_revision.rs ... FAILED tests/actual_tests_bless/revisioned_executable.rs (revision `run`) ... ok tests/actual_tests_bless/revisioned_executable.rs (revision `panic`) ... ok +tests/actual_tests_bless/revisioned_executable.rs (revision `run.run`) ... ok +tests/actual_tests_bless/revisioned_executable.rs (revision `panic.run`) ... FAILED tests/actual_tests_bless/revisioned_executable_panic.rs (revision `run`) ... ok tests/actual_tests_bless/revisioned_executable_panic.rs (revision `panic`) ... ok +tests/actual_tests_bless/revisioned_executable_panic.rs (revision `run.run`) ... FAILED +tests/actual_tests_bless/revisioned_executable_panic.rs (revision `panic.run`) ... ok tests/actual_tests_bless/revisions.rs (revision `foo`) ... ok tests/actual_tests_bless/revisions.rs (revision `bar`) ... ok tests/actual_tests_bless/revisions_bad.rs (revision `foo`) ... ok @@ -491,23 +497,29 @@ tests/actual_tests_bless/revisions_multiple_per_annotation.rs (revision `bar`) . tests/actual_tests_bless/revisions_same_everywhere.rs (revision `foo`) ... ok tests/actual_tests_bless/revisions_same_everywhere.rs (revision `bar`) ... ok tests/actual_tests_bless/run_panic.rs ... ok +tests/actual_tests_bless/run_panic.rs (revision `run`) ... ok tests/actual_tests_bless/rustfix-fail-revisions.rs (revision `a`) ... ok tests/actual_tests_bless/rustfix-fail-revisions.rs (revision `b`) ... ok +tests/actual_tests_bless/rustfix-fail-revisions.a.fixed ... FAILED +tests/actual_tests_bless/rustfix-fail-revisions.b.fixed ... FAILED tests/actual_tests_bless/rustfix-fail.rs ... ok +tests/actual_tests_bless/rustfix-fail.fixed ... FAILED tests/actual_tests_bless/unicode.rs ... FAILED tests/actual_tests_bless/unknown_revision.rs ... FAILED tests/actual_tests_bless/unknown_revision2.rs ... FAILED tests/actual_tests_bless/wrong_diagnostic_code.rs ... FAILED -tests/actual_tests_bless/abort.rs (revision `run`) ... FAILED -tests/actual_tests_bless/failing_executable.rs (revision `run`) ... FAILED -tests/actual_tests_bless/revisioned_executable.rs (revision `run.run`) ... ok -tests/actual_tests_bless/revisioned_executable.rs (revision `panic.run`) ... FAILED -tests/actual_tests_bless/revisioned_executable_panic.rs (revision `run.run`) ... FAILED -tests/actual_tests_bless/revisioned_executable_panic.rs (revision `panic.run`) ... ok -tests/actual_tests_bless/run_panic.rs (revision `run`) ... ok -tests/actual_tests_bless/rustfix-fail-revisions.a.fixed ... FAILED -tests/actual_tests_bless/rustfix-fail-revisions.b.fixed ... FAILED -tests/actual_tests_bless/rustfix-fail.fixed ... FAILED + +FAILED TEST: tests/actual_tests_bless/abort.rs (revision `run`) +command: "$CMD" + +error: test got signal: 6 (SIGABRT), but expected 0 + = note: the test was expected to run successfully + +full stderr: + +full stdout: + + FAILED TEST: tests/actual_tests_bless/aux_build_not_found.rs command: canonicalizing path `tests/actual_tests_bless/auxiliary/aasdflkjasdlfjasdlfkjasdf` @@ -619,6 +631,27 @@ full stdout: +FAILED TEST: tests/actual_tests_bless/failing_executable.rs (revision `run`) +command: "$CMD" + +error: test got exit status: 101, but expected 0 + --> tests/actual_tests_bless/failing_executable.rs:4:5 + | +4 | assert_eq!(5, 6); + | ^^^^^^^^^^^^^^^^^ assertion `left == right` failed + | + +full stderr: +thread 'main' panicked at tests/actual_tests_bless/failing_executable.rs: +assertion `left == right` failed + left: 5 + right: 6 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + +full stdout: + + + FAILED TEST: tests/actual_tests_bless/no_main.rs command: "rustc" "--error-format=json" "--crate-type=lib" "--out-dir" "$TMP "tests/actual_tests_bless/no_main.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" @@ -750,6 +783,37 @@ full stdout: +FAILED TEST: tests/actual_tests_bless/revisioned_executable.rs (revision `panic.run`) +command: "$CMD" + +error: test got exit status: 0, but expected 101 + = note: the test was expected to panic + +full stderr: + +full stdout: + + + +FAILED TEST: tests/actual_tests_bless/revisioned_executable_panic.rs (revision `run.run`) +command: "$CMD" + +error: test got exit status: 101, but expected 0 + --> tests/actual_tests_bless/revisioned_executable_panic.rs + | +6 | panic!() + | ^^^^^^^^ explicit panic + | + +full stderr: +thread 'main' panicked at tests/actual_tests_bless/revisioned_executable_panic.rs: +explicit panic +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + +full stdout: + + + FAILED TEST: tests/actual_tests_bless/revisions_bad.rs (revision `bar`) command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/revisions_bad.rs" "--cfg=bar" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" @@ -782,6 +846,99 @@ full stdout: +FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.a.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1" + +error: test got exit status: 1, but expected 0 + --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9 + | +2 | #![deny(warnings)] + | ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't + | + +full stderr: +error: path statement drops value + --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:11:5 + | +11 | x; + | ^^ help: use `drop` to clarify the intent: `drop(x);` + | +note: the lint level is defined here + --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9 + | +2 | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(path_statements)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + + +full stdout: + + + +FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.b.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1" + +error: test got exit status: 1, but expected 0 + --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9 + | +2 | #![deny(warnings)] + | ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't + | + +full stderr: +error: path statement drops value + --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:11:5 + | +11 | x; + | ^^ help: use `drop` to clarify the intent: `drop(x);` + | +note: the lint level is defined here + --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9 + | +2 | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(path_statements)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + + +full stdout: + + + +FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_1" + +error: test got exit status: 1, but expected 0 + --> tests/actual_tests_bless/rustfix-fail.fixed:1:9 + | +1 | #![deny(warnings)] + | ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't + | + +full stderr: +error: path statement drops value + --> tests/actual_tests_bless/rustfix-fail.fixed:10:5 + | +10 | x; + | ^^ help: use `drop` to clarify the intent: `drop(x);` + | +note: the lint level is defined here + --> tests/actual_tests_bless/rustfix-fail.fixed:1:9 + | +1 | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(path_statements)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + + +full stdout: + + + FAILED TEST: tests/actual_tests_bless/unicode.rs command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/unicode.rs" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" @@ -896,187 +1053,30 @@ error: aborting due to 2 previous errors full stdout: - -FAILED TEST: tests/actual_tests_bless/abort.rs (revision `run`) -command: "$CMD" - -error: test got signal: 6 (SIGABRT), but expected 0 - = note: the test was expected to run successfully - -full stderr: - -full stdout: - - - -FAILED TEST: tests/actual_tests_bless/failing_executable.rs (revision `run`) -command: "$CMD" - -error: test got exit status: 101, but expected 0 - --> tests/actual_tests_bless/failing_executable.rs:4:5 - | -4 | assert_eq!(5, 6); - | ^^^^^^^^^^^^^^^^^ assertion `left == right` failed - | - -full stderr: -thread 'main' panicked at tests/actual_tests_bless/failing_executable.rs: -assertion `left == right` failed - left: 5 - right: 6 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -full stdout: - - - -FAILED TEST: tests/actual_tests_bless/revisioned_executable.rs (revision `panic.run`) -command: "$CMD" - -error: test got exit status: 0, but expected 101 - = note: the test was expected to panic - -full stderr: - -full stdout: - - - -FAILED TEST: tests/actual_tests_bless/revisioned_executable_panic.rs (revision `run.run`) -command: "$CMD" - -error: test got exit status: 101, but expected 0 - --> tests/actual_tests_bless/revisioned_executable_panic.rs - | -6 | panic!() - | ^^^^^^^^ explicit panic - | - -full stderr: -thread 'main' panicked at tests/actual_tests_bless/revisioned_executable_panic.rs: -explicit panic -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -full stdout: - - - -FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.a.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.a.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1" - -error: test got exit status: 1, but expected 0 - --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9 - | -2 | #![deny(warnings)] - | ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't - | - -full stderr: -error: path statement drops value - --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:11:5 - | -11 | x; - | ^^ help: use `drop` to clarify the intent: `drop(x);` - | -note: the lint level is defined here - --> tests/actual_tests_bless/rustfix-fail-revisions.a.fixed:2:9 - | -2 | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(path_statements)]` implied by `#[deny(warnings)]` - -error: aborting due to 1 previous error - - -full stdout: - - - -FAILED TEST: tests/actual_tests_bless/rustfix-fail-revisions.b.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail-revisions.b.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_revisions_1" - -error: test got exit status: 1, but expected 0 - --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9 - | -2 | #![deny(warnings)] - | ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't - | - -full stderr: -error: path statement drops value - --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:11:5 - | -11 | x; - | ^^ help: use `drop` to clarify the intent: `drop(x);` - | -note: the lint level is defined here - --> tests/actual_tests_bless/rustfix-fail-revisions.b.fixed:2:9 - | -2 | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(path_statements)]` implied by `#[deny(warnings)]` - -error: aborting due to 1 previous error - - -full stdout: - - - -FAILED TEST: tests/actual_tests_bless/rustfix-fail.fixed -command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests_bless/rustfix-fail.fixed" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail.rlib" "--extern" "basic_fail=$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug/libbasic_fail-$HASH.rmeta" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "-L" "$DIR/tests/integrations/basic-fail/../../../target/$TMP/$TRIPLE/debug" "--edition" "2021" "--crate-name" "__rustfix_fail_1" - -error: test got exit status: 1, but expected 0 - --> tests/actual_tests_bless/rustfix-fail.fixed:1:9 - | -1 | #![deny(warnings)] - | ^^^^^^^^ after rustfix is applied, all errors should be gone, but weren't - | - -full stderr: -error: path statement drops value - --> tests/actual_tests_bless/rustfix-fail.fixed:10:5 - | -10 | x; - | ^^ help: use `drop` to clarify the intent: `drop(x);` - | -note: the lint level is defined here - --> tests/actual_tests_bless/rustfix-fail.fixed:1:9 - | -1 | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(path_statements)]` implied by `#[deny(warnings)]` - -error: aborting due to 1 previous error - - -full stdout: - - FAILURES: + tests/actual_tests_bless/abort.rs (revision run) tests/actual_tests_bless/aux_build_not_found.rs tests/actual_tests_bless/aux_proc_macro_misuse.rs tests/actual_tests_bless/aux_proc_macro_no_main.rs tests/actual_tests_bless/compile_flags_quotes.rs tests/actual_tests_bless/compiletest-rs-command.rs + tests/actual_tests_bless/failing_executable.rs (revision run) tests/actual_tests_bless/no_main.rs tests/actual_tests_bless/no_main_manual.rs tests/actual_tests_bless/no_test.rs tests/actual_tests_bless/non_top_level_configs.rs tests/actual_tests_bless/pass_with_annotation.rs tests/actual_tests_bless/revised_revision.rs - tests/actual_tests_bless/revisions_bad.rs (revision bar) - tests/actual_tests_bless/unicode.rs - tests/actual_tests_bless/unknown_revision.rs - tests/actual_tests_bless/unknown_revision2.rs - tests/actual_tests_bless/wrong_diagnostic_code.rs - tests/actual_tests_bless/abort.rs (revision run) - tests/actual_tests_bless/failing_executable.rs (revision run) tests/actual_tests_bless/revisioned_executable.rs (revision panic.run) tests/actual_tests_bless/revisioned_executable_panic.rs (revision run.run) + tests/actual_tests_bless/revisions_bad.rs (revision bar) tests/actual_tests_bless/rustfix-fail-revisions.a.fixed tests/actual_tests_bless/rustfix-fail-revisions.b.fixed tests/actual_tests_bless/rustfix-fail.fixed + tests/actual_tests_bless/unicode.rs + tests/actual_tests_bless/unknown_revision.rs + tests/actual_tests_bless/unknown_revision2.rs + tests/actual_tests_bless/wrong_diagnostic_code.rs test result: FAIL. 23 failed; 24 passed; 3 ignored @@ -1084,8 +1084,8 @@ Building dependencies ... ok tests/actual_tests_bless_yolo/revisions_bad.rs (revision `foo`) ... ok tests/actual_tests_bless_yolo/revisions_bad.rs (revision `bar`) ... ok tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.rs ... ok -tests/actual_tests_bless_yolo/rustfix-multiple-fail.rs ... ok tests/actual_tests_bless_yolo/rustfix-maybe-incorrect.fixed ... ok +tests/actual_tests_bless_yolo/rustfix-multiple-fail.rs ... ok tests/actual_tests_bless_yolo/rustfix-multiple-fail.1.fixed ... ok tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed ... FAILED tests/actual_tests_bless_yolo/rustfix-multiple-fail.3.fixed ... ok diff --git a/tests/integrations/basic/Cargo.stdout b/tests/integrations/basic/Cargo.stdout index b7182e6c..1de6f886 100644 --- a/tests/integrations/basic/Cargo.stdout +++ b/tests/integrations/basic/Cargo.stdout @@ -12,36 +12,36 @@ Building aux file tests/actual_tests/auxiliary/proc_macro_attr.rs ... ok tests/actual_tests/aux_attr_proc_macro.rs ... ok Building aux file tests/actual_tests/auxiliary/derive_proc_macro.rs ... ok tests/actual_tests/aux_derive.rs ... ok +tests/actual_tests/aux_derive.fixed ... ok Building aux file tests/actual_tests/auxiliary/the_proc_macro.rs ... ok tests/actual_tests/aux_proc_macro.rs ... ok tests/actual_tests/dep_derive.rs ... ok +tests/actual_tests/dep_derive.rs (revision `run`) ... ok tests/actual_tests/error_above.rs ... ok tests/actual_tests/executable.rs ... ok +tests/actual_tests/executable.rs (revision `run`) ... ok tests/actual_tests/foomp-rustfix.rs ... ok +tests/actual_tests/foomp-rustfix.fixed ... ok tests/actual_tests/foomp.rs ... ok tests/actual_tests/joined_above.rs ... ok +tests/actual_tests/joined_above.fixed ... ok tests/actual_tests/joined_below.rs ... ok +tests/actual_tests/joined_below.fixed ... ok tests/actual_tests/joined_mixed.rs ... ok +tests/actual_tests/joined_mixed.fixed ... ok tests/actual_tests/mac_span.rs ... ok +tests/actual_tests/mac_span.fixed ... ok tests/actual_tests/match_diagnostic_code.rs ... ok +tests/actual_tests/match_diagnostic_code.fixed ... ok tests/actual_tests/no_rustfix.rs ... ok tests/actual_tests/rustfix-multiple.rs ... ok +tests/actual_tests/rustfix-multiple.1.fixed ... ok +tests/actual_tests/rustfix-multiple.2.fixed ... ok tests/actual_tests/stdin.rs ... ok +tests/actual_tests/stdin.rs (revision `run`) ... ok tests/actual_tests/unicode.rs ... ok tests/actual_tests/windows_paths.rs ... ok tests/actual_tests/subdir/aux_proc_macro.rs ... ok -tests/actual_tests/aux_derive.fixed ... ok -tests/actual_tests/dep_derive.rs (revision `run`) ... ok -tests/actual_tests/executable.rs (revision `run`) ... ok -tests/actual_tests/foomp-rustfix.fixed ... ok -tests/actual_tests/joined_above.fixed ... ok -tests/actual_tests/joined_below.fixed ... ok -tests/actual_tests/joined_mixed.fixed ... ok -tests/actual_tests/mac_span.fixed ... ok -tests/actual_tests/match_diagnostic_code.fixed ... ok -tests/actual_tests/rustfix-multiple.1.fixed ... ok -tests/actual_tests/rustfix-multiple.2.fixed ... ok -tests/actual_tests/stdin.rs (revision `run`) ... ok test result: ok. 31 passed