requirements.test-coverage.storage.outcomes
Requirements index · View definition
Requirement
Each coverage run MUST record the outcome of every test attempt that started. It MUST distinguish successful, failed, and interrupted runs and identify attempts with missing or unreadable coverage rather than treating them as zero execution. An empty test selection MUST be identified as empty; nextest’s success or failure for that selection MUST remain the test execution result.
Rationale
I judged the tests adequate for each obligation in requirements.test-coverage.storage.outcomes. I did not request implementation source. The supplied tests were enough to map every obligation to a scenario and an assertion.
1. Record the outcome of every test attempt that started.
tests/execution_coverage.rs#fn[real_parallel_processes_retries_child_profiles_and_filtered_reruns]runs a workspace with a retry. It asserts exactly 6 attempt records for 5 tests, and 2 records for the retried test. It also asserts that attempt identities are unique and that same-named tests in different binaries stay distinct.tests/execution_coverage.rs#fn[a_process_that_cannot_start_is_failed_with_retained_attempt_metadata]covers an attempt whose process cannot launch. It asserts one record with outcomefailedand a “Cannot start test process” diagnostic.- Failures before any test starts have a test too:
tests/execution_coverage.rs#fn[a_build_that_cannot_start_retains_failed_run_metadata],tests/execution_coverage.rs#fn[unreadable_build_inputs_fail_preparation_before_any_tests_start]and the compile-error step in the big test. Each asserts a run outcome offailed, no attempts and a diagnostic.
2. Distinguish successful, failed and interrupted runs.
- Success: the big test asserts a run outcome of
successand attempt outcomes ofsuccess. The--no-runstep does the same. - Failed: the retry’s first attempt is asserted
failedand its secondsuccess. With--retries 0the run and the attempt are both assertedfailed. - Interrupted:
tests/execution_coverage.rs#fn[interrupting_the_parent_preserves_started_attempt_metadata]sends SIGINT to a started, waiting test. It asserts exit code 130, run outcomeinterrupted, exactly one attempt record, and that record’s outcomeinterrupted.
3. Identify attempts with missing or unreadable coverage rather than treating them as zero execution.
tests/execution_coverage.rs#fn[passing_tests_with_missing_or_corrupt_profiles_fail_collection_and_retain_partial_reports]covers three attempts:- A missing profile gets the diagnostic “No LLVM profile was written”.
- A corrupt profile gets a process diagnostic and empty lines.
- A good profile has non-empty lines.
- The attempts keep outcome
success, and the run isfailed.
src/execution_coverage/book.rs#mod[tests]/fn[unreadable_history_cannot_reintroduce_an_older_success]covers the reporting side:- A missing raw profile gives “missing or unreadable coverage” and “A retained raw profile is missing”.
- A missing captured source and unsupported run metadata are also reported as unavailable or incomplete.
- Unreadable attempt metadata does not fall back to an older success.
4. An empty test selection is identified as empty, and nextest’s result stays the execution result.
real_parallel_processes_retries_child_profiles_and_filtered_rerunsruns an empty selection with--no-tests pass. It asserts a successful exit, no attempts, and an “Empty test selection” diagnostic.- It then runs the same selection without that flag. It asserts nextest’s exit code 4, run outcome
failed, no attempts and the same diagnostic. - It also checks that a compile-only
--no-runrun is not labelled “Empty”.
src/execution_coverage/runner.rs#mod[tests]/fn[empty_conversion_starts_no_work_and_reports_no_completions] adds a small unit check of the empty case.
Every clause has a test that exercises the behaviour and asserts its outcome, both success and failure variants are covered, and I found no unresolved gaps or marking gaps.
Inputs
Tests
Input 2: outline src/execution_coverage/book.rs mod[tests]/fn[unreadable_history_cannot_reintroduce_an_older_success]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[unreadable_history_cannot_reintroduce_an_older_success] - Kind:
fn src/execution_coverage/book.rs:2188–2262
// {test}`requirements.test-coverage.index.selection`
// {test}`requirements.test-coverage.index.unavailable`
// {test}`requirements.test-coverage.index.freshness`
// {test}`requirements.test-coverage.storage.outcomes`
// {test}`requirements.test-coverage.index.file_map.combined.measurement`
#[test]
fn unreadable_history_cannot_reintroduce_an_older_success() {
let (temp, mut book) = fixture();
record(temp.path(), "one", 1, "a", &[(1, 1)]);
let newest = record(temp.path(), "one", 2, "a", &[(1, 0)]);
fs::write(newest.join("attempt.json"), "not JSON").unwrap();
populate(&mut book, temp.path()).unwrap();
let index = &book.chapters().next().unwrap().content;
assert!(index.contains("cannot establish latest-per-test selection"));
assert!(index.contains("gap counts unavailable"));
assert!(!index.contains("1/1 (100.0%)"));
let (temp, mut book) = fixture();
let newest = record(temp.path(), "one", 1, "a", &[(1, 1)]);
let path = newest.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&path).unwrap();
run.sources.clear();
save(&path, &run).unwrap();
populate(&mut book, temp.path()).unwrap();
assert!(
book.chapters()
.next()
.unwrap()
.content
.contains("missing or unreadable coverage")
);
assert!(
book.chapters()
.next()
.unwrap()
.content
.contains("Matching captured source is missing")
);
// Unsupported metadata cannot establish compatibility for combined totals.
let (temp, mut book) = fixture();
let attempt = record(temp.path(), "one", 1, "a", &[(1, 1)]);
let path = attempt.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&path).unwrap();
run.schema = 99;
save(&path, &run).unwrap();
populate(&mut book, temp.path()).unwrap();
let index = &book.chapters().next().unwrap().content;
assert!(index.contains("Coverage history is incomplete"));
assert!(index.contains("gap counts unavailable"));
// A retained result with an unreadable/missing raw profile is unavailable.
let (temp, mut book) = fixture();
let attempt = record(temp.path(), "one", 1, "a", &[(1, 1)]);
fs::remove_file(attempt.join("1-1.profraw")).unwrap();
populate(&mut book, temp.path()).unwrap();
assert!(
book.chapters()
.next()
.unwrap()
.content
.contains("missing or unreadable coverage")
);
assert!(
book.chapters()
.next()
.unwrap()
.content
.contains("gap counts unavailable")
);
assert!(
book.chapters()
.next()
.unwrap()
.content
.contains("A retained raw profile is missing")
);
}
Input 3: outline src/execution_coverage/runner.rs mod[tests]/fn[empty_conversion_starts_no_work_and_reports_no_completions]
- File:
src/execution_coverage/runner.rs - Selector:
mod[tests]/fn[empty_conversion_starts_no_work_and_reports_no_completions] - Kind:
fn src/execution_coverage/runner.rs:1708–1715
// {test}`requirements.test-coverage.storage.outcomes`
#[test]
fn empty_conversion_starts_no_work_and_reports_no_completions() {
let results: Vec<()> =
parallel_collect::<(), _>(&[], 4, |_| panic!("no work"), |_| panic!("no completions"));
assert!(results.is_empty());
assert_eq!(parallel_collect(&[7], 0, |value| *value, |_| {}), vec![7]);
}
Input 4: outline tests/execution_coverage.rs fn[real_parallel_processes_retries_child_profiles_and_filtered_reruns]
- File:
tests/execution_coverage.rs - Selector:
fn[real_parallel_processes_retries_child_profiles_and_filtered_reruns] - Kind:
fn tests/execution_coverage.rs:741–1018
// {test}`requirements.test-coverage.run`
// {test}`requirements.test-coverage.processes`
// {test}`requirements.test-coverage.processes.reports`
// {test}`requirements.test-coverage.storage`
// {test}`requirements.test-coverage.storage.provenance`
// {test}`requirements.test-coverage.storage.configuration`
// {test}`requirements.test-coverage.storage.outcomes`
// {test}`requirements.test-coverage.failures`
#[test]
fn real_parallel_processes_retries_child_profiles_and_filtered_reruns() {
let temp = fixture();
let root = temp.path();
assert_success(&coverage(
root,
&["--workspace", "--retries", "1", "-j", "2", "--no-fail-fast"],
));
let saved = runs(root);
assert_eq!(saved.len(), 1);
let first = &saved[0].0;
assert_eq!(
saved[0].1["id"],
first.file_name().unwrap().to_str().unwrap()
);
assert!(saved[0].1["started"].as_u64().unwrap() > 0);
assert_eq!(saved[0].1["command"][0], "cargo nextest run");
assert!(
saved[0].1["selection"]
.as_array()
.unwrap()
.iter()
.any(|arg| arg == "--workspace")
);
assert!(saved[0].1["revision"].is_null());
assert!(saved[0].1["dirty"].is_null());
assert!(
saved[0].1["inputs"]
.get(root.join("src/lib.rs").to_str().unwrap())
.is_some()
);
let records = attempts(first);
assert_eq!(records.len(), 6); // five tests, one retried
let retry = records
.iter()
.filter(|record| record["test"] == "retries")
.collect::<Vec<_>>();
assert_eq!(retry.len(), 2);
assert!(
retry
.iter()
.any(|record| record["outcome"] == "failed" && record["attempt"] == "1")
);
assert!(
retry
.iter()
.any(|record| record["outcome"] == "success" && record["attempt"] == "2")
);
let child = records
.iter()
.find(|record| record["test"] == "child_process")
.unwrap();
assert_eq!(child["processes"].as_array().unwrap().len(), 2);
assert!(
child["processes"]
.as_array()
.unwrap()
.iter()
.all(|process| process["diagnostic"].is_null()
&& !process["lines"].as_object().unwrap().is_empty())
);
assert!(
records
.iter()
.all(|record| !record["processes"].as_array().unwrap().is_empty())
);
assert_eq!(
records
.iter()
.filter(|record| record["test"].as_str().unwrap().ends_with("same_name"))
.count(),
2
);
let same_named = records
.iter()
.filter(|record| record["test"].as_str().unwrap().ends_with("same_name"))
.collect::<Vec<_>>();
let binaries = same_named
.iter()
.map(|record| record["binary"].as_str().unwrap())
.collect::<std::collections::BTreeSet<_>>();
assert_eq!(
binaries,
std::collections::BTreeSet::from(["coverage-fixture", "coverage-fixture::processes"])
);
let identities = records
.iter()
.map(|record| record["id"].as_str().unwrap())
.collect::<std::collections::BTreeSet<_>>();
assert_eq!(identities.len(), records.len());
for record in &records {
for process in record["processes"].as_array().unwrap() {
for profile in process["profiles"].as_array().unwrap() {
assert!(
first
.join("attempts")
.join(record["id"].as_str().unwrap())
.join(profile.as_str().unwrap())
.is_file()
);
}
}
}
let configuration = &saved[0].1["configuration_inputs"];
assert!(
configuration["rustc"]
.as_str()
.unwrap()
.contains("LLVM version:")
);
assert!(!configuration["target"].as_str().unwrap().is_empty());
assert_eq!(configuration["cargo-profile"], "test");
assert!(
configuration["instrumentation"]
.as_str()
.unwrap()
.contains("-C instrument-coverage")
);
assert!(first.join("maps.json").is_file());
assert!(
saved[0].1["sources"]["src/lib.rs"]
.as_str()
.unwrap()
.contains("pub fn value")
);
assert_success(&coverage(root, &["-E", "test(second)"]));
let saved = runs(root);
assert_eq!(saved.len(), 2);
assert_eq!(attempts(&saved[1].0).len(), 1);
assert_eq!(saved[0].1["configuration"], saved[1].1["configuration"]);
assert_eq!(
saved[1].1["selection"],
serde_json::json!(["-E", "test(second)"])
);
// A scheduling profile doesn't split build compatibility.
let config = root.join(".config/nextest.toml");
let mut source = fs::read_to_string(&config).unwrap();
source.push_str("\n[profile.focused]\ntest-threads = 1\n");
fs::write(config, source).unwrap();
assert_success(&coverage(
root,
&["--profile", "focused", "-E", "test(second)"],
));
let saved = runs(root);
assert_eq!(saved[0].1["configuration"], saved[2].1["configuration"]);
assert_eq!(attempts(&saved[0].0).len(), 6); // historical profiles were retained
// Collection must preserve failure, including a retry's attempt outcome.
let failed = coverage(root, &["-E", "test(retries)", "--retries", "0"]);
assert!(!failed.status.success());
let saved = runs(root);
let newest = saved.last().unwrap();
assert_eq!(newest.1["outcome"], "failed");
assert_eq!(attempts(&newest.0)[0]["outcome"], "failed");
// Empty selection has nextest's own exit result and a visible run diagnostic.
let empty = coverage(
root,
&["-E", "test(definitely_missing)", "--no-tests", "pass"],
);
assert_success(&empty);
let saved = runs(root);
assert!(attempts(&saved.last().unwrap().0).is_empty());
assert!(
saved.last().unwrap().1["diagnostics"][0]
.as_str()
.unwrap()
.contains("Empty test selection")
);
let empty_failure = coverage(root, &["-E", "test(definitely_missing)"]);
assert_eq!(
empty_failure.status.code(),
Some(4),
"{}",
String::from_utf8_lossy(&empty_failure.stderr)
);
let saved = runs(root);
let newest = saved.last().unwrap();
assert_eq!(newest.1["outcome"], "failed");
assert!(attempts(&newest.0).is_empty());
assert!(
newest.1["diagnostics"][0]
.as_str()
.unwrap()
.contains("Empty test selection")
);
assert_success(&coverage(
root,
&["--features", "alpha", "-Fbeta", "-E", "test(second)"],
));
let saved = runs(root);
let newest = saved.last().unwrap();
assert_ne!(newest.1["configuration"], saved[0].1["configuration"]);
let enabled: Value = serde_json::from_str(
newest.1["configuration_inputs"]["enabled-features"]
.as_str()
.unwrap(),
)
.unwrap();
assert!(enabled.as_object().unwrap().values().any(|features| {
features
.as_array()
.unwrap()
.contains(&Value::String("alpha".into()))
&& features
.as_array()
.unwrap()
.contains(&Value::String("beta".into()))
}));
assert_success(&coverage(
root,
&[
"--config",
"build.build-dir='custom-build'",
"-E",
"test(second)",
],
));
let saved = runs(root);
assert_eq!(attempts(&saved.last().unwrap().0).len(), 1);
assert!(!root.join("custom-build").exists());
assert_success(&coverage(root, &["--no-run", "-E", "test(second)"]));
let saved = runs(root);
let newest = saved.last().unwrap();
assert_eq!(newest.1["outcome"], "success");
assert!(attempts(&newest.0).is_empty());
assert!(
newest.1["diagnostics"][0]
.as_str()
.unwrap()
.contains("Compilation-only")
);
assert!(
!newest.1["diagnostics"][0]
.as_str()
.unwrap()
.contains("Empty")
);
// Compilation failures also retain run identity and all earlier process data.
fs::write(
root.join("src/lib.rs"),
"compile_error!(\"deliberate build failure\");\n",
)
.unwrap();
let failed_build = coverage(root, &["-E", "test(second)"]);
assert!(!failed_build.status.success());
let saved = runs(root);
let newest = saved.last().unwrap();
assert_eq!(newest.1["outcome"], "failed");
assert!(attempts(&newest.0).is_empty());
assert!(
newest.1["diagnostics"][0]
.as_str()
.unwrap()
.contains("Instrumented compilation")
);
assert_eq!(attempts(first).len(), 6);
for record in &records {
for process in record["processes"].as_array().unwrap() {
for profile in process["profiles"].as_array().unwrap() {
assert!(
first
.join("attempts")
.join(record["id"].as_str().unwrap())
.join(profile.as_str().unwrap())
.is_file()
);
}
}
}
}
Input 5: outline tests/execution_coverage.rs fn[a_build_that_cannot_start_retains_failed_run_metadata]
- File:
tests/execution_coverage.rs - Selector:
fn[a_build_that_cannot_start_retains_failed_run_metadata] - Kind:
fn tests/execution_coverage.rs:1057–1110
// {test}`requirements.test-coverage.failures`
// {test}`requirements.test-coverage.storage.outcomes`
#[cfg(unix)]
#[test]
fn a_build_that_cannot_start_retains_failed_run_metadata() {
use std::os::unix::{fs::PermissionsExt, fs::symlink};
let temp = fixture();
let root = temp.path();
let sysroot = Command::new("rustc")
.args(["--print", "sysroot"])
.output()
.unwrap();
assert_success(&sysroot);
let toolchain = std::path::PathBuf::from(String::from_utf8(sysroot.stdout).unwrap().trim());
let bin = root.join("fake-tools");
fs::create_dir(&bin).unwrap();
symlink(toolchain.join("bin/rustc"), bin.join("rustc")).unwrap();
let nextest = std::env::split_paths(&std::env::var_os("PATH").unwrap())
.map(|directory| directory.join("cargo-nextest"))
.find(|path| path.is_file())
.expect("cargo-nextest is installed");
symlink(nextest, bin.join("cargo-nextest")).unwrap();
let cargo = bin.join("cargo");
fs::write(&cargo, "#!/bin/sh\nif [ \"$1\" = metadata ]; then\n\"$HABEAS_TEST_CARGO_PATH\" \"$@\"\nresult=$?\n/bin/rm \"$0\"\nexit \"$result\"\nfi\nexec \"$HABEAS_TEST_CARGO_PATH\" \"$@\"\n").unwrap();
fs::set_permissions(&cargo, fs::Permissions::from_mode(0o755)).unwrap();
let output = Command::new(env!("CARGO_BIN_EXE_habeas"))
.arg("coverage")
.arg("--")
.args(["-E", "test(second)"])
.current_dir(root)
.env(
"PATH",
std::env::join_paths([bin.as_path(), Path::new("/usr/bin"), Path::new("/bin")])
.unwrap(),
)
.env("HABEAS_TEST_CARGO_PATH", toolchain.join("bin/cargo"))
.env("CARGO_NET_OFFLINE", "true")
.env_remove("CARGO_TARGET_DIR")
.env_remove("CARGO_BUILD_TARGET_DIR")
.env_remove("RUSTC_WORKSPACE_WRAPPER")
.output()
.unwrap();
assert!(!output.status.success());
let saved = runs(root);
assert_eq!(saved.len(), 1);
assert_eq!(saved[0].1["outcome"], "failed");
assert!(attempts(&saved[0].0).is_empty());
assert!(
saved[0].1["diagnostics"][0]
.as_str()
.unwrap()
.contains("Cannot start instrumented compilation")
);
}
Input 6: outline tests/execution_coverage.rs fn[passing_tests_with_missing_or_corrupt_profiles_fail_collection_and_retain_partial_reports]
- File:
tests/execution_coverage.rs - Selector:
fn[passing_tests_with_missing_or_corrupt_profiles_fail_collection_and_retain_partial_reports] - Kind:
fn tests/execution_coverage.rs:1228–1323
// {test}`requirements.test-coverage.failures`
// {test}`requirements.test-coverage.storage.outcomes`
// {test}`requirements.test-coverage.processes.reports`
// {test}`requirements.test-coverage.test`
#[cfg(unix)]
#[test]
fn passing_tests_with_missing_or_corrupt_profiles_fail_collection_and_retain_partial_reports() {
let temp = fixture();
let root = temp.path();
fs::write(root.join("tests/processes.rs"), "").unwrap();
fs::write(root.join("src/lib.rs"), r#"
#[test] fn good_profile() { assert_eq!(std::hint::black_box(1), 1); }
unsafe extern "C" { fn _exit(status: i32) -> !; }
#[test] fn missing_profile() { unsafe { _exit(0) } }
#[test] fn corrupt_profile() {
let template = std::path::PathBuf::from(std::env::var("LLVM_PROFILE_FILE").unwrap());
std::fs::write(template.parent().unwrap().join(format!("{}-corrupt.profraw", std::process::id())), "not an LLVM profile").unwrap();
}
"#).unwrap();
let output = coverage(root, &["--workspace"]);
assert!(!output.status.success());
assert!(
String::from_utf8_lossy(&output.stderr)
.contains("partial profiles and reports have been retained")
);
let combined = full_flow(root);
assert!(!combined.status.success());
assert!(!String::from_utf8_lossy(&combined.stdout).contains("Coverage check"));
assert!(
String::from_utf8_lossy(&combined.stderr)
.contains("partial profiles and reports have been retained")
);
let saved = runs(root);
assert_eq!(saved[0].1["outcome"], "failed");
let records = attempts(&saved[0].0);
assert_eq!(records.len(), 3);
assert!(
records
.iter()
.all(|attempt| attempt["outcome"] == "success"),
"test execution itself succeeds: {records:?}"
);
let missing = records
.iter()
.find(|attempt| attempt["test"] == "missing_profile")
.unwrap();
assert!(
missing["diagnostics"]
.as_array()
.unwrap()
.iter()
.any(|diagnostic| diagnostic
.as_str()
.unwrap()
.contains("No LLVM profile was written"))
);
let corrupt = records
.iter()
.find(|attempt| attempt["test"] == "corrupt_profile")
.unwrap();
assert!(
corrupt["processes"]
.as_array()
.unwrap()
.iter()
.any(|process| !process["diagnostic"].is_null()
&& process["lines"].as_object().unwrap().is_empty())
);
let good = records
.iter()
.find(|attempt| attempt["test"] == "good_profile")
.unwrap();
assert!(
!good["processes"][0]["lines"]
.as_object()
.unwrap()
.is_empty()
);
for attempt in [&good, &corrupt] {
for profile in attempt["processes"]
.as_array()
.unwrap()
.iter()
.flat_map(|process| process["profiles"].as_array().unwrap())
{
assert!(
saved[0]
.0
.join("attempts")
.join(attempt["id"].as_str().unwrap())
.join(profile.as_str().unwrap())
.is_file()
);
}
}
}
Input 7: outline tests/execution_coverage.rs fn[a_process_that_cannot_start_is_failed_with_retained_attempt_metadata]
- File:
tests/execution_coverage.rs - Selector:
fn[a_process_that_cannot_start_is_failed_with_retained_attempt_metadata] - Kind:
fn tests/execution_coverage.rs:1325–1350
// {test}`requirements.test-coverage.storage.outcomes`
// {test}`requirements.test-coverage.failures`
#[test]
fn a_process_that_cannot_start_is_failed_with_retained_attempt_metadata() {
let temp = tempfile::tempdir().unwrap();
let run = temp.path().join("run");
let output = Command::new(env!("CARGO_BIN_EXE_habeas"))
.arg("coverage-process")
.arg(temp.path().join("nonexistent-test-program"))
.env("HABEAS_COVERAGE_RUN", &run)
.env("NEXTEST_BINARY_ID", "fixture::lib")
.env("NEXTEST_TEST_NAME", "cannot_start")
.env("NEXTEST_ATTEMPT", "1")
.output()
.unwrap();
assert!(!output.status.success());
let records = attempts(&run);
assert_eq!(records.len(), 1);
assert_eq!(records[0]["outcome"], "failed");
assert!(
records[0]["diagnostics"][0]
.as_str()
.unwrap()
.contains("Cannot start test process")
);
}
Input 8: outline tests/execution_coverage.rs fn[unreadable_build_inputs_fail_preparation_before_any_tests_start]
- File:
tests/execution_coverage.rs - Selector:
fn[unreadable_build_inputs_fail_preparation_before_any_tests_start] - Kind:
fn tests/execution_coverage.rs:1352–1381
// {test}`requirements.test-coverage.storage.outcomes`
// {test}`requirements.test-coverage.storage.provenance`
// {test}`requirements.test-coverage.failures`
#[cfg(unix)]
#[test]
fn unreadable_build_inputs_fail_preparation_before_any_tests_start() {
use std::os::unix::fs::PermissionsExt;
let temp = fixture();
let root = temp.path();
fs::write(
root.join("build.rs"),
"fn main() { println!(\"cargo::rerun-if-changed=input.data\"); }\n",
)
.unwrap();
fs::write(root.join("input.data"), "private build input").unwrap();
fs::set_permissions(root.join("input.data"), fs::Permissions::from_mode(0o000)).unwrap();
let output = coverage(root, &["-E", "test(second)"]);
fs::set_permissions(root.join("input.data"), fs::Permissions::from_mode(0o600)).unwrap();
assert!(!output.status.success());
assert!(String::from_utf8_lossy(&output.stderr).contains("Coverage preparation failed"));
let saved = runs(root);
assert_eq!(saved[0].1["outcome"], "failed");
assert!(attempts(&saved[0].0).is_empty());
assert!(
saved[0].1["diagnostics"][0]
.as_str()
.unwrap()
.contains("before test startup")
);
}
Input 9: outline tests/execution_coverage.rs fn[interrupting_the_parent_preserves_started_attempt_metadata]
- File:
tests/execution_coverage.rs - Selector:
fn[interrupting_the_parent_preserves_started_attempt_metadata] - Kind:
fn tests/execution_coverage.rs:1383–1442
// {test}`requirements.test-coverage.storage.outcomes`
// {test}`requirements.test-coverage.failures`
#[cfg(unix)]
#[test]
fn interrupting_the_parent_preserves_started_attempt_metadata() {
let temp = fixture();
let root = temp.path();
fs::write(root.join("src/lib.rs"), "#[test] fn waits() { std::fs::write(\"started\", \"ready\").unwrap(); loop { std::thread::sleep(std::time::Duration::from_millis(20)); } }\n").unwrap();
fs::write(root.join("tests/processes.rs"), "").unwrap();
let mut child = Command::new(env!("CARGO_BIN_EXE_habeas"))
.args(["coverage", "--", "-E", "test(waits)"])
.current_dir(root)
.env("CARGO_NET_OFFLINE", "true")
.env_remove("CARGO_TARGET_DIR")
.env_remove("CARGO_BUILD_TARGET_DIR")
.env_remove("RUSTC_WORKSPACE_WRAPPER")
.env_remove("HABEAS_COVERAGE_RUN")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.spawn()
.unwrap();
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(60);
while !root.join("started").exists() && std::time::Instant::now() < deadline {
if let Some(status) = child.try_wait().unwrap() {
panic!("coverage exited before the test started: {status}");
}
std::thread::sleep(std::time::Duration::from_millis(20));
}
if !root.join("started").exists() {
child.kill().unwrap();
child.wait().unwrap();
panic!("test did not start before the readiness deadline");
}
assert!(
Command::new("kill")
.args(["-INT", &child.id().to_string()])
.status()
.unwrap()
.success()
);
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(15);
let status = loop {
if let Some(status) = child.try_wait().unwrap() {
break status;
}
if std::time::Instant::now() >= deadline {
child.kill().unwrap();
child.wait().unwrap();
panic!("coverage did not finish after interruption");
}
std::thread::sleep(std::time::Duration::from_millis(20));
};
assert_eq!(status.code(), Some(130));
let saved = runs(root);
assert_eq!(saved[0].1["outcome"], "interrupted");
let records = attempts(&saved[0].0);
assert_eq!(records.len(), 1);
assert_eq!(records[0]["test"], "waits");
assert_eq!(records[0]["outcome"], "interrupted");
}
Other sources
Input 1: requirements selection requirements.test-coverage.storage.outcomes
requirements.test-coverage.storage.outcomes:md/requirements/test-coverage.md:137–143
:::{req} storage.outcomes
Each coverage run MUST record the outcome of every test attempt that started.
It MUST distinguish successful, failed, and interrupted runs and identify
attempts with missing or unreadable coverage rather than treating them as zero
execution. An empty test selection MUST be identified as empty; nextest's
success or failure for that selection MUST remain the test execution result.
:::