test_hash_file_docs.py

tests/test_hash_file_docs.py

76 INDEXED FILES WITH A HEADER COMMENT AND NO FILE DOCUMENTATION.

test_a_comment_after_code_is_not_a_file_doc

None test_hash_file_docs.test_a_comment_after_code_is_not_a_file_doc()

A file whose comments start below the first code line has no file doc.

tests/test_hash_file_docs.py:152

Checks

  • assert extract_file_doc("x.sh", "set -e\n\n# This documents the next bit.\nrun\n") == ""

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-008measuredtest_a_comment_after_code_is_not_a_file_doc → extract_file_doc
Source · 6 lines
def test_a_comment_after_code_is_not_a_file_doc() -> None:
    """The block must LEAD the file. A `#` comment after the first statement documents that
    statement, and attributing it to the file would publish one function's note as the module's
    — the same error `JsFileDoc` guards against by requiring an `@file` tag.
    """
    assert extract_file_doc("x.sh", "set -e\n\n# This documents the next bit.\nrun\n") == ""

1 more lines, not shown

Activity · 1 steps
lines 157–157assert extract_file_doc("x.sh", "set -e\n\n# This documents the next bit.\nrun\n") == ""

test_a_licence_only_header_is_rejected

None test_hash_file_docs.test_a_licence_only_header_is_rejected(str header)

A licence-only header is not documentation.

tests/test_hash_file_docs.py:128

Checks

  • assert extract_file_doc("x.sh", header + "\ncode\n") == ""

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-008measuredtest_a_licence_only_header_is_rejected → extract_file_doc
Source · 8 lines
def test_a_licence_only_header_is_rejected(header: str) -> None:
    """Publishing boilerplate as documentation would add rows of it to the corpus
    `search(corpus="prose")` reads and make a real header harder to find. Asserted per shape
    because each of these appears alone at the top of real files in the measured set.
    """
    assert extract_file_doc("x.sh", header + "\ncode\n") == ""

Activity · 1 steps
lines 133–133assert extract_file_doc("x.sh", header + "\ncode\n") == ""

test_every_hash_comment_type_is_read

None test_hash_file_docs.test_every_hash_comment_type_is_read(str path)

Shell and CMake headers are read too.

tests/test_hash_file_docs.py:104

Checks

  • assert "Builds the thing" in doc, f"{path}: {doc!r}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-008measuredtest_every_hash_comment_type_is_read → extract_file_doc
Source · 10 lines
def test_every_hash_comment_type_is_read(path: str) -> None:
    """ALL SIX, because 62 of the 76 unread files are types clew already harvests — the gap was
    never specific to the ones C5 added. Claiming only `.pl` would fix one mark and leave the
    other 70 files silent.
    """
    doc = extract_file_doc(path, "# Builds the thing.\n#\n# Run it with no arguments.\n\ncode\n")

    assert "Builds the thing" in doc, f"{path}: {doc!r}"

Activity · 2 steps
lines 109–109doc = extract_file_doc(path, "# Builds the thing.\n#\n# Run it with no arguments.\n\ncode\n")lines 111–111assert "Builds the thing" in doc, f"{path}: {doc!r}"

test_licence_lines_are_dropped_from_a_real_header

None test_hash_file_docs.test_licence_lines_are_dropped_from_a_real_header()

Licence lines are dropped from a header that also carries prose.

tests/test_hash_file_docs.py:138

Checks

  • assert "Generate error.c" in doc
  • assert "SPDX" not in doc, doc
  • assert "Copyright" not in doc, doc

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-008measuredtest_licence_lines_are_dropped_from_a_real_header → extract_file_doc
Source · 12 lines
def test_licence_lines_are_dropped_from_a_real_header() -> None:
    """The Perl header above carries BOTH — two prose lines and then copyright. The block is
    accepted for the prose and the licence lines are not published, because a reader searching
    the prose corpus for a concept should not match every file that shares a licence.
    """
    doc = extract_file_doc("scripts/generate_errors.pl", PERL)

    assert "Generate error.c" in doc
    assert "SPDX" not in doc, doc
    assert "Copyright" not in doc, doc

Activity · 4 steps
lines 143–143doc = extract_file_doc("scripts/generate_errors.pl", PERL)lines 145–145assert "Generate error.c" in doclines 146–146assert "SPDX" not in doc, doclines 147–147assert "Copyright" not in doc, doc

test_the_graded_perl_header_is_extracted

None test_hash_file_docs.test_the_graded_perl_header_is_extracted()

The mbedtls Q4 header is extracted verbatim enough to answer its mark.

tests/test_hash_file_docs.py:64

Checks

  • assert doc, "a leading # block is file-level documentation"
  • assert "Generate error.c" in doc
  • assert "include_dir data_dir error_file" in doc, doc

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-008measuredtest_the_graded_perl_header_is_extracted → extract_file_doc
Source · 14 lines
def test_the_graded_perl_header_is_extracted() -> None:
    """RED BEFORE THE FIX: `.pl` matches no extractor, so this returns "".

    Asserted on the CONTENT the mark needs — that the file generates `error.c` and how it is
    invoked — rather than on an exact string, because `_clean` normalises whitespace and the
    assertion should survive that.
    """
    doc = extract_file_doc("scripts/generate_errors.pl", PERL)

    assert doc, "a leading # block is file-level documentation"
    assert "Generate error.c" in doc
    assert "include_dir data_dir error_file" in doc, doc

Activity · 4 steps
lines 71–71doc = extract_file_doc("scripts/generate_errors.pl", PERL)lines 73–73assert doc, "a leading # block is file-level documentation"lines 74–74assert "Generate error.c" in doclines 75–75assert "include_dir data_dir error_file" in doc, doc

test_the_shebang_is_skipped

None test_hash_file_docs.test_the_shebang_is_skipped()

The shebang is not part of the documentation.

tests/test_hash_file_docs.py:80

Checks

  • assert "/usr/bin/env" not in doc, doc
  • assert doc.lstrip().startswith("Generate error.c"), doc

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-008measuredtest_the_shebang_is_skipped → extract_file_doc
Source · 11 lines
def test_the_shebang_is_skipped() -> None:
    """`#!/usr/bin/env perl` is a kernel directive that happens to start with `#`. Including it
    makes every script's documentation begin with an interpreter path, which is noise in a
    corpus a reader searches by concept.
    """
    doc = extract_file_doc("scripts/generate_errors.pl", PERL)

    assert "/usr/bin/env" not in doc, doc
    assert doc.lstrip().startswith("Generate error.c"), doc

Activity · 3 steps
lines 85–85doc = extract_file_doc("scripts/generate_errors.pl", PERL)lines 87–87assert "/usr/bin/env" not in doc, doclines 88–88assert doc.lstrip().startswith("Generate error.c"), doc