mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
CI: the two ui-egui shards take about the same time
Each ui-egui part ran its pinned tests with --test-threads 3 beside its counted share with --test-threads 1. On the 4-CPU runners the pinned tests finished in about 40 s, and the counted share of about 2,640 tests then ran on one thread for 9 to 12 minutes (run 46267439238). A part now runs its counted share and then its pinned tests, one after the other, each with nextest's default thread count. The help F1 test moves to part 1's pinned list, which leaves the two parts with closer test totals.
This commit is contained in:
1 parent
3ad283b9b0
commit
6a6fa5056c
2 files changed
+13
-35
No files matched your search
+8
-26
@@ -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<shards::Part>) -> 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<shards::Part>) ->
|
||||
let quoted = args.iter().map(|a| if a.contains(' ') { format!("'{a}'") } else { a.clone() }).collect::<Vec<_>>().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() {
|
||||
|
||||
+5
-9
@@ -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:<k>/<n>`
|
||||
//! 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:<k>/<n>`, with every
|
||||
/// pinned test filtered out when the split pins any), then the tests this part pins.
|
||||
|
||||
Reference in new issue
Block a user