requirements.test-coverage.index.file_map.directories
Requirements index · View definition
Requirement
The table of
MUST group its listed files by their directory hierarchy. Each non-root directory containing a listed file, directly or through descendants, MUST have a group. Each group MUST be independently expandable and collapsible.
A collapsed group MUST show its workspace-relative path and the summaries required by
and
, while hiding its file rows and descendant groups.
Rationale
The two {test}-marked tests cover every obligation in requirements.test-coverage.index.file_map.directories.
I read the test helpers and the renderer. GapDirectory::render emits <details class="gap-directory" data-directory=… open><summary><code>path/</code> …min · counts · N not measured</summary> body</details>. Only gaps_map renders the map, so there is one map to cover.
Obligations and the tests that cover them
- Group files by directory hierarchy.
combined_directory_minimum_includes_hidden_passing_fileschecks nesting throughassert_directory_contents.srcholds the child groupsrc/nestedand the filesrc/gap.rs.src/nestedholds onlysrc/nested/deep.src/nested/deepholdssrc/nested/deep/gap.rs.directory_minima_use_exact_fractions_and_count_unmeasured_descendantsdoes the same forsrc,src/nestedand the files under them.- The first test also asserts that root-level file rows (
code.rs) fall outside any directory group. - Group membership is checked structurally.
directory_groupbalances nested<details>tags, and the helper asserts the body contains each child group and file row.
- Every non-root directory with a listed file, directly or through descendants, has a group.
- In the first test,
src/nestedhas no listed file of its own, sincepassing.rsis hidden. It still gets a group becausedeepis below it. - In the second test,
src/nested/deepandsrc/siblingget groups in the 8-file case.src/nestedgets one when its only descendants are unmeasured files. - A similarly named sibling directory,
src-other, gets a separate group that is not merged intosrc.
- In the first test,
- Each group is independently expandable and collapsible.
directory_minima_use_exact_fractions_and_count_unmeasured_descendantsclosessrc/nestedby removing itsopenattribute.- It asserts that
srcstays open andsrc/nestedis closed. - It asserts the body of
src/nestedand every file card are unchanged, and that restoringopenreproduces the original map. - The first test asserts that every group is a native details element and is open.
- A collapsed group shows its workspace-relative path and the minimum and not-measured summaries.
assert_directory_contentsasserts the<summary>contains<code>{directory}/</code>, and contains no file rows or table.- The tests assert the summary contains the “Minimum measured file coverage:” label and the percentage (
25.0%,0.0%). They also assert thedata-min-coveredanddata-min-instrumentedfractions. - They assert the summary shows “N not measured” only when N is nonzero, with exact counts such as 5, 3, 2 and 1 across nested and sibling groups. They also assert “No measured files” with no
%. - Because the summary carries these values and the rows and descendants sit in the body, a closed group shows the summary and hides the rest.
- The test also checks the closed-group summaries are identical to the open ones.
- Hidden rows and descendants. Closed state hides the body, which holds the file rows and descendant groups. The tests show these are in the body and not the summary.
Related cases checked
- Unlisted files with no obligations or accepted exceptions do not inflate the not-measured count.
- The partial and stale paths render no
gap-directorygroups.incomplete_attempts_do_not_label_their_files_as_unmeasured_in_a_partial_mapcovers this. It is marked for other requirements, but it is consistent with the subject. - The minimum and status values belong to
…minimumand…minimum.statuses, which the subject cites. The subject’s tests exercise their presence in the collapsed summary.
I found no plausible requirement-violating behavior that these tests would accept, and no fixme acknowledgments apply.
Inputs
Tests
Input 5: outline src/execution_coverage/book.rs mod[tests]/fn[combined_directory_minimum_includes_hidden_passing_files]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[combined_directory_minimum_includes_hidden_passing_files] - Kind:
fn src/execution_coverage/book.rs:1030–1114
// {test}`requirements.test-coverage.index.file_map.combined`
// {test}`requirements.test-coverage.index.file_map.directories.initial`
// {test}`requirements.test-coverage.index.file_map.directories.data`
// {test}`requirements.test-coverage.index.file_map.minimum`
// {test}`requirements.test-coverage.index.gaps.summary`
// {test}`requirements.test-coverage.index.file_map.directories`
#[test]
fn combined_directory_minimum_includes_hidden_passing_files() {
let (temp, mut book) = fixture();
let root = temp.path();
fs::create_dir_all(root.join("src/nested/deep")).unwrap();
fs::write(
root.join("src/gap.rs"),
format!("fn gap() {{\n{}}}\n", " let value = 1;\n".repeat(18)),
)
.unwrap();
fs::write(
root.join("src/nested/passing.rs"),
"fn passing() {\n let a = 1;\n let b = 2;\n let c = 3;\n}\n",
)
.unwrap();
fs::write(root.join("src/nested/deep/gap.rs"), "fn nested_gap() {}\n").unwrap();
let path = record(root, "all", 1, "same", &[(1, 0), (2, 1)]);
let run_path = path.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&run_path).unwrap();
let mut attempt: Attempt = load(&path.join("attempt.json")).unwrap();
for (file, total, covered, count) in [
("src/gap.rs", 20, 19, 0),
("src/nested/passing.rs", 5, 4, 1),
("src/nested/deep/gap.rs", 1, 1, 0),
] {
run.sources
.insert(file.into(), fs::read_to_string(root.join(file)).unwrap());
attempt.processes[0].lines.insert(
file.into(),
(1..=total)
.map(|line| (line, u64::from(line <= covered)))
.collect(),
);
attempt.processes[0].functions.as_mut().unwrap().push(
super::super::FunctionExecution {
file: file.into(),
line: 1,
column: 1,
count,
},
);
}
save(&run_path, &run).unwrap();
save(&path.join("attempt.json"), &attempt).unwrap();
populate(&mut book, root).unwrap();
let overview = &book.chapters().next().unwrap().content;
let map = map_html(overview);
assert!(map.contains("data-directory=\"src\" open"));
assert!(map.contains("data-min-covered=\"4\" data-min-instrumented=\"5\">80.0%"));
assert!(map.contains("2 uncovered obligations"));
for (directory, expected) in [("src", 2), ("src/nested", 1), ("src/nested/deep", 1)] {
let summary = directory_summary(map, directory);
assert!(summary.contains(&format!("{expected} uncovered obligations")));
assert!(summary.contains("Minimum measured file coverage:"));
}
assert_directory_contents(map, "src", &["src/nested"], &["src/gap.rs"]);
assert_directory_contents(map, "src/nested", &["src/nested/deep"], &[]);
assert_directory_contents(map, "src/nested/deep", &[], &["src/nested/deep/gap.rs"]);
for directory in ["src", "src/nested", "src/nested/deep"] {
assert!(map.contains(&format!("data-directory=\"{directory}\" open")));
}
assert!(map.contains("data-file=\"code.rs\""));
assert!(
map.find("data-file=\"code.rs\"").unwrap()
< map.find("<details class=\"gap-directory\"").unwrap(),
"root file rows are outside directory controls"
);
assert_eq!(map.matches("data-file=").count(), 3);
assert!(map.contains("data-file=\"src/gap.rs\""));
assert!(map.contains("95.0%"));
assert!(file_card(map, "src/gap.rs").contains("<code>src/gap.rs</code>"));
assert!(map.contains("zero execution"));
assert!(!map.contains("data-file=\"src/nested/passing.rs\""));
assert!(
book.chapters()
.all(|chapter| chapter.name != "File notes: src/nested/passing.rs")
);
assert!(overview.contains("1 file obligations · 3 function obligations"));
}
Input 6: outline src/execution_coverage/book.rs mod[tests]/fn[directory_minima_use_exact_fractions_and_count_unmeasured_descendants]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[directory_minima_use_exact_fractions_and_count_unmeasured_descendants] - Kind:
fn src/execution_coverage/book.rs:1466–1642
// {test}`requirements.test-coverage.index.file_map.minimum`
// {test}`requirements.test-coverage.index.file_map.minimum.statuses`
// {test}`requirements.test-coverage.index.file_map.minimum.descendants`
// {test}`requirements.test-coverage.index.file_map.directories`
// {test}`requirements.test-coverage.index.file_map.directories.data`
#[test]
fn directory_minima_use_exact_fractions_and_count_unmeasured_descendants() {
let render = |files: &[(&str, usize, usize)]| {
let mut policy = super::super::check::PolicyReport {
report: super::super::check::CheckReport {
passed: false,
text: String::new(),
},
files: files
.iter()
.map(|&(file, covered, total)| super::super::check::FilePolicy {
file: file.into(),
covered,
total,
obligations: vec![super::super::check::Obligation {
selector: String::new(),
line: 1,
measurement: "below target".into(),
exception: None,
}],
})
.collect(),
counts_complete: true,
measured: true,
findings: vec![],
};
// Unlisted files with no obligations or accepted exceptions must
// not inflate the directory's not-measured count.
for (file, accepted) in [
("src/nested/hidden-empty.rs", false),
("src/nested/hidden-accepted.rs", true),
] {
policy.files.push(super::super::check::FilePolicy {
file: file.into(),
covered: 0,
total: 0,
obligations: if accepted {
vec![super::super::check::Obligation {
selector: String::new(),
line: 1,
measurement: "not measured".into(),
exception: Some(super::super::check::Exception {
accepted: true,
review_missing: false,
justification: "No instrumented obligations.".into(),
findings: vec![],
}),
}]
} else {
vec![]
},
});
}
gaps_map(&policy, Path::new("coverage.md"), 1)
};
let map = render(&[("src/higher.rs", 501, 1000), ("src/lower.rs", 1001, 2000)]);
assert!(
directory_summary(&map, "src")
.contains("data-min-covered=\"1001\" data-min-instrumented=\"2000\"")
);
let map = render(&[
("src/a.rs", 1, 2),
("src/nested/b.rs", 1, 4),
("src/nested/c.rs", 0, 0),
]);
for directory in ["src", "src/nested"] {
let summary = directory_summary(&map, directory);
assert!(summary.contains("Minimum measured file coverage:"));
assert!(summary.contains("25.0%"));
assert!(summary.contains("1 not measured"));
assert!(!summary.contains("0 unavailable"));
assert!(!summary.contains("2 not measured"));
}
assert_directory_contents(&map, "src", &["src/nested"], &["src/a.rs"]);
assert_directory_contents(
&map,
"src/nested",
&[],
&["src/nested/b.rs", "src/nested/c.rs"],
);
// Changing one native details control only changes its open attribute;
// all file identities, measurements, summaries and sibling state remain.
let opening = "<details class=\"gap-directory\" data-directory=\"src/nested\" open>";
let closed_opening = opening.replace(" open>", ">");
let closed = map.replace(opening, &closed_opening);
assert_ne!(closed, map);
assert!(closed.contains("data-directory=\"src\" open>"));
assert!(closed.contains("data-directory=\"src/nested\">"));
assert_eq!(
directory_group(&closed, "src/nested")
.split_once('>')
.unwrap()
.1,
directory_group(&map, "src/nested")
.split_once('>')
.unwrap()
.1
);
for file in ["src/a.rs", "src/nested/b.rs", "src/nested/c.rs"] {
assert_eq!(file_card(&map, file), file_card(&closed, file));
}
assert_eq!(closed.replace(&closed_opening, opening), map);
let map = render(&[("src/unknown.rs", 0, 0)]);
let summary = directory_summary(&map, "src");
assert!(summary.contains("No measured files"));
assert!(summary.contains("1 not measured"));
assert!(!summary.contains('%'));
let map = render(&[
("src/measured-zero.rs", 0, 4),
("src/nested/unmeasured.rs", 0, 0),
]);
let summary = directory_summary(&map, "src");
assert!(summary.contains("Minimum measured file coverage:"));
assert!(summary.contains("0.0%"));
assert!(summary.contains("1 not measured"));
assert!(!summary.contains("2 not measured"));
let zero = file_card(&map, "src/measured-zero.rs");
assert!(zero.contains("data-status=\"measured\""));
assert!(zero.contains("0.0%"));
assert!(zero.contains("0/4 instrumented lines covered"));
assert!(!zero.contains("not measured"));
let nested = directory_summary(&map, "src/nested");
assert!(nested.contains("No measured files"));
assert!(nested.contains("1 not measured"));
assert!(!nested.contains('%'));
let map = render(&[
("src/direct.rs", 0, 0),
("src/nested/a.rs", 0, 0),
("src/nested/deep/b.rs", 0, 0),
("src/nested/deep/c.rs", 0, 0),
("src/sibling/d.rs", 0, 0),
("src/measured-zero.rs", 0, 4),
("src/positive.rs", 1, 4),
("src-other/outside.rs", 0, 0),
]);
for (directory, count) in [
("src", 5),
("src/nested", 3),
("src/nested/deep", 2),
("src/sibling", 1),
("src-other", 1),
] {
let summary = directory_summary(&map, directory);
assert!(
summary.contains(&format!(" · {count} not measured")),
"{summary}"
);
}
assert!(directory_summary(&map, "src").contains("0.0%"));
let closed = map.replace(
"<details class=\"gap-directory\" data-directory=\"src/nested\" open>",
"<details class=\"gap-directory\" data-directory=\"src/nested\">",
);
for directory in [
"src",
"src/nested",
"src/nested/deep",
"src/sibling",
"src-other",
] {
assert_eq!(
directory_summary(&closed, directory)
.split_once('>')
.unwrap()
.1,
directory_summary(&map, directory)
.split_once('>')
.unwrap()
.1
);
}
}
Referenced definitions
Input 2: requirements selection requirements.test-coverage.index.file_map.table
requirements.test-coverage.index.file_map.table:md/requirements/test-coverage.md:243–250
:::{req} index.file_map.table
Each file coverage map MUST present its listed files in a compact table, with
one row per file and columns for its workspace-relative path and coverage
percentage or measurement status. Covered and instrumented line counts MUST
remain available in each measured file's row or expanded details.
The counts, statuses, and visual distinction of coverage levels MUST follow
{cite}`requirements.test-coverage.index.file_map`.
:::
Input 3: requirements selection requirements.test-coverage.index.file_map.minimum
requirements.test-coverage.index.file_map.minimum:md/requirements/test-coverage.md:277–292
:::{req} index.file_map.minimum
Each directory group under
{cite}`requirements.test-coverage.index.file_map.directories` MUST display the
minimum measured file coverage percentage within its directory, including
descendant directories.
For the combined gaps overview, the minimum MUST consider all current
first-party Rust files represented by the map within that directory,
including files hidden because they have no unsatisfied obligations.
The minimum MUST use the file coverage fractions of
{cite}`requirements.test-coverage.index.file_map` before rounding for display,
regardless of which groups are expanded. Its label MUST identify it as the
minimum measured file coverage. Not-measured and unavailable files MUST NOT
contribute a percentage. A group with no measured files MUST show no numerical
minimum.
:::
Input 4: requirements selection requirements.test-coverage.index.file_map.minimum.statuses
requirements.test-coverage.index.file_map.minimum.statuses:md/requirements/test-coverage.md:294–301
:::{req} index.file_map.minimum.statuses
Each directory group under
{cite}`requirements.test-coverage.index.file_map.directories` MUST display
the number of its listed files, including descendants, that are not measured
whenever that count is nonzero. The status MUST follow
{cite}`requirements.test-coverage.index.file_map`. The count MUST describe
only files listed by the map, regardless of which groups are expanded.
:::
Other sources
Input 1: requirements selection requirements.test-coverage.index.file_map.directories
requirements.test-coverage.index.file_map.directories:md/requirements/test-coverage.md:252–262
:::{req} index.file_map.directories
The table of {cite}`requirements.test-coverage.index.file_map.table` MUST group
its listed files by their directory hierarchy. Each non-root directory
containing a listed file, directly or through descendants, MUST have a group.
Each group MUST be independently expandable and collapsible.
A collapsed group MUST show its workspace-relative path and the summaries
required by {cite}`requirements.test-coverage.index.file_map.minimum` and
{cite}`requirements.test-coverage.index.file_map.minimum.statuses`, while
hiding its file rows and descendant groups.
:::
Input 7: outline src/execution_coverage/book.rs mod[tests]/fn[directory_group]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[directory_group] - Kind:
fn src/execution_coverage/book.rs:832–854
// Return a complete native details group, accounting for nested groups and
// explanation controls rather than stopping at the first closing tag.
fn directory_group<'a>(html: &'a str, directory: &str) -> &'a str {
let start = html
.find(&format!(
"<details class=\"gap-directory\" data-directory=\"{directory}\""
))
.unwrap();
let rest = &html[start..];
let tags = regex::Regex::new(r"<details(?:\s[^>]*|)>|</details>").unwrap();
let mut depth = 0;
for tag in tags.find_iter(rest) {
if tag.as_str() == "</details>" {
depth -= 1;
if depth == 0 {
return &rest[..tag.end()];
}
} else {
depth += 1;
}
}
panic!("unclosed directory {directory}");
}
Input 8: outline src/execution_coverage/book.rs mod[tests]/fn[assert_directory_contents]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[assert_directory_contents] - Kind:
fn src/execution_coverage/book.rs:856–868
fn assert_directory_contents(html: &str, directory: &str, children: &[&str], files: &[&str]) {
let group = directory_group(html, directory);
let (summary, body) = group.split_once("</summary>").unwrap();
assert!(summary.contains(&format!("<code>{directory}/</code>")));
assert!(!summary.contains("data-file="));
assert!(!summary.contains("<table"));
for child in children {
assert!(body.contains(directory_group(html, child)));
}
for file in files {
assert!(body.contains(&format!("data-file=\"{file}\"")));
}
}
Input 9: outline src/execution_coverage/book.rs mod[tests]/fn[directory_summary]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[directory_summary] - Kind:
fn src/execution_coverage/book.rs:1457–1464
fn directory_summary<'a>(map: &'a str, directory: &str) -> &'a str {
map.split(&format!("data-directory=\"{directory}\""))
.nth(1)
.unwrap()
.split("</summary>")
.next()
.unwrap()
}
Input 10: outline src/execution_coverage/book.rs impl[GapDirectory<'_>]/fn[render]
- File:
src/execution_coverage/book.rs - Selector:
impl[GapDirectory<'_>]/fn[render] - Kind:
fn src/execution_coverage/book.rs:87–182
fn render(
&self,
html: &mut String,
folder: &str,
policy: &super::check::PolicyReport,
index: &Path,
next: &mut usize,
) {
if !self.files.is_empty() {
html.push_str("<table class=\"gap-file-table\"><colgroup><col><col><col><col></colgroup><thead><tr><th>File</th><th>Coverage</th><th>Uncovered obligations</th><th>Explanation</th></tr></thead><tbody>\n");
for file in &self.files {
let id = format!("habeas-gap-file-{}", *next);
*next += 1;
let gaps: Vec<_> = file
.obligations
.iter()
.filter(|gap| !gap.accepted())
.collect();
let threshold = gaps.iter().any(|gap| gap.selector.is_empty());
let functions = gaps.len() - usize::from(threshold);
let undocumented = gaps.iter().filter(|gap| gap.exception.is_none()).count();
let description = match (threshold, functions) {
(true, 0) => "file below target".to_owned(),
(true, n) => format!("file + {n} functions"),
(false, 1) => "1 function".to_owned(),
(false, n) => format!("{n} functions"),
};
let explanation = if undocumented == gaps.len() {
"Missing"
} else {
"Review needed"
};
let percentage = if file.total == 0 {
"not measured".to_owned()
} else {
percentage_label(file.covered, file.total)
};
let indicator = if file.total == 0 {
String::new()
} else {
format!(
"<span class=\"gap-coverage-bar\" aria-hidden=\"true\" style=\"--gap-covered: {:.6}%\"></span>",
100.0 * file.covered as f64 / file.total as f64
)
};
html.push_str(&format!("<tr class=\"gap-file-row habeas-coverage-file\" data-file=\"{}\" data-status=\"{}\"><td><button class=\"gap-file-button\" aria-expanded=\"false\" aria-controls=\"{id}\" onclick=\"const row=document.getElementById(this.getAttribute('aria-controls'));row.hidden=!row.hidden;this.setAttribute('aria-expanded',String(!row.hidden));this.querySelector('.gap-chevron').textContent=row.hidden?'▸':'▾'\"><span class=\"gap-chevron\" aria-hidden=\"true\">▸</span><code>{}</code></button></td><td class=\"gap-percentage\">{percentage}{indicator}</td><td>{description}</td><td class=\"gap-unresolved\">{explanation}</td></tr>\n", escaped(&file.file), if file.total == 0 { "not measured" } else { "measured" }, escaped(&file.file)));
let notes =
crate::chapter_href(index, &super::notes::path(index, &file.file), None);
html.push_str(&format!("<tr class=\"gap-detail-row\" id=\"{id}\" hidden><td colspan=\"4\"><p class=\"gap-detail-title\"><code>{}</code> · {}/{} instrumented lines covered · <a href=\"{}\">Current source notes</a></p><table class=\"gap-obligation-table\"><thead><tr><th>Source item</th><th>Measurement</th><th>Explanation</th></tr></thead><tbody>", escaped(&file.file), file.covered, file.total, escaped(¬es)));
for gap in gaps {
html.push_str(&format!("<tr><td><code>{}</code><br><span class=\"gap-meta\">{}:{}</span></td><td>{}</td><td>{}</td></tr>\n", escaped(if gap.selector.is_empty() { "File root" } else { &gap.selector }), escaped(&file.file), gap.line, escaped(&gap.measurement), explanation_html(gap)));
}
html.push_str("</tbody></table></td></tr>\n");
}
html.push_str("</tbody></table>\n");
}
for (name, directory) in &self.directories {
let path = if folder.is_empty() {
name.clone()
} else {
format!("{folder}/{name}")
};
let prefix = format!("{path}/");
let minimum = policy
.files
.iter()
.filter(|file| file.file.starts_with(&prefix) && file.total > 0)
.min_by(|a, b| {
((a.covered as u128) * (b.total as u128))
.cmp(&((b.covered as u128) * (a.total as u128)))
});
let min = minimum.map_or_else(|| "No measured files".to_owned(), |file| format!("Minimum measured file coverage: <strong data-min-covered=\"{}\" data-min-instrumented=\"{}\">{}</strong>", file.covered, file.total, percentage_label(file.covered, file.total)));
let not_measured = policy
.files
.iter()
.filter(|file| {
file.file.starts_with(&prefix)
&& file.total == 0
&& file.obligations.iter().any(|gap| !gap.accepted())
})
.count();
let counts = if policy.counts_complete {
format!("{} uncovered obligations", directory.count())
} else if policy.measured {
format!(
"Gap counts incomplete: {} established uncovered obligations",
directory.count()
)
} else {
"Gap counts unavailable".to_owned()
};
html.push_str(&format!("<details class=\"gap-directory\" data-directory=\"{}\" open><summary><code>{}/</code><span class=\"gap-meta\">{min} · {counts}{} </span></summary>\n", escaped(&path), escaped(&path), if not_measured > 0 { format!(" · {not_measured} not measured") } else { String::new() }));
directory.render(html, &path, policy, index, next);
html.push_str("</details>\n");
}
}
Input 11: outline src/execution_coverage/book.rs mod[tests]/fn[incomplete_attempts_do_not_label_their_files_as_unmeasured_in_a_partial_map]
- File:
src/execution_coverage/book.rs - Selector:
mod[tests]/fn[incomplete_attempts_do_not_label_their_files_as_unmeasured_in_a_partial_map] - Kind:
fn src/execution_coverage/book.rs:1328–1380
// {test}`requirements.test-coverage.index.file_map`
// {test}`requirements.test-coverage.index.file_map.table`
// {test}`requirements.test-coverage.index.file_map.combined`
// {test}`requirements.test-coverage.index.file_map.combined.measurement`
// {test}`requirements.test-coverage.index.freshness`
// {test}`requirements.test-coverage.index.file_map.minimum`
// {test}`requirements.test-coverage.index.file_map.minimum.statuses`
#[test]
fn incomplete_attempts_do_not_label_their_files_as_unmeasured_in_a_partial_map() {
let (temp, book) = fixture();
let root = temp.path();
fs::create_dir_all(root.join("src/nested")).unwrap();
fs::write(root.join("src/nested/other.rs"), "fn other() {}\n").unwrap();
let good = record(root, "good", 1, "a", &[(1, 1)]);
let bad = record(root, "bad", 2, "a", &[]);
let mut attempt: Attempt = load(&bad.join("attempt.json")).unwrap();
attempt.processes[0].lines =
BTreeMap::from([("src/nested/other.rs".into(), BTreeMap::from([(1, 1)]))]);
save(&bad.join("attempt.json"), &attempt).unwrap();
for path in [&good, &bad] {
let run_path = path.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&run_path).unwrap();
run.sources
.insert("src/nested/other.rs".into(), "fn other() {}\n".into());
save(&run_path, &run).unwrap();
}
fs::remove_file(bad.join("1-1.profraw")).unwrap();
let mut partial = book.clone();
populate(&mut partial, root).unwrap();
let index = &partial.chapters().next().unwrap().content;
assert!(index.contains("Coverage unavailable"));
assert!(!map_html(index).contains("data-file="));
assert!(!map_html(index).contains("not measured"));
assert!(!map_html(index).contains("class=\"gap-directory\""));
assert!(!map_html(index).contains("data-min-covered="));
assert!(!map_html(index).contains("gap-coverage-bar\""));
assert!(index.contains("1 unavailable test attempts"));
// A stale selected attempt leaves the same unknown per-file state.
let run_path = bad.parent().unwrap().parent().unwrap().join("run.json");
let mut run: Run = load(&run_path).unwrap();
run.inputs
.insert("missing-build-input".into(), "old-hash".into());
save(&run_path, &run).unwrap();
let mut stale = book;
populate(&mut stale, root).unwrap();
let index = &stale.chapters().next().unwrap().content;
assert!(index.contains("Coverage unavailable"));
assert!(!map_html(index).contains("data-file="));
assert!(!map_html(index).contains("class=\"gap-directory\""));
assert!(!map_html(index).contains("data-min-covered="));
assert!(!map_html(index).contains("not measured"));
assert!(index.contains("1 stale test attempts"));
}