Merge main into feat/scripts-doc-defaults

This commit is contained in:
dotCooCoo committed 2026-11-29 06:45:39 -08:00
commit c10031537b
5 files changed
+365 -42

No files matched your search

+10 -5
View File
@@ -38,27 +38,32 @@
"applicability": "required"
},
{
"name": "gate / test 1/5 (ubuntu-24.04)",
"name": "gate / test 1/6 (ubuntu-24.04)",
"app_id": 15368,
"applicability": "required"
},
{
"name": "gate / test 2/5 (ubuntu-24.04)",
"name": "gate / test 2/6 (ubuntu-24.04)",
"app_id": 15368,
"applicability": "required"
},
{
"name": "gate / test 3/5 (ubuntu-24.04)",
"name": "gate / test 3/6 (ubuntu-24.04)",
"app_id": 15368,
"applicability": "required"
},
{
"name": "gate / test 4/5 (ubuntu-24.04)",
"name": "gate / test 4/6 (ubuntu-24.04)",
"app_id": 15368,
"applicability": "required"
},
{
"name": "gate / test 5/5 (ubuntu-24.04)",
"name": "gate / test 5/6 (ubuntu-24.04)",
"app_id": 15368,
"applicability": "required"
},
{
"name": "gate / test 6/6 (ubuntu-24.04)",
"app_id": 15368,
"applicability": "required"
},
+6 -5
View File
@@ -39,11 +39,12 @@ jobs:
dev-strip: true
# The workspace crates also build without line tables. A panic still names its file and line.
dev-debug: "0"
# Five legs instead of one: shards 1 to 4 each build and run the tests of their own crates,
# and shard 5 runs the other `cargo xtask ci` steps (xtask/src/shards.rs). `gate (<os>)`
# passes only when all five did. On pushes to main, a `cache warm` leg builds what every
# shard builds and saves the dependency cache.
test-shards: 5
# Six legs instead of one: shards 1 and 2 each build vectorcraft-ui-egui's tests and run
# half of them, shards 3 to 5 each build and run the tests of their own crates, and shard 6
# runs the other `cargo xtask ci` steps (xtask/src/shards.rs). `gate (<os>)` passes only
# when all six did. On pushes to main, a `cache warm` leg builds what every shard builds and
# saves the dependency cache.
test-shards: 6
shard-command: cargo xtask ci shard
warm-command: cargo xtask ci warm
# The dependency cache also keeps the compiled workspace crates and test executables, so a
+5 -1
View File
@@ -78,9 +78,13 @@ Read on 2026-11-24; re-read anything that may have moved before `nightly-signer`
| `manual_actors` / `automatic_signer_actors` | the five release managers / `[]` | release-managers team (id 19837241) members who can push; equals the producer caller's `manual-actors` |
| `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist |
| `platforms` | three rows | Learning Machines stable identities (Windows Authenticode publisher subject, Linux OpenPGP fingerprint, Apple Developer ID team `DJ6XS33FX8`) |
| `candidate_policy.required_workflows` | CI (`ci.yml`, workflow `380135806`), 8 jobs | Workflow list API; jobs that succeeded on recent main push runs |
| `candidate_policy.required_workflows` | CI (`ci.yml`, workflow `380135806`), 9 jobs | Workflow list API; jobs that succeeded on recent main push runs |
| `candidate_policy.sonar` | `storytold` / `storytold_vectorcraft`, app `12526` | `sonar-project.properties`; the SonarCloud check on main commits |
The signer reads the policy from `nightly-signer`, so a candidate whose CI ran six test shards
(`test 1/6` to `test 6/6`) is admitted only after `nightly-signer` advances to a main commit with
this policy. Candidates whose CI ran five shards should be signed before that advance.
## Ownership and interface
- `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named
+73 -11
View File
@@ -23,7 +23,7 @@ mod version;
mod web_fonts;
use std::path::{Path, PathBuf};
use std::process::{Command, ExitCode};
use std::process::{Command, ExitCode, Stdio};
const USAGE: &str = "\
usage: cargo xtask <command>
@@ -264,12 +264,63 @@ fn has_nextest() -> bool {
/// The workspace's unit and integration tests, without examples (clippy still checks those).
/// nextest runs each test in its own process, in parallel across all test binaries.
fn cmd_test() -> Result<(), String> {
test_packages(&["--workspace".to_owned()], "--workspace")
test_packages(&["--workspace".to_owned()], "--workspace", None)
}
/// [`cmd_test`] for the packages `select` picks (`--workspace` or `-p` ids), shown as `shown`.
fn test_packages(select: &[String], shown: &str) -> 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.
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 {
if !has_nextest() {
return Err(format!("cargo nextest run {shown}: a shard that runs part of a crate's tests needs cargo-nextest"));
}
let mut c = cargo();
c.args(["nextest", "list", "--color", "never", "--message-format", "json"]).args(select).args(TARGETS);
let out = c.stderr(Stdio::inherit()).output().map_err(|e| format!("cargo nextest list {shown}: failed to spawn: {e}"))?;
if !out.status.success() {
return Err(format!("cargo nextest list {shown}: exited with {}", out.status));
}
let missing = part.missing_pins(&String::from_utf8_lossy(&out.stdout)).map_err(|e| format!("cargo nextest list {shown}: {e}"))?;
if !missing.is_empty() {
return Err(format!(
"cargo nextest list {shown}: no test has the full name of pinned test(s) {} (update `pinned` in xtask/src/shards.rs)",
missing.join(", ")
));
}
let command = |args: Vec<String>| {
let mut c = cargo();
c.args(["nextest", "run"]).args(select).args(TARGETS).args(&args);
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 c = cargo();
if has_nextest() {
c.args(["nextest", "run"]).args(select).args(TARGETS);
@@ -307,7 +358,8 @@ fn cmd_ci() -> Result<(), String> {
/// `cargo xtask ci shard`: shard `GATE_SHARD` of `GATE_SHARDS` (1-based, as the shared gate
/// workflow sets them). A test shard runs the shard checks, then the tests and doctests of its
/// crates, and the i18n report where it tests vectorcraft-ui-egui. The checks shard runs every
/// crates, and the i18n report where it tests vectorcraft-ui-egui; a part of a split runs its
/// share of the tests, and only part 1 the doctests and the report. The checks shard runs every
/// other `ci` step and the shard checks.
fn cmd_ci_shard() -> Result<(), String> {
let number = |key: &str| -> Result<usize, String> {
@@ -327,16 +379,22 @@ fn cmd_ci_shard() -> Result<(), String> {
let checked = shards::run()?;
let mut steps: Vec<Step> = Vec::new();
match &checked[shard - 1] {
shards::Shard::Tests(crates) => {
shards::Shard::Tests(crates, part) => {
let names = shards::names(crates);
eprintln!("ci shard {shard}/{count}: the tests of {names}");
let share = part.map(|p| format!(" (part {} of {})", p.index, p.split.parts())).unwrap_or_default();
eprintln!("ci shard {shard}/{count}: the tests of {names}{share}");
let select = shards::select(crates);
let shown = crates.iter().map(|m| format!("-p {}", m.name)).collect::<Vec<_>>().join(" ");
let part = *part;
let (s, w) = (select.clone(), shown.clone());
steps.push(("test", Box::new(move || test_packages(&s, &w))));
steps.push(("test", Box::new(move || test_packages(&s, &w, part))));
// The doctests and the i18n report run once, on a split's first part.
let first = part.is_none_or(|p| p.is_first());
let (s, w) = (select.clone(), shown.clone());
steps.push(("doctests", Box::new(move || doctest_packages(&s, &w))));
if crates.iter().any(|m| m.name == "vectorcraft-ui-egui") {
if first {
steps.push(("doctests", Box::new(move || doctest_packages(&s, &w))));
}
if first && crates.iter().any(|m| m.name == "vectorcraft-ui-egui") {
steps.push(("i18n-report", Box::new(move || i18n_report_packages(&select, &shown))));
}
}
@@ -361,7 +419,11 @@ fn cmd_ci_warm() -> Result<(), String> {
let checked = shards::run()?;
let mut steps: Vec<Step> = Vec::new();
for shard in checked {
if let shards::Shard::Tests(crates) = shard {
// A split's later parts build the same tests as its first.
if let shards::Shard::Tests(crates, part) = shard {
if part.is_some_and(|p| !p.is_first()) {
continue;
}
steps.push((
"build tests",
Box::new(move || {
+271 -20
View File
@@ -10,6 +10,12 @@
//! its features in `cargo test --workspace`. Cargo resolves features over the packages a command
//! selects, so a feature that only another crate's dev-dependencies turn on is off in a shard
//! without that crate, and the tests behind it do not build.
//!
//! A [`Split`] runs the tests of its crates on several shards in a row ([`Group::Part`]). Each
//! 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.
use std::collections::{BTreeMap, BTreeSet};
@@ -20,15 +26,53 @@ use serde_json::Value;
pub enum Group {
/// The tests of these workspace crates (package names).
Crates(&'static [&'static str]),
/// Part `k` (1-based) of a split's tests. Parts 1 to n of a split are consecutive shards.
Part(&'static Split, usize),
/// The tests of every workspace member no other group names.
Rest,
/// The `cargo xtask ci` steps that are not tests.
Checks,
}
/// Crates whose tests run on several shards, one [`Group::Part`] each.
#[derive(Debug, PartialEq, Eq)]
pub struct Split {
/// The workspace crates (package names).
pub crates: &'static [&'static str],
/// For each part, the full names of the tests it runs outside the counted partition (the
/// slowest ones, spread so that no part waits on all of them). Its length is the part count.
pub pinned: &'static [&'static [&'static str]],
}
impl Split {
/// How many shards the split runs on.
pub fn parts(&self) -> usize {
self.pinned.len()
}
}
/// 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.
pub static UI_EGUI: Split = Split {
crates: &["vectorcraft-ui-egui"],
pinned: &[
&[
"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",
],
&[
"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",
],
],
};
/// The shards in order; `test-shards` in `.github/workflows/ci.yml` is its length.
pub const GROUPS: &[Group] = &[
Group::Crates(&["vectorcraft-ui-egui"]),
Group::Part(&UI_EGUI, 1),
Group::Part(&UI_EGUI, 2),
Group::Crates(&["vectorcraft-engine"]),
Group::Crates(&["vectorcraft", "vectorcraft-web", "vectorcraft-cli", "vectorcraft-mcp", "xtask"]),
Group::Rest,
@@ -45,13 +89,70 @@ pub struct Member {
pub version: String,
}
/// What one shard runs, with its crates resolved.
/// What one shard runs, with its crates resolved; a shard of a [`Split`] carries its part.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Shard {
Tests(Vec<Member>),
Tests(Vec<Member>, Option<Part>),
Checks,
}
/// Part `index` (1-based) of `split`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Part {
pub split: &'static Split,
pub index: usize,
}
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.
/// The counted run passes `--no-tests=pass`. The pinned run keeps nextest's default and
/// fails when no tests match.
pub fn runs(&self) -> Vec<Vec<String>> {
let all: Vec<&str> = self.split.pinned.iter().flat_map(|p| p.iter().copied()).collect();
let mut counted = vec!["--partition".to_owned(), format!("count:{}/{}", self.index, self.split.parts()), "--no-tests=pass".to_owned()];
if !all.is_empty() {
counted.extend(["-E".to_owned(), format!("not ({})", exact(&all))]);
}
let mut runs = vec![counted];
let own = self.split.pinned[self.index - 1];
if !own.is_empty() {
runs.push(vec!["-E".to_owned(), exact(own)]);
}
runs
}
/// The tests this part pins whose full names are absent from
/// `cargo nextest list --message-format json` output. Invalid listings return an error.
pub fn missing_pins(&self, list: &str) -> Result<Vec<&'static str>, String> {
let list: Value = serde_json::from_str(list).map_err(|e| format!("invalid JSON listing: {e}"))?;
let suites = list.get("rust-suites").and_then(Value::as_object).ok_or("JSON listing has no `rust-suites` map")?;
let mut listed = BTreeSet::new();
for (binary, suite) in suites {
let tests =
suite.get("testcases").and_then(Value::as_object).ok_or_else(|| format!("JSON listing has no `testcases` map for `{binary}`"))?;
listed.extend(tests.keys().map(String::as_str));
}
Ok(self.split.pinned[self.index - 1].iter().copied().filter(|p| !listed.contains(p)).collect())
}
/// Whether this part runs the doctests and the i18n report.
pub fn is_first(&self) -> bool {
self.index == 1
}
}
/// A filterset that matches each of `names` exactly.
fn exact(names: &[&str]) -> String {
names.iter().map(|n| format!("test(={n})")).collect::<Vec<_>>().join(" | ")
}
/// The workspace members of `cargo metadata --no-deps` output, in its order.
pub fn members(meta: &Value) -> Result<Vec<Member>, String> {
let ids: BTreeSet<&str> = meta["workspace_members"].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
@@ -72,22 +173,49 @@ pub fn members(meta: &Value) -> Result<Vec<Member>, String> {
}
/// Each group of `groups` with its crates: a named crate must be a workspace member and named
/// once, there must be exactly one [`Group::Rest`], and no test shard may be empty.
/// once, there must be exactly one [`Group::Rest`], and no test shard may be empty. A split's
/// parts 1 to n must be consecutive shards, with at least two parts, and no test pinned twice.
pub fn assign(groups: &[Group], members: &[Member]) -> Result<Vec<Shard>, String> {
const WHERE: &str = "xtask/src/shards.rs › GROUPS";
let mut named: BTreeMap<&str, usize> = BTreeMap::new();
for (i, g) in groups.iter().enumerate() {
if let Group::Crates(names) = g {
if names.is_empty() {
return Err(format!("shard {} names no crates ({WHERE})", i + 1));
let names = match g {
Group::Crates(names) => *names,
Group::Part(split, k) => {
let n = split.parts();
if n < 2 {
return Err(format!("shard {} is a part of a split with {n} part(s), not 2 or more ({WHERE})", i + 1));
}
// Part 1 of the split is shard `first` (0-based) when this shard is part k.
let in_order = (1..=n).contains(k)
&& (i + 1).checked_sub(*k).is_some_and(|first| {
(1..=n).all(|p| matches!(groups.get(first + p - 1), Some(Group::Part(s, q)) if *s == *split && *q == p))
});
if !in_order {
return Err(format!("shard {} is part {k} of a split whose {n} parts are not shards 1 to {n} in a row ({WHERE})", i + 1));
}
if *k > 1 {
continue;
}
let mut pinned = BTreeSet::new();
for name in split.pinned.iter().flat_map(|p| p.iter()) {
if !pinned.insert(*name) {
return Err(format!("`{name}` is pinned to two parts of shard {}'s split ({WHERE})", i + 1));
}
}
split.crates
}
for name in *names {
if !members.iter().any(|m| m.name == *name) {
return Err(format!("shard {} names `{name}`, which is not a workspace member ({WHERE})", i + 1));
}
if let Some(first) = named.insert(name, i) {
return Err(format!("`{name}` is in shard {} and shard {} ({WHERE})", first + 1, i + 1));
}
Group::Rest | Group::Checks => continue,
};
if names.is_empty() {
return Err(format!("shard {} names no crates ({WHERE})", i + 1));
}
for name in names {
if !members.iter().any(|m| m.name == *name) {
return Err(format!("shard {} names `{name}`, which is not a workspace member ({WHERE})", i + 1));
}
if let Some(first) = named.insert(name, i) {
return Err(format!("`{name}` is in shard {} and shard {} ({WHERE})", first + 1, i + 1));
}
}
}
@@ -100,13 +228,14 @@ pub fn assign(groups: &[Group], members: &[Member]) -> Result<Vec<Shard>, String
.iter()
.enumerate()
.map(|(i, g)| match g {
Group::Crates(names) => Ok(Shard::Tests(pick(&|m| names.contains(&m.name.as_str())))),
Group::Crates(names) => Ok(Shard::Tests(pick(&|m| names.contains(&m.name.as_str())), None)),
Group::Part(split, index) => Ok(Shard::Tests(pick(&|m| split.crates.contains(&m.name.as_str())), Some(Part { split, index: *index }))),
Group::Rest => {
let rest = pick(&|m| !named.contains_key(m.name.as_str()));
if rest.is_empty() {
return Err(format!("shard {} takes the remaining crates, and there are none ({WHERE})", i + 1));
}
Ok(Shard::Tests(rest))
Ok(Shard::Tests(rest, None))
}
Group::Checks => Ok(Shard::Checks),
})
@@ -184,7 +313,7 @@ pub fn check() -> Result<Vec<Shard>, String> {
let workspace = tree_features(&tree(&["--workspace".to_owned()])?, &members);
let mut differences = Vec::new();
for (i, shard) in shards.iter().enumerate() {
if let Shard::Tests(crates) = shard {
if let Shard::Tests(crates, _) = shard {
let alone = tree_features(&tree(&select(crates))?, &members);
differences.extend(feature_differences(i + 1, crates, &workspace, &alone));
}
@@ -206,7 +335,10 @@ pub fn run() -> Result<Vec<Shard>, String> {
let shards = check()?;
for (i, shard) in shards.iter().enumerate() {
match shard {
Shard::Tests(crates) => println!("shard {}/{}: tests of {} crate(s): {}", i + 1, shards.len(), crates.len(), names(crates)),
Shard::Tests(crates, part) => {
let share = part.map(|p| format!(", part {} of {}", p.index, p.split.parts())).unwrap_or_default();
println!("shard {}/{}: tests of {} crate(s): {}{share}", i + 1, shards.len(), crates.len(), names(crates))
}
Shard::Checks => println!("shard {}/{}: the other ci steps", i + 1, shards.len()),
}
}
@@ -224,11 +356,130 @@ mod tests {
fn crates(shard: &Shard) -> Vec<&str> {
match shard {
Shard::Tests(c) => c.iter().map(|m| m.name.as_str()).collect(),
Shard::Tests(c, _) => c.iter().map(|m| m.name.as_str()).collect(),
Shard::Checks => Vec::new(),
}
}
/// The crates of each shard that runs a crate's tests from the start: a part after the first
/// runs a share of the same tests, so it is counted with part 1.
fn owners(shard: &Shard) -> Vec<&str> {
match shard {
Shard::Tests(_, Some(p)) if !p.is_first() => Vec::new(),
_ => crates(shard),
}
}
/// The tests (binary ids and full names, in the order nextest lists them) that one `cargo nextest run` with
/// `args` from [`Part::runs`] runs, as nextest selects them: the `-E` filterset (`test(=…)`
/// terms joined by `|`, or `not (…)` of them) first, then `--partition count:<k>/<n>`, which
/// keeps the i-th (0-based) test the filter left in each binary when `i % n` is `k - 1`.
fn selected<'a>(args: &[String], tests: &[(&'a str, &'a str)]) -> Vec<(&'a str, &'a str)> {
let value = |flag: &str| args.iter().position(|a| a == flag).map(|i| args[i + 1].as_str());
let filtered: Vec<(&str, &str)> = match value("-E") {
None => tests.to_vec(),
Some(expr) => {
let (negated, body) = expr.strip_prefix("not (").and_then(|e| e.strip_suffix(')')).map_or((false, expr), |b| (true, b));
let names: Vec<&str> = body.split(" | ").map(|t| t.strip_prefix("test(=").and_then(|t| t.strip_suffix(')')).unwrap()).collect();
tests.iter().copied().filter(|(_, t)| names.contains(t) != negated).collect()
}
};
match value("--partition") {
None => filtered,
Some(p) => {
let (k, n) = p.strip_prefix("count:").and_then(|p| p.split_once('/')).unwrap();
let (k, n): (usize, usize) = (k.parse().unwrap(), n.parse().unwrap());
let mut counts = BTreeMap::new();
filtered
.into_iter()
.filter(|(binary, _)| {
let count = counts.entry(*binary).or_insert(0);
let selected = *count % n == k - 1;
*count += 1;
selected
})
.collect()
}
}
}
/// The tests each part of `split` runs, over all of its runs.
fn share<'a>(split: &'static Split, tests: &[(&'a str, &'a str)]) -> Vec<Vec<(&'a str, &'a str)>> {
(1..=split.parts()).map(|index| Part { split, index }.runs().iter().flat_map(|args| selected(args, tests)).collect()).collect()
}
static SPLIT: Split = Split { crates: &["a"], pinned: &[&["a::slow1", "a::slow3"], &["a::slow2"]] };
#[test]
fn a_split_runs_on_its_parts_in_a_row() {
let ws = [m("a"), m("b")];
let shards = assign(&[Group::Part(&SPLIT, 1), Group::Part(&SPLIT, 2), Group::Rest, Group::Checks], &ws).unwrap();
assert_eq!(shards.iter().map(crates).collect::<Vec<_>>(), [vec!["a"], vec!["a"], vec!["b"], vec![]]);
assert_eq!(shards[1], Shard::Tests(vec![m("a")], Some(Part { split: &SPLIT, index: 2 })));
let apart = assign(&[Group::Part(&SPLIT, 1), Group::Rest, Group::Part(&SPLIT, 2)], &ws).unwrap_err();
assert!(apart.contains("not shards 1 to 2 in a row"), "{apart}");
let missing = assign(&[Group::Part(&SPLIT, 2), Group::Rest], &ws).unwrap_err();
assert!(missing.contains("shard 1 is part 2"), "{missing}");
let twice = assign(&[Group::Part(&SPLIT, 1), Group::Part(&SPLIT, 2), Group::Crates(&["a"]), Group::Rest], &ws).unwrap_err();
assert!(twice.contains("`a` is in shard 1 and shard 3"), "{twice}");
const ONE: Split = Split { crates: &["a"], pinned: &[&[]] };
assert!(assign(&[Group::Part(&ONE, 1), Group::Rest], &ws).unwrap_err().contains("not 2 or more"));
const DOUBLE: Split = Split { crates: &["a"], pinned: &[&["a::t"], &["a::t"]] };
assert!(assign(&[Group::Part(&DOUBLE, 1), Group::Part(&DOUBLE, 2), Group::Rest], &ws).unwrap_err().contains("pinned to two parts"));
}
#[test]
fn every_test_of_a_split_runs_on_exactly_one_part() {
let tests = [
("a::lib", "a::t1"),
("a::lib", "a::slow1"),
("a::lib", "a::t2"),
("a::lib", "a::t3"),
("a::bin/a", "a::slow2"),
("a::bin/a", "a::t4"),
("a::bin/a", "a::t5"),
("a::bin/a", "a::slow3"),
];
let parts = share(&SPLIT, &tests);
assert_eq!(
parts,
[
vec![("a::lib", "a::t1"), ("a::lib", "a::t3"), ("a::bin/a", "a::t4"), ("a::lib", "a::slow1"), ("a::bin/a", "a::slow3")],
vec![("a::lib", "a::t2"), ("a::bin/a", "a::t5"), ("a::bin/a", "a::slow2")],
]
);
let mut all = parts.concat();
all.sort_unstable();
let mut want = tests.to_vec();
want.sort_unstable();
assert_eq!(all, want);
let (one, two) = (Part { split: &SPLIT, index: 1 }, Part { split: &SPLIT, index: 2 });
assert_eq!(
one.runs(),
[
vec![
"--partition".to_owned(),
"count:1/2".to_owned(),
"--no-tests=pass".to_owned(),
"-E".to_owned(),
"not (test(=a::slow1) | test(=a::slow3) | test(=a::slow2))".to_owned(),
],
vec!["-E".to_owned(), "test(=a::slow1) | test(=a::slow3)".to_owned()],
]
);
assert!(one.is_first() && !two.is_first());
let list = r#"{"rust-suites":{"a::lib":{"testcases":{"a::t1":{},"a::slow1":{}}},"a::bin/a":{"testcases":{"a::slow2":{}}}}}"#;
assert_eq!(one.missing_pins(list).unwrap(), ["a::slow3"]);
assert!(two.missing_pins(list).unwrap().is_empty());
assert!(one.missing_pins("invalid JSON").is_err());
assert!(one.missing_pins("{}").is_err());
assert!(one.missing_pins(r#"{"rust-suites":{"a::lib":{}}}"#).is_err());
// A split that pins nothing passes no filterset, which nextest would reject as `not ()`.
static BARE: Split = Split { crates: &["a"], pinned: &[&[], &[]] };
assert_eq!(Part { split: &BARE, index: 2 }.runs(), [vec!["--partition".to_owned(), "count:2/2".to_owned(), "--no-tests=pass".to_owned()]]);
assert_eq!(share(&BARE, &tests).concat().len(), tests.len());
}
#[test]
fn the_rest_shard_takes_every_crate_no_group_names() {
let ws = [m("a"), m("b"), m("c"), m("d")];
@@ -259,7 +510,7 @@ mod tests {
fn every_workspace_member_is_tested_on_exactly_one_shard() {
let ws = members(&crate::metadata().unwrap()).unwrap();
let shards = assign(GROUPS, &ws).unwrap();
let mut tested: Vec<&str> = shards.iter().flat_map(crates).collect();
let mut tested: Vec<&str> = shards.iter().flat_map(owners).collect();
tested.sort_unstable();
let mut all: Vec<&str> = ws.iter().map(|m| m.name.as_str()).collect();
all.sort_unstable();