test_script_front_end.py¶
tests/test_script_front_end.py
Shell, CMake, YAML and JSON reach the index — and each gets what its file type is.
test_a_file_merely_ending_in_the_cmake_name_is_not_cmake
None test_script_front_end.test_a_file_merely_ending_in_the_cmake_name_is_not_cmake()
The CMake name matches as a component, not as a suffix.
tests/test_script_front_end.py:213
Checks
assert claims("CMakeLists.txt")assert claims("src/CMakeLists.txt")assert not claims("oldcmakelists.txt")assert not claims("src/vendor-CMakeLists.txt")assert _ts_language_for("src/CMakeLists.txt") is not Noneassert _ts_language_for("oldcmakelists.txt") is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_a_file_merely_ending_in_the_cmake_name_is_not_cmake → has_language |
Source · 16 lines
def test_a_file_merely_ending_in_the_cmake_name_is_not_cmake() -> None:
"""THE SUFFIX TRAP. Both the router and `claims` match `CMakeLists.txt` by name, and the
cheap way to express that in a suffix table — `endswith("cmakelists.txt")` — also
matches `oldcmakelists.txt` and `vendor-cmakelists.txt`. The name is a whole path
component, so that is what is tested.
@brief The CMake name matches as a component, not as a suffix. @version 1
"""
assert claims("CMakeLists.txt")
assert claims("src/CMakeLists.txt")
assert not claims("oldcmakelists.txt")
assert not claims("src/vendor-CMakeLists.txt")
if substrate.has_language("cmake"):
assert _ts_language_for("src/CMakeLists.txt") is not None
assert _ts_language_for("oldcmakelists.txt") is None1 more lines, not shown
Activity · 7 steps
test_a_missing_grammar_routes_to_nothing_instead_of_raising
None test_script_front_end.test_a_missing_grammar_routes_to_nothing_instead_of_raising(pytest.MonkeyPatch monkeypatch)
An absent optional grammar resolves to None.
tests/test_script_front_end.py:128
Checks
assert _ts_language_for("scripts/deploy.sh") is Noneassert _ts_language_for("CMakeLists.txt") is Noneassert _ts_language_for("src/main.c") is not None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_missing_grammar_routes_to_nothing_instead_of_raising → _ts_language_for → _grammar_available → has_language |
Source · 16 lines
def test_a_missing_grammar_routes_to_nothing_instead_of_raising(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""THE DEGRADE, pinned. `parse_tree` raises ValueError for an unknown key, so the
router must refuse the route rather than hand the build a grammar it cannot use.
@brief An absent optional grammar resolves to None. @version 1
"""
monkeypatch.setattr(substrate, "has_language", lambda key: key not in {"bash", "cmake"})
assert _ts_language_for("scripts/deploy.sh") is None
assert _ts_language_for("CMakeLists.txt") is None
## The always-present grammars are NOT gated: a wheel without them is a broken
## install, and failing loudly is correct there.
assert _ts_language_for("src/main.c") is not None
Activity · 4 steps
test_a_shell_script_routes_to_the_bash_grammar
None test_script_front_end.test_a_shell_script_routes_to_the_bash_grammar()
`.sh` resolves a grammar.
tests/test_script_front_end.py:104
Checks
assert grammar is not Noneassert grammar.key == "bash"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_a_shell_script_routes_to_the_bash_grammar → has_language |
Source · 9 lines
def test_a_shell_script_routes_to_the_bash_grammar() -> None:
"""@brief `.sh` resolves a grammar. @version 1"""
if not substrate.has_language("bash"):
pytest.skip("substrate has no bash grammar; clew requires lang-parsing-substrate>=0.12.0")
grammar = _ts_language_for("scripts/deploy.sh")
assert grammar is not None
assert grammar.key == "bash"
Activity · 5 steps
test_shell_and_cmake_definitions_become_rows
None test_script_front_end.test_shell_and_cmake_definitions_become_rows(tuple[Path, Path] repo)
A shell function and a CMake function and macro are written as rows.
tests/test_script_front_end.py:173
Checks
assert members == {
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-INDEX-004 | measured | test_shell_and_cmake_definitions_become_rows → emit_definitions → ensure_symbol_provenance |
| REQ-DDB-PIPE-003 | measured | test_shell_and_cmake_definitions_become_rows → emit_definitions → run_harvest |
| REQ-DDB-PIPE-011 | measured | test_shell_and_cmake_definitions_become_rows → emit_definitions → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_shell_and_cmake_definitions_become_rows → missing_languages |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-014 | measured | test_shell_and_cmake_definitions_become_rows → emit_definitions → ensure_generated_files_table |
Source · 21 lines
def test_shell_and_cmake_definitions_become_rows(repo: tuple[Path, Path]) -> None:
"""The end-to-end path: registration, the shared harvest's dispatch, and the writer.
@brief A shell function and a CMake function and macro are written as rows. @version 1
"""
db, root = repo
missing = substrate.missing_languages(("bash", "cmake"))
if missing:
pytest.skip(f"substrate lacks {missing}; clew requires lang-parsing-substrate>=0.12.0")
register_paths(db, ["scripts/deploy.sh", "CMakeLists.txt", "config.yaml"])
emit_definitions(db, root, None)
members = _members(db)
assert members == {
"deploy": "function",
"add_firmware": "function",
"strict_warnings": "macro definition",
}
Activity · 8 steps
test_the_cmake_file_name_routes_even_though_its_extension_is_txt
None test_script_front_end.test_the_cmake_file_name_routes_even_though_its_extension_is_txt()
The CMake file name routes; a plain `.txt` does not.
tests/test_script_front_end.py:113
Checks
assert named is not None and named.key == "cmake"assert _ts_language_for("src/CMakeLists.txt") is not Noneassert _ts_language_for("notes.txt") is Noneassert _ts_language_for("requirements.txt") is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_the_cmake_file_name_routes_even_though_its_extension_is_txt → has_language |
Source · 15 lines
def test_the_cmake_file_name_routes_even_though_its_extension_is_txt() -> None:
"""`CMakeLists.txt` is named, not suffixed — and `.txt` must NOT route to CMake, or
every README.txt in the tree would be parsed as a build script.
@brief The CMake file name routes; a plain `.txt` does not. @version 1
"""
if not substrate.has_language("cmake"):
pytest.skip("substrate has no cmake grammar; clew requires lang-parsing-substrate>=0.12.0")
named = _ts_language_for("CMakeLists.txt")
assert named is not None and named.key == "cmake"
assert _ts_language_for("src/CMakeLists.txt") is not None
assert _ts_language_for("notes.txt") is None
assert _ts_language_for("requirements.txt") is None
Activity · 7 steps
test_the_data_files_are_in_the_file_set_with_no_symbols
None test_script_front_end.test_the_data_files_are_in_the_file_set_with_no_symbols(tuple[Path, Path] repo)
YAML and JSON are registered and carry no memberdef rows.
tests/test_script_front_end.py:161
Checks
assert _paths(db) == {"config.yaml", "data.json"}assert _members(db) == {}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_the_data_files_are_in_the_file_set_with_no_symbols → emit_definitions → ensure_symbol_provenance |
| REQ-DDB-PIPE-003 | measured | test_the_data_files_are_in_the_file_set_with_no_symbols → emit_definitions → run_harvest |
| REQ-DDB-PIPE-011 | inferred | test_the_data_files_are_in_the_file_set_with_no_symbols → emit_definitions → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_the_data_files_are_in_the_file_set_with_no_symbols → emit_definitions |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-014 | measured | test_the_data_files_are_in_the_file_set_with_no_symbols → emit_definitions → ensure_generated_files_table |
Source · 12 lines
def test_the_data_files_are_in_the_file_set_with_no_symbols(repo: tuple[Path, Path]) -> None:
"""@brief YAML and JSON are registered and carry no memberdef rows. @version 1"""
db, root = repo
scanned = ["config.yaml", "data.json", "src/main.c"]
register_paths(db, scanned)
assert _paths(db) == {"config.yaml", "data.json"}
emit_definitions(db, root, None)
assert _members(db) == {}
Activity · 6 steps
test_the_shell_doc_block_reaches_the_row
None test_script_front_end.test_the_shell_doc_block_reaches_the_row(tuple[Path, Path] repo)
The `#` block above a shell function becomes its brief.
tests/test_script_front_end.py:194
Checks
assert "Deploy the built artefact." in brief
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-INDEX-004 | measured | test_the_shell_doc_block_reaches_the_row → emit_definitions → ensure_symbol_provenance |
| REQ-DDB-PIPE-003 | measured | test_the_shell_doc_block_reaches_the_row → emit_definitions → run_harvest |
| REQ-DDB-PIPE-011 | measured | test_the_shell_doc_block_reaches_the_row → emit_definitions → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_the_shell_doc_block_reaches_the_row → has_language |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-014 | measured | test_the_shell_doc_block_reaches_the_row → emit_definitions → ensure_generated_files_table |
Source · 19 lines
def test_the_shell_doc_block_reaches_the_row(repo: tuple[Path, Path]) -> None:
"""@brief The `#` block above a shell function becomes its brief. @version 1"""
db, root = repo
if not substrate.has_language("bash"):
pytest.skip("substrate has no bash grammar; clew requires lang-parsing-substrate>=0.12.0")
register_paths(db, ["scripts/deploy.sh"])
emit_definitions(db, root, None)
conn = sqlite3.connect(str(db))
try:
brief = conn.execute(
"SELECT briefdescription FROM memberdef WHERE name = 'deploy'"
).fetchone()[0]
finally:
conn.close()
assert "Deploy the built artefact." in brief