test_declaration_validated.py¶
tests/test_declaration_validated.py
The checked-in `.clew.yaml` is validated as strictly as a stated option (R5-CFG F1/F4/F5/F26).
test_a_list_section_written_as_one_string_is_one_entry
None test_declaration_validated.test_a_list_section_written_as_one_string_is_one_entry(Path tmp_path)
A string list section is normalised; a wrong type is refused.
tests/test_declaration_validated.py:93
Checks
assert load_declaration(_declare(tmp_path, "vendored: extern\n"))["vendored"] == ["extern"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_list_section_written_as_one_string_is_one_entry → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_a_list_section_written_as_one_string_is_one_entry → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_a_list_section_written_as_one_string_is_one_entry → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 12 lines
def test_a_list_section_written_as_one_string_is_one_entry(tmp_path: Path) -> None:
"""F5 for the index: `vendored: extern` was iterated as `e, x, t, e, r, n`. A bare string is a
one-item list (the precedent `gcov` and `theme.css` already set); any other non-list is refused
rather than warned and ignored (F26).
@brief A string list section is normalised; a wrong type is refused.
"""
assert load_declaration(_declare(tmp_path, "vendored: extern\n"))["vendored"] == ["extern"]
with pytest.raises(DeclarationError, match="entry_patterns"):
load_declaration(_declare(tmp_path, "entry_patterns: {main: 1}\n"))
Activity · 3 steps
test_a_mapping_section_written_as_a_scalar_is_refused
None test_declaration_validated.test_a_mapping_section_written_as_a_scalar_is_refused(Path tmp_path)
A non-mapping manifest section is refused.
tests/test_declaration_validated.py:83
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_mapping_section_written_as_a_scalar_is_refused → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_a_mapping_section_written_as_a_scalar_is_refused → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_a_mapping_section_written_as_a_scalar_is_refused → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 10 lines
def test_a_mapping_section_written_as_a_scalar_is_refused(tmp_path: Path) -> None:
"""A path string under `thread_patterns:` was dropped by `section()` (mapping-or-None), so the
build ran on built-in spawn patterns. In-tree, a manifest section is the document inline.
@brief A non-mapping manifest section is refused.
"""
with pytest.raises(DeclarationError, match="thread_patterns"):
load_declaration(_declare(tmp_path, "thread_patterns: patterns.yaml\n"))
Activity · 2 steps
test_a_path_section_must_be_a_string
None test_declaration_validated.test_a_path_section_must_be_a_string(Path tmp_path)
A non-string path section is refused.
tests/test_declaration_validated.py:105
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_path_section_must_be_a_string → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_a_path_section_must_be_a_string → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_a_path_section_must_be_a_string → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 7 lines
def test_a_path_section_must_be_a_string(tmp_path: Path) -> None:
"""F26: `doxyfile: [a, b]` warned and was ignored. A path section is one path.
@brief A non-string path section is refused.
"""
with pytest.raises(DeclarationError, match="doxyfile"):
load_declaration(_declare(tmp_path, "doxyfile: [a, b]\n"))1 more lines, not shown
Activity · 2 steps
test_a_section_document_key_nothing_reads_is_refused
None test_declaration_validated.test_a_section_document_key_nothing_reads_is_refused(Path tmp_path, str text, str named)
preprocessor and kconfig keys are allow-listed.
tests/test_declaration_validated.py:54
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_section_document_key_nothing_reads_is_refused → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_a_section_document_key_nothing_reads_is_refused → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_a_section_document_key_nothing_reads_is_refused → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 13 lines
def test_a_section_document_key_nothing_reads_is_refused(
tmp_path: Path, text: str, named: str
) -> None:
"""F4 / F2a: `preprocessor: {predefine: [FOO]}` recorded a DECLARED configuration with no
macros; `kconfig: {path: ...}` (the documented spelling, wrong) was ignored and the root
Kconfig picked by convention.
@brief preprocessor and kconfig keys are allow-listed.
"""
with pytest.raises(DeclarationError, match=repr(named)):
load_declaration(_declare(tmp_path, text))
Activity · 2 steps
test_an_unknown_manifest_entry_key_is_refused_in_tree
None test_declaration_validated.test_an_unknown_manifest_entry_key_is_refused_in_tree(Path tmp_path)
The in-tree file is checked against MANIFEST_SCHEMAS.
tests/test_declaration_validated.py:33
Checks
assert load_declaration(tmp_path)["thread_patterns"]["spawns"][0]["entry_arg_index"] == 2
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_unknown_manifest_entry_key_is_refused_in_tree → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_an_unknown_manifest_entry_key_is_refused_in_tree → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_an_unknown_manifest_entry_key_is_refused_in_tree → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 21 lines
def test_an_unknown_manifest_entry_key_is_refused_in_tree(tmp_path: Path) -> None:
"""F1: `entry_arg_idx` for `entry_arg_index` keyed a spawn off argument 0 with no word said.
@brief The in-tree file is checked against MANIFEST_SCHEMAS.
"""
bad = _declare(tmp_path, "thread_patterns:\n spawns:\n - {name: Spawn, entry_arg_idx: 2}\n")
with pytest.raises(DeclarationError, match="entry_arg_idx"):
load_declaration(bad)
(tmp_path / ".clew.yaml").write_text(
"thread_patterns:\n spawns:\n - {name: Spawn, entry_arg_index: 2}\n", encoding="utf-8"
)
assert load_declaration(tmp_path)["thread_patterns"]["spawns"][0]["entry_arg_index"] == 2
@pytest.mark.parametrize(
("text", "named"),
[
("preprocessor:\n predefine: [FOO]\n", "predefine"),
("kconfig:\n path: sub/Kconfig\n", "path"),
],
)