diff --git a/xtask/src/main.rs b/xtask/src/main.rs index ba0ed79acf..7c2e587a7d 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -269,6 +269,8 @@ fn cmd_test() -> Result<(), String> { /// [`cmd_test`] for the packages `select` picks (`--workspace` or `-p` ids), shown as `shown`; /// with `part`, only that part's share of their tests (xtask/src/shards.rs), which needs nextest. +/// A part runs its counted share, then its pinned tests, each with nextest's default thread count. +/// Every run finishes before the first error is returned. fn test_packages(select: &[String], shown: &str, part: Option) -> Result<(), String> { const TARGETS: [&str; 3] = ["--lib", "--bins", "--tests"]; if let Some(part) = part { @@ -294,32 +296,12 @@ fn test_packages(select: &[String], shown: &str, part: Option) -> let quoted = args.iter().map(|a| if a.contains(' ') { format!("'{a}'") } else { a.clone() }).collect::>().join(" "); (c, format!("cargo nextest run {shown} --lib --bins --tests {quoted}")) }; - let cpus = std::thread::available_parallelism().map_or(1, usize::from); - let pinned_threads = part.pins().max(1).min(cpus.saturating_sub(1).max(1)); - let counted_threads = if part.pins() == 0 { cpus } else { cpus.saturating_sub(pinned_threads).max(1) }; - let mut runs = part.runs().into_iter(); - let mut counted = runs.next().ok_or_else(|| format!("cargo nextest run {shown}: no counted run"))?; - counted.extend(["--test-threads".to_owned(), counted_threads.to_string()]); - let pinned = runs - .next() - .map(|mut args| { - args.extend(["--test-threads".to_owned(), pinned_threads.to_string()]); - let (mut c, what) = command(args); - eprintln!("$ {what}"); - c.spawn().map(|child| (child, what.clone())).map_err(|e| format!("{what}: failed to spawn: {e}")) - }) - .transpose()?; - let (c, what) = command(counted); - let counted_result = run(c, &what); - let pinned_result = match pinned { - None => Ok(()), - Some((mut child, what)) => match child.wait() { - Ok(status) if status.success() => Ok(()), - Ok(status) => Err(format!("{what}: exited with {status}")), - Err(e) => Err(format!("{what}: failed to wait: {e}")), - }, - }; - return counted_result.and(pinned_result); + let mut result = Ok(()); + for args in part.runs() { + let (c, what) = command(args); + result = result.and(run(c, &what)); + } + return result; } let mut c = cargo(); if has_nextest() { diff --git a/xtask/src/shards.rs b/xtask/src/shards.rs index 1baede03bd..29f5281a84 100644 --- a/xtask/src/shards.rs +++ b/xtask/src/shards.rs @@ -15,7 +15,8 @@ //! part builds the same tests and runs its share of them: the tests its `pinned` list names, and //! every other test of the crates by nextest's counted partition (`--partition count:/` //! with the pinned tests filtered out, so each of them runs once). The doctests and the i18n -//! report run on part 1. +//! report run on part 1. A part runs its counted share and then its pinned tests, each with +//! nextest's default thread count, and runs both even when the first fails. use std::collections::{BTreeMap, BTreeSet}; @@ -51,8 +52,8 @@ impl Split { } } -/// vectorcraft-ui-egui's tests, on two shards. The pinned tests took 23 to 74 s each in CI -/// (run 46256086023), and each part's pinned tests add up to about 120 to 130 s. +/// vectorcraft-ui-egui's tests, on two shards. The pinned tests took 18 to 44 s each in CI +/// run 46267439238. pub static UI_EGUI: Split = Split { crates: &["vectorcraft-ui-egui"], pinned: &[ @@ -60,11 +61,11 @@ pub static UI_EGUI: Split = Split { "panels::actions::tests_edits::every_listed_menu_item_runs_from_the_menu_what_its_step_holds", "dialogs::revolve::tests::a_3d_row_sets_its_param_previews_and_applies_in_one_step", "shortcuts::tests::alt_chords_type_special_characters_while_editing_text", + "menus::tests::help_f1_opens_discover_without_a_document", ], &[ "palette::tests::the_palette_leaves_out_the_commands_a_pick_cannot_run", "chrome::tests::the_control_bar_leaves_members_out_in_its_priority_order", - "menus::tests::help_f1_opens_discover_without_a_document", ], ], }; @@ -104,11 +105,6 @@ pub struct Part { } impl Part { - /// The number of tests this part pins. - pub fn pins(&self) -> usize { - self.split.pinned[self.index - 1].len() - } - /// The arguments `cargo nextest run` takes after the package and target selection, once for /// each run this part makes: the counted share (`--partition count:/`, with every /// pinned test filtered out when the split pins any), then the tests this part pins.