diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/ui_test | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/ui_test')
-rw-r--r-- | vendor/ui_test/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/ui_test/Cargo.toml | 2 | ||||
-rw-r--r-- | vendor/ui_test/src/config.rs | 9 | ||||
-rw-r--r-- | vendor/ui_test/src/lib.rs | 152 | ||||
-rw-r--r-- | vendor/ui_test/src/parser.rs | 37 |
5 files changed, 125 insertions, 77 deletions
diff --git a/vendor/ui_test/.cargo-checksum.json b/vendor/ui_test/.cargo-checksum.json index f76028178..b15928ec4 100644 --- a/vendor/ui_test/.cargo-checksum.json +++ b/vendor/ui_test/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CONTRIBUTING.md":"e030432e8f8830a0c6e6fb783dcae14c19d20f770d4e2e274a48693748d7bd68","Cargo.toml":"e5ea7eaf370e6c185588d14835b2168b186895729431930452542b7fff4d72a2","README.md":"c846bb425130a0e3542797ef7d7cdc0dc508d1cb6e8db812821ee8d053d97f35","src/cmd.rs":"5a095efafc7e015f5f27383100cae9d553e8d9f18b5fd298d3f0192bff90d620","src/config.rs":"5c71a3ad1f4c404238b9066cfade4f4dcf1b7f55f9c2ed291bdc317413415f40","src/dependencies.rs":"06083293ea5243e424da7b7af0967ee03cd1270e160edb52e3cb00231f1dc85c","src/diff.rs":"6d399e7a6eb354aa420d683bdab4fcd27ab5b7bcfe6787d515fd579429b22f99","src/error.rs":"8fdb38126aafb5bbbb8e8ad0f2af87f0d78ced23cbc5872672a8669104177dc1","src/github_actions.rs":"81a78130b4e22ca703433f4bec90be4191711c1ffdc1e59dd136f678a167ce2c","src/lib.rs":"d1d2afd1e468cda79b5811178220030ba771db8e1800e8dfb434d061614dc2fa","src/mode.rs":"4565cb37f7399789fdd46dd73de20b58a25762a1a7543cfc06c04bb972622a56","src/parser.rs":"0a3c549ff3752c03c2fcf767a375e30a7c97a80b4263c00abe5e5d7025dfd5a8","src/parser/tests.rs":"c6e2fa9587791daab294b87f3fabd01d908885175e4a94182d960e5e7e86664f","src/rustc_stderr.rs":"3771e4f6716b6a0d81f2454750f9b6d65c6c0faf199a33b396e78a04a4512e5a","src/status_emitter.rs":"f9e5fad26a2a702147ec1d20b044cb2d96c6aa24853c03387c61ca2748f6a2da","src/tests.rs":"67b56d2135bb106de6660abd8889e7236b8d5c0619a20ccaf6ceb32bcd372668","tests/integration.rs":"da0a1629c5c65253eb58a56a68fb98d8e369f8a069326a0c8b0589e408450c0f"},"package":"24a2e70adc9d18b9b4dd80ea57aeec447103c6fbb354a07c080adad451c645e1"}
\ No newline at end of file +{"files":{"CONTRIBUTING.md":"e030432e8f8830a0c6e6fb783dcae14c19d20f770d4e2e274a48693748d7bd68","Cargo.toml":"915e699eec2835eca914023a7796b74c6a11ca3be118d88a676c380b066c202a","README.md":"c846bb425130a0e3542797ef7d7cdc0dc508d1cb6e8db812821ee8d053d97f35","src/cmd.rs":"5a095efafc7e015f5f27383100cae9d553e8d9f18b5fd298d3f0192bff90d620","src/config.rs":"356ebc347fdecdc4d17755df10e4bc328c70e6bcfa812a2bc7433eadc73c5028","src/dependencies.rs":"06083293ea5243e424da7b7af0967ee03cd1270e160edb52e3cb00231f1dc85c","src/diff.rs":"6d399e7a6eb354aa420d683bdab4fcd27ab5b7bcfe6787d515fd579429b22f99","src/error.rs":"8fdb38126aafb5bbbb8e8ad0f2af87f0d78ced23cbc5872672a8669104177dc1","src/github_actions.rs":"81a78130b4e22ca703433f4bec90be4191711c1ffdc1e59dd136f678a167ce2c","src/lib.rs":"e7d295b40a4e07725f94428c4dc3d4525bb3bd46ca6b1547d3445d5e58724c33","src/mode.rs":"4565cb37f7399789fdd46dd73de20b58a25762a1a7543cfc06c04bb972622a56","src/parser.rs":"73b1b15f5333f8d428db5f6fc2443e3905280e10126aa16c03ed4d8fc9bb371b","src/parser/tests.rs":"c6e2fa9587791daab294b87f3fabd01d908885175e4a94182d960e5e7e86664f","src/rustc_stderr.rs":"3771e4f6716b6a0d81f2454750f9b6d65c6c0faf199a33b396e78a04a4512e5a","src/status_emitter.rs":"f9e5fad26a2a702147ec1d20b044cb2d96c6aa24853c03387c61ca2748f6a2da","src/tests.rs":"67b56d2135bb106de6660abd8889e7236b8d5c0619a20ccaf6ceb32bcd372668","tests/integration.rs":"da0a1629c5c65253eb58a56a68fb98d8e369f8a069326a0c8b0589e408450c0f"},"package":"c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"}
\ No newline at end of file diff --git a/vendor/ui_test/Cargo.toml b/vendor/ui_test/Cargo.toml index df5908843..9f172f3d1 100644 --- a/vendor/ui_test/Cargo.toml +++ b/vendor/ui_test/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.63" name = "ui_test" -version = "0.11.6" +version = "0.11.7" description = "A test framework for testing rustc diagnostics output" readme = "README.md" license = "MIT OR Apache-2.0" diff --git a/vendor/ui_test/src/config.rs b/vendor/ui_test/src/config.rs index 6f24cce90..8d92fe8d8 100644 --- a/vendor/ui_test/src/config.rs +++ b/vendor/ui_test/src/config.rs @@ -82,7 +82,10 @@ impl Config { dependencies_crate_manifest_path: None, dependency_builder: CommandBuilder::cargo(), num_test_threads: std::thread::available_parallelism().unwrap(), - out_dir: std::env::current_dir().unwrap().join("target/ui"), + out_dir: std::env::var_os("CARGO_TARGET_DIR") + .map(PathBuf::from) + .unwrap_or_else(|| std::env::current_dir().unwrap().join("target")) + .join("ui"), edition: Some("2021".into()), } } @@ -128,7 +131,9 @@ impl Config { .push((Regex::new(pattern).unwrap().into(), replacement.as_ref())); } - pub(crate) fn build_dependencies_and_link_them(&mut self) -> Result<()> { + /// Compile dependencies and make sure `Config::program` contains the right flags + /// to find the dependencies. + pub fn build_dependencies_and_link_them(&mut self) -> Result<()> { let dependencies = build_dependencies(self)?; for (name, artifacts) in dependencies.dependencies { for dependency in artifacts { diff --git a/vendor/ui_test/src/lib.rs b/vendor/ui_test/src/lib.rs index 7837d0e62..1420e2881 100644 --- a/vendor/ui_test/src/lib.rs +++ b/vendor/ui_test/src/lib.rs @@ -11,7 +11,7 @@ use bstr::ByteSlice; pub use color_eyre; use color_eyre::eyre::{eyre, Result}; -use crossbeam_channel::unbounded; +use crossbeam_channel::{unbounded, Receiver, Sender}; use parser::{ErrorMatch, Revisioned}; use regex::bytes::Regex; use rustc_stderr::{Diagnostics, Level, Message}; @@ -179,15 +179,11 @@ pub fn run_tests_generic( config.build_dependencies_and_link_them()?; - // A channel for files to process - let (submit, receive) = unbounded(); - let mut results = vec![]; - thread::scope(|s| -> Result<()> { - // Create a thread that is in charge of walking the directory and submitting jobs. - // It closes the channel when it is done. - s.spawn(|| { + run_and_collect( + config.num_test_threads.get(), + |submit| { let mut todo = VecDeque::new(); todo.push_back(config.root_dir.clone()); while let Some(path) = todo.pop_front() { @@ -210,73 +206,51 @@ pub fn run_tests_generic( submit.send(path).unwrap(); } } - // There will be no more jobs. This signals the workers to quit. - // (This also ensures `submit` is moved into this closure.) - drop(submit); - }); - - // A channel for the messages emitted by the individual test threads. - // Used to produce live updates while running the tests. - let (finished_files_sender, finished_files_recv) = unbounded::<TestRun>(); - - s.spawn(|| { + }, + |receive, finished_files_sender| -> Result<()> { + for path in receive { + let maybe_config; + let config = match per_file_config(&config, &path) { + None => &config, + Some(config) => { + maybe_config = config; + &maybe_config + } + }; + let result = match std::panic::catch_unwind(|| parse_and_test_file(&path, config)) { + Ok(res) => res, + Err(err) => { + finished_files_sender.send(TestRun { + result: TestResult::Errored { + command: Command::new("<unknown>"), + errors: vec![Error::Bug( + *Box::<dyn std::any::Any + Send + 'static>::downcast::<String>( + err, + ) + .unwrap(), + )], + stderr: vec![], + }, + path, + revision: String::new(), + })?; + continue; + } + }; + for result in result { + finished_files_sender.send(result)?; + } + } + Ok(()) + }, + |finished_files_recv| { for run in finished_files_recv { status_emitter.test_result(&run.path, &run.revision, &run.result); results.push(run); } - }); - - let mut threads = vec![]; - - // Create N worker threads that receive files to test. - for _ in 0..config.num_test_threads.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 { - let maybe_config; - let config = match per_file_config(&config, &path) { - None => &config, - Some(config) => { - maybe_config = config; - &maybe_config - } - }; - let result = - match std::panic::catch_unwind(|| parse_and_test_file(&path, config)) { - Ok(res) => res, - Err(err) => { - finished_files_sender.send(TestRun { - result: TestResult::Errored { - command: Command::new("<unknown>"), - errors: vec![Error::Bug( - *Box::<dyn std::any::Any + Send + 'static>::downcast::< - String, - >(err) - .unwrap(), - )], - stderr: vec![], - }, - path, - revision: String::new(), - })?; - continue; - } - }; - for result in result { - finished_files_sender.send(result)?; - } - } - Ok(()) - })); - } - - for thread in threads { - thread.join().unwrap()?; - } - Ok(()) - })?; + }, + )?; let mut failures = vec![]; let mut succeeded = 0; @@ -309,6 +283,43 @@ pub fn run_tests_generic( } } +/// 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<SUBMISSION: Send, RESULT: Send>( + num_threads: usize, + submitter: impl FnOnce(Sender<SUBMISSION>) + Send, + runner: impl Sync + Fn(&Receiver<SUBMISSION>, Sender<RESULT>) -> Result<()>, + collector: impl FnOnce(Receiver<RESULT>) + Send, +) -> Result<()> { + // A channel for files to process + let (submit, receive) = unbounded(); + + thread::scope(|s| { + // Create a thread that is in charge of walking the directory and submitting jobs. + // It closes the channel when it is done. + s.spawn(|| submitter(submit)); + + // A channel for the messages emitted by the individual test threads. + // Used to produce live updates while running the tests. + let (finished_files_sender, finished_files_recv) = unbounded(); + + s.spawn(|| collector(finished_files_recv)); + + let mut threads = vec![]; + + // Create N worker threads that receive files to test. + for _ in 0..num_threads { + let finished_files_sender = finished_files_sender.clone(); + threads.push(s.spawn(|| runner(&receive, finished_files_sender))); + } + + for thread in threads { + thread.join().unwrap()?; + } + Ok(()) + }) +} + fn parse_and_test_file(path: &Path, config: &Config) -> Vec<TestRun> { let comments = match parse_comments_in_file(path) { Ok(comments) => comments, @@ -696,6 +707,7 @@ fn run_rustfix( revisioned: std::iter::once(( vec![], Revisioned { + line: 0, ignore: vec![], only: vec![], stderr_per_bitwidth: false, diff --git a/vendor/ui_test/src/parser.rs b/vendor/ui_test/src/parser.rs index d2b510e1b..b041fb812 100644 --- a/vendor/ui_test/src/parser.rs +++ b/vendor/ui_test/src/parser.rs @@ -18,7 +18,7 @@ mod tests; /// get processed by their respective use sites. #[derive(Default, Debug)] pub(crate) struct Comments { - /// List of revision names to execute. Can only be speicified once + /// List of revision names to execute. Can only be specified once pub revisions: Option<Vec<String>>, /// Comments that are only available under specific revisions. /// The defaults are in key `vec![]` @@ -78,6 +78,9 @@ impl Comments { #[derive(Default, Debug)] /// Comments that can be filtered for specific revisions. pub(crate) struct Revisioned { + /// The line in which this revisioned item was first added. + /// Used for reporting errors on unknown revisions. + pub line: usize, /// Don't run this test if any of these filters apply pub ignore: Vec<Condition>, /// Only run this test if all of these filters apply @@ -210,6 +213,27 @@ impl Comments { }), } } + if let Some(revisions) = &parser.comments.revisions { + for (key, revisioned) in &parser.comments.revisioned { + for rev in key { + if !revisions.contains(rev) { + parser.errors.push(Error::InvalidComment { + msg: format!("the revision `{rev}` is not known"), + line: revisioned.line, + }) + } + } + } + } else { + for (key, revisioned) in &parser.comments.revisioned { + if !key.is_empty() { + parser.errors.push(Error::InvalidComment { + msg: "there are no revisions in this test".into(), + line: revisioned.line, + }) + } + } + } if parser.errors.is_empty() { Ok(parser.comments) } else { @@ -332,10 +356,17 @@ impl CommentParser<Comments> { revisions: Vec<String>, f: impl FnOnce(&mut CommentParser<&mut Revisioned>), ) { + let line = self.line; let mut this = CommentParser { errors: std::mem::take(&mut self.errors), - line: self.line, - comments: self.revisioned.entry(revisions).or_default(), + line, + comments: self + .revisioned + .entry(revisions) + .or_insert_with(|| Revisioned { + line, + ..Default::default() + }), }; f(&mut this); self.errors = this.errors; |