Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.test-coverage.index.unavailable

Requirements index · View definition

evidence Valid

Requirement

When no coverage run has been recorded, the coverage index MUST show a readable message explaining how to collect one. Missing, unreadable, or incomplete run data MUST produce a visible diagnostic in the index without preventing the rest of the book from rendering.

Rationale

I judged this from the supplied test source only, and I did not request any implementation source.

Obligations derived from requirements.test-coverage.index.unavailable:

  1. With no recorded coverage run, the index MUST show a readable message explaining how to collect one.
  2. Missing, unreadable, or incomplete run data MUST produce a visible diagnostic in the index.
  3. That failure MUST NOT prevent the rest of the book from rendering.

How the tests cover them (all in src/execution_coverage/book.rs):

  • No run recorded:
    • mod[tests]/fn[unavailable_runs_are_readable_and_generated_paths_cannot_collide] populates a fixture with no runs. It asserts that the index chapter contains “Run habeas coverage”, which is the instruction for collecting a run.
  • Missing or unreadable run data:
    • mod[tests]/fn[run_data_failures_render_diagnostics_and_leave_other_chapters_readable] covers four cases: missing run.json, corrupt run.json, a missing attempts directory, and a run that carries a diagnostic.
    • In each case it asserts that the index contains “Coverage diagnostic:”.
    • It also asserts case-specific text: “unavailable run data”, “attempts”, or “(interrupted): collection was interrupted”.
    • It then asserts that an unrelated chapter’s content is unchanged, and that populate returned Ok.
    • That is the “rest of the book still renders” obligation.
  • Unreadable storage:
    • mod[tests]/fn[unreadable_storage_is_a_diagnostic_and_does_not_stop_book_rendering] is Unix-only. It sets the storage directory to mode 000 and asserts that populate succeeds. It also asserts that the index contains “Coverage diagnostic: Coverage storage is unreadable” and “No test coverage is available”.
  • Incomplete data:
    • mod[tests]/fn[unreadable_history_cannot_reintroduce_an_older_success] covers four more cases, and populate is unwrapped in each:
      • a corrupt attempt.json;
      • a run with its captured sources cleared;
      • an unsupported schema version;
      • a missing raw profile.
    • For these it asserts diagnostic text such as “cannot establish latest-per-test selection”, “missing or unreadable coverage”, “Coverage history is incomplete”, “gap counts unavailable”, and “A retained raw profile is missing”.
    • It also asserts that the older 100% success is not shown.

Gaps: I found none. The no-run case does not assert that other chapters survive. The requirement ties non-blocking rendering to the failure cases, and those cases do assert it. In the incomplete-data cases, populate(...).unwrap() succeeding is enough to show that rendering was not blocked. All the obligations have marked tests with concrete assertions.

Inputs

Tests

Input 2: outline src/execution_coverage/book.rs mod[tests]/fn[unavailable_runs_are_readable_and_generated_paths_cannot_collide]
    // {test}`requirements.test-coverage.index.paths`
    // {test}`requirements.test-coverage.index.unavailable`
    #[test]
    fn unavailable_runs_are_readable_and_generated_paths_cannot_collide() {
        let (temp, mut collision) = fixture();
        collision.push_item(Chapter::new(
            "Authored",
            "Keep me".into(),
            "reports/coverage.md",
            vec![],
        ));
        assert!(
            populate(&mut collision, temp.path())
                .unwrap_err()
                .to_string()
                .contains("coverage index path conflicts")
        );
        let (temp, mut book) = fixture();
        populate(&mut book, temp.path()).unwrap();
        assert!(
            book.chapters()
                .next()
                .unwrap()
                .content
                .contains("Run `habeas coverage`")
        );
        // Current file-note pages are generated reports too, even without runs.
        let (temp, mut book) = fixture();
        book.push_item(Chapter::new(
            "Notes collision",
            "".into(),
            super::super::notes::path(Path::new("reports/coverage.md"), "code.rs"),
            vec![],
        ));
        assert!(
            populate(&mut book, temp.path())
                .unwrap_err()
                .to_string()
                .contains("conflicts")
        );
    }
Input 3: outline src/execution_coverage/book.rs mod[tests]/fn[unreadable_history_cannot_reintroduce_an_older_success]
    // {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 4: outline src/execution_coverage/book.rs mod[tests]/fn[run_data_failures_render_diagnostics_and_leave_other_chapters_readable]
    // {test}`requirements.test-coverage.index.unavailable`
    #[test]
    fn run_data_failures_render_diagnostics_and_leave_other_chapters_readable() {
        for case in [
            "missing run",
            "corrupt run",
            "missing attempts",
            "run diagnostic",
        ] {
            let (temp, mut book) = fixture();
            let attempt = record(temp.path(), "one", 1, "a", &[(1, 1)]);
            let run_dir = attempt.parent().unwrap().parent().unwrap();
            match case {
                "missing run" => fs::remove_file(run_dir.join("run.json")).unwrap(),
                "corrupt run" => fs::write(run_dir.join("run.json"), "not JSON").unwrap(),
                "missing attempts" => fs::remove_dir_all(run_dir.join("attempts")).unwrap(),
                "run diagnostic" => {
                    let mut run: Run = load(&run_dir.join("run.json")).unwrap();
                    run.outcome = "interrupted".into();
                    run.diagnostics.push("collection was interrupted".into());
                    save(&run_dir.join("run.json"), &run).unwrap();
                }
                _ => unreachable!(),
            }
            book.push_item(Chapter::new(
                "Other chapter",
                "Unrelated content survives.".into(),
                "other.md",
                vec![],
            ));
            populate(&mut book, temp.path()).unwrap();
            let index = &book.chapters().next().unwrap().content;
            assert!(
                index.contains("**Coverage diagnostic:**"),
                "{case}: {index}"
            );
            if case == "missing run" || case == "corrupt run" {
                assert!(index.contains("unavailable run data"), "{case}");
            } else if case == "missing attempts" {
                assert!(index.contains("attempts"), "{index}");
            } else {
                assert!(index.contains("(interrupted): collection was interrupted"));
            }
            assert!(
                book.chapters()
                    .any(|chapter| chapter.content == "Unrelated content survives.")
            );
        }
    }
Input 5: outline src/execution_coverage/book.rs mod[tests]/fn[unreadable_storage_is_a_diagnostic_and_does_not_stop_book_rendering]
    // {test}`requirements.test-coverage.index.unavailable`
    #[cfg(unix)]
    #[test]
    fn unreadable_storage_is_a_diagnostic_and_does_not_stop_book_rendering() {
        use std::os::unix::fs::PermissionsExt;
        let (temp, mut book) = fixture();
        record(temp.path(), "one", 1, "a", &[(1, 1)]);
        let storage = temp.path().join("target/habeas/coverage");
        fs::set_permissions(&storage, fs::Permissions::from_mode(0o000)).unwrap();
        let result = populate(&mut book, temp.path());
        fs::set_permissions(storage, fs::Permissions::from_mode(0o755)).unwrap();
        result.unwrap();
        let index = &book.chapters().next().unwrap().content;
        assert!(index.contains("**Coverage diagnostic:** Coverage storage is unreadable"));
        assert!(index.contains("No test coverage is available"));
    }

Other sources

Input 1: requirements selection requirements.test-coverage.index.unavailable
:::{req} index.unavailable
When no coverage run has been recorded, the coverage index MUST show a readable
message explaining how to collect one. Missing, unreadable, or incomplete run
data MUST produce a visible diagnostic in the index
without preventing the rest of the book from rendering.
:::