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.guidance

Requirements index · View definition

evidence Valid

Requirement

The generated coverage subchapter MUST make coverage-collection and post-suite-checking guidance available under cite requirements.test-coverage.check.guidance, without requiring separate authored content.

Rationale

Obligation. requirements.test-coverage.index.guidance says the generated coverage subchapter MUST make coverage-collection and post-suite-checking guidance available. That guidance is the content requirements.test-coverage.check.guidance describes. It must appear without separate authored content.

Test. src/execution_coverage/book.rs#mod[tests]/fn[generated_reports_inherit_the_requirements_index_hierarchy] is marked {test} for both index.guidance and check.guidance. Its authored input is minimal. The fixture helper creates a chapter whose only content is the bare :::{coverage-index} directive. The parent chapter holds only a heading. The test then runs populate_in, the production path, and asserts on the generated coverage chapter’s content.

Mapping.

  • Collection and checking commands. The test asserts the generated content contains habeas test, habeas coverage -- --workspace and habeas coverage-check. It also asserts the phrase “after it succeeds,\nrun habeas coverage-check as a separate step”. That covers the recommendation to run the check as a separate step after the instrumented run.
  • habeas test ordering. It asserts the phrase “habeas test collects coverage for the whole workspace,\nthen checks it”. That covers habeas test as the command that runs collection and then checking in order.
  • Static validation test. It asserts “static validation test needs no prior coverage”, which covers the clause that the static validation test and coverage checking do not depend on order.
  • Related setup guidance. It also asserts several other phrases. These include the 80% target, habeas:coverage, the current accepted review, “No project declaration or special configuration”, and the prose-justification and habeas author text.
  • No authored content. It asserts the :::{coverage-index} directive no longer appears in the output. Together with the near-empty fixture, this shows the guidance is generated rather than authored.
  • Hierarchy. The test is parameterized over numbered and unnumbered parents. That covers the “under the subchapter” placement for both parent shapes.

Gaps. None found. The assertions check specific guidance text, so an implementation that omitted the guidance, or relied on authored content, would fail. The requirement’s other obligations, such as the bundled agent instructions and the content of the static validation test, belong to check.guidance itself. They are not assessed here.

Inputs

Tests

Input 3: outline src/execution_coverage/book.rs mod[tests]/fn[generated_reports_inherit_the_requirements_index_hierarchy]
    // {test}`requirements.test-coverage.index`
    // {test}`requirements.test-coverage.index.navigation`
    // {test}`requirements.test-coverage.index.source`
    // {test}`requirements.test-coverage.index.guidance`
    // {test}`requirements.test-coverage.check.guidance`
    // {test}`requirements.test-coverage.check.exceptions.setup`
    // {test}`requirements.test-coverage.index.details`
    #[test]
    fn generated_reports_inherit_the_requirements_index_hierarchy() {
        for number in [Some(SectionNumber::new(vec![3, 2])), None] {
            let (temp, mut book) = fixture();
            let BookItem::Chapter(parent) = &mut book.items[0] else {
                unreachable!()
            };
            parent.path = Some("reports.md".into());
            parent.name = "Requirements index".into();
            parent.content = "# Requirements index\n".into();
            parent.parent_names = vec!["Reports".into()];
            parent.number = number.clone();
            parent.sub_items.push(BookItem::Chapter(Chapter::new(
                "Guide",
                "# Guide\n".into(),
                "reports/guide.md",
                vec![],
            )));
            record(temp.path(), "one", 1, "a", &[(1, 1)]);
            // Build fixture configuration before invoking the production path.
            fs::create_dir(temp.path().join("md")).unwrap();
            fs::write(temp.path().join("book.toml"), "[book]\nsrc='md'\n").unwrap();
            fs::write(temp.path().join("md/SUMMARY.md"), "# Summary\n").unwrap();
            super::populate_in(
                &mut book,
                temp.path(),
                Some(temp.path().join("target")),
                Path::new("reports.md"),
            )
            .unwrap();
            let BookItem::Chapter(parent) = &book.items[0] else {
                unreachable!()
            };
            assert!(
                parent
                    .content
                    .contains("[Coverage gaps](reports/coverage.html)")
            );
            assert_eq!(parent.number, number);
            let BookItem::Chapter(coverage) = &parent.sub_items[0] else {
                unreachable!()
            };
            assert_eq!(coverage.parent_names, ["Reports", "Requirements index"]);
            assert_eq!(
                coverage.path.as_deref(),
                Some(Path::new("reports/coverage.md"))
            );
            assert!(coverage.source_path.is_none());
            assert_eq!(
                coverage.number,
                number.as_ref().map(|_| SectionNumber::new(vec![3, 2, 1]))
            );
            assert_eq!(parent.sub_items.len(), 2);
            for (offset, item) in coverage.sub_items.iter().enumerate() {
                let BookItem::Chapter(page) = item else {
                    unreachable!()
                };
                assert_eq!(
                    page.parent_names,
                    ["Reports", "Requirements index", "Coverage gaps"]
                );
                assert_eq!(
                    page.number,
                    number
                        .as_ref()
                        .map(|_| SectionNumber::new(vec![3, 2, 1, offset as u32 + 1]))
                );
                assert!(page.source_path.is_none());
                assert!(page.content.contains("../coverage.html"));
            }
            for guidance in [
                "habeas test",
                "habeas coverage -- --workspace",
                "habeas coverage-check",
                "static validation test needs no prior coverage",
                "80%",
                "habeas:coverage",
                "current accepted review",
                "No project declaration or special configuration",
                "after it succeeds,\nrun `habeas coverage-check` as a separate step",
                "`habeas test` collects coverage for the whole workspace,\nthen checks it",
                "substantive prose justification",
                "fenced commentary or a Rust doc comment",
                "citation review with `habeas author`",
                "Ordinary partly covered functions\nneed no exception when their file meets its target",
            ] {
                assert!(
                    coverage.content.contains(guidance),
                    "missing generated guidance: {guidance}"
                );
            }
            assert!(!coverage.content.contains(":::{coverage-index}"));
        }
    }

Referenced definitions

Input 2: requirements selection requirements.test-coverage.check.guidance
:::{req} check.guidance
Habeas's bundled agent instructions and setup-generated coverage documentation
MUST recommend running `habeas coverage-check` after a successful full-workspace
instrumented nextest run using `habeas coverage -- --workspace`, as a separate
CI step. They MUST document `habeas test` as the command running collection and
post-suite checking in order under {cite}`requirements.test-coverage.test`.

The static validation test MUST NOT require current collected execution
coverage or validate exception applicability against current runtime gaps.
Those checks belong to the post-suite coverage command. Coverage checking
MUST NOT depend on running the static validation test last.
:::

Other sources

Input 1: requirements selection requirements.test-coverage.index.guidance
:::{req} index.guidance
The generated coverage subchapter MUST make coverage-collection and
post-suite-checking guidance available under
{cite}`requirements.test-coverage.check.guidance`, without requiring
separate authored content.
:::
Input 4: outline src/execution_coverage/book.rs mod[tests]/fn[fixture]
    fn fixture() -> (tempfile::TempDir, Book) {
        let temp = tempfile::tempdir().unwrap();
        fs::write(temp.path().join("Cargo.toml"), "[workspace]\n").unwrap();
        fs::write(temp.path().join("code.rs"), "fn one() {}\nfn two() {}\n").unwrap();
        let mut book = Book::new();
        book.push_item(Chapter::new(
            "Coverage",
            ":::{coverage-index}\n:::\n".into(),
            "reports/coverage.md",
            vec![],
        ));
        (temp, book)
    }