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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-008 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-008 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-008 | measured | test_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
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 docassert "SPDX" not in doc, docassert "Copyright" not in doc, doc
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-008 | measured | test_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
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 docassert "include_dir data_dir error_file" in doc, doc
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-008 | measured | test_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
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, docassert doc.lstrip().startswith("Generate error.c"), doc
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-008 | measured | test_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