test_guard_schema_closed.py¶
tests/guard/test_guard_schema_closed.py
The gate's own section is closed, globbed and agrees with the index's vocabulary (R5-CFG F10-F13, F18).
test_a_1x_regex_exclude_is_refused_with_a_pointer
None test_guard_schema_closed.test_a_1x_regex_exclude_is_refused_with_a_pointer(Path tmp_path)
`^tests/` (the 1.x regex form) is refused naming the glob and `re:` forms.
tests/guard/test_guard_schema_closed.py:101
Checks
assert "re:" in " ".join(exc.value.problems)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_a_1x_regex_exclude_is_refused_with_a_pointer → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_a_1x_regex_exclude_is_refused_with_a_pointer → load_config → apply_opt_in_languages |
Source · 8 lines
def test_a_1x_regex_exclude_is_refused_with_a_pointer(tmp_path: Path) -> None:
"""@brief `^tests/` (the 1.x regex form) is refused naming the glob and `re:` forms."""
(tmp_path / ".clew.yaml").write_text('guard:\n validate:\n exclude: ["^tests/"]\n')
with pytest.raises(ConfigError) as exc:
load_config(tmp_path / ".clew.yaml")
assert "re:" in " ".join(exc.value.problems)
Activity · 4 steps
test_a_well_formed_tag_and_language_pass
None test_guard_schema_closed.test_a_well_formed_tag_and_language_pass()
The documented per-entry keys are accepted, for a new tag and a new language too.
tests/guard/test_guard_schema_closed.py:45
Checks
assert (validate_config_schema({ "validate": { "tags": { "req": {"pattern": "^R-[0-9]+$", "cross_reference": True}, "owner": { "pattern": ".+",
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_a_well_formed_tag_and_language_pass → validate_config_schema |
Source · 30 lines
def test_a_well_formed_tag_and_language_pass() -> None:
"""@brief The documented per-entry keys are accepted, for a new tag and a new language too."""
assert (
validate_config_schema(
{
"validate": {
"tags": {
"req": {"pattern": "^R-[0-9]+$", "cross_reference": True},
"owner": {
"pattern": ".+",
"require_prefix": ["@"],
"require_contains": "x",
},
},
"languages": {
"kotlin": {
"extensions": [".kt"],
"function_pattern": "fun (\\w+)",
"exclude_names": [],
"comment_style": {"start": "/\\*\\*", "end": "\\*/"},
"require_return": False,
}
},
}
}
)
== []
)
Activity · 1 steps
test_bus_tags_moved_to_the_declaration
None test_guard_schema_closed.test_bus_tags_moved_to_the_declaration(Path tmp_path)
`validate.bus.tags` is refused naming the top-level `event_tags:`.
tests/guard/test_guard_schema_closed.py:135
Checks
assert "event_tags" in " ".join(exc.value.problems)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_bus_tags_moved_to_the_declaration → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_bus_tags_moved_to_the_declaration → load_config → apply_opt_in_languages |
Source · 8 lines
def test_bus_tags_moved_to_the_declaration(tmp_path: Path) -> None:
"""@brief `validate.bus.tags` is refused naming the top-level `event_tags:`."""
(tmp_path / ".clew.yaml").write_text("guard:\n validate:\n bus: {tags: [emits]}\n")
with pytest.raises(ConfigError) as exc:
load_config(tmp_path / ".clew.yaml")
assert "event_tags" in " ".join(exc.value.problems)
Activity · 4 steps
test_excludes_are_globs_and_a_regex_says_so
None test_guard_schema_closed.test_excludes_are_globs_and_a_regex_says_so(Path tmp_path, pytest.MonkeyPatch monkeypatch)
Globs by default, `re:` for a regex.
tests/guard/test_guard_schema_closed.py:89
Checks
assert {"tests/a.c", "gen/out.c"} <= skippedassert "src/tests_util.c" not in skipped and "src/ok.c" not in skipped
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → get_file_at_revision → run_git → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → gate_exclusion |
| REQ-DDB-GUARD-001 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file |
| REQ-DDB-GUARD-002 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_version_staleness |
| REQ-DDB-GUARD-003 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_tags |
| REQ-DDB-GUARD-004 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage |
| REQ-DDB-GUARD-005 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_return_presence |
| REQ-DDB-GUARD-006 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_file_presence |
| REQ-DDB-GUARD-007 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_duplicate_tags |
| REQ-DDB-GUARD-009 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-012 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → load_config |
| REQ-DDB-GUARD-013 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → unconfigured_language |
| REQ-DDB-GUARD-014 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id |
| REQ-DDB-GUARD-018 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → parse_source_file |
| REQ-DDB-GUARD-019 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-023 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → get_file_at_revision |
| REQ-DDB-GUARD-024 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-025 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-026 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_bus_tags |
| REQ-DDB-GUARD-027 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_exists → _uncheckable |
| REQ-DDB-PIPE-011 | measured | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → gate_exclusion → binary_file |
| REQ-DDB-WIKI-054 | inferred | test_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 12 lines
def test_excludes_are_globs_and_a_regex_says_so(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""F18: `tests/**` is a glob (it does not exclude `src/tests_util.c`); a regex needs `re:`.
@brief Globs by default, `re:` for a regex.
"""
skipped = _excluded(tmp_path, monkeypatch, ["tests/**", "re:^gen/"])
assert {"tests/a.c", "gen/out.c"} <= skipped
assert "src/tests_util.c" not in skipped and "src/ok.c" not in skipped
Activity · 3 steps
test_node_is_known_when_the_wiki_declares_sources
None test_guard_schema_closed.test_node_is_known_when_the_wiki_declares_sources(Path tmp_path)
`@node` follows `wiki.sources`.
tests/guard/test_guard_schema_closed.py:143
Checks
assert _unknown_tags(tmp_path, sources, "node") == []assert _unknown_tags(tmp_path, "guard: {}\n", "node") != []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_node_is_known_when_the_wiki_declares_sources → _unknown_tags → check_unknown_tags |
| REQ-DDB-GUARD-012 | measured | test_node_is_known_when_the_wiki_declares_sources → _unknown_tags → load_config |
| REQ-DDB-GUARD-024 | measured | test_node_is_known_when_the_wiki_declares_sources → _unknown_tags → load_config → apply_opt_in_languages |
Source · 10 lines
def test_node_is_known_when_the_wiki_declares_sources(tmp_path: Path) -> None:
"""F11: `wiki.sources` asks authors for `@node`; the gate accepts it there, and only there.
@brief `@node` follows `wiki.sources`.
"""
sources = "wiki:\n sources:\n - {name: keys, path: keys.toml}\n"
assert _unknown_tags(tmp_path, sources, "node") == []
assert _unknown_tags(tmp_path, "guard: {}\n", "node") != []
Activity · 3 steps
test_tag_and_language_entries_are_checked
None test_guard_schema_closed.test_tag_and_language_entries_are_checked(dict config, str named)
A misspelled per-tag or per-language key is refused by name.
tests/guard/test_guard_schema_closed.py:39
Checks
assert any(named in e for e in errors), errors
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_tag_and_language_entries_are_checked → validate_config_schema |
Source · 6 lines
def test_tag_and_language_entries_are_checked(config: dict, named: str) -> None:
"""@brief A misspelled per-tag or per-language key is refused by name."""
errors = validate_config_schema(config)
assert any(named in e for e in errors), errors
Activity · 2 steps
test_the_indexs_event_tags_are_known_to_the_gate
None test_guard_schema_closed.test_the_indexs_event_tags_are_known_to_the_gate(Path tmp_path)
One event vocabulary.
tests/guard/test_guard_schema_closed.py:125
Checks
assert _unknown_tags(tmp_path, "event_tags: {broadcasts: producer}\n", "broadcasts") == []assert _unknown_tags(tmp_path, "guard: {}\n", "publishes") == []assert _unknown_tags(tmp_path, "guard: {}\n", "broadcasts") != []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_the_indexs_event_tags_are_known_to_the_gate → _unknown_tags → check_unknown_tags |
| REQ-DDB-GUARD-012 | measured | test_the_indexs_event_tags_are_known_to_the_gate → _unknown_tags → load_config |
| REQ-DDB-GUARD-024 | measured | test_the_indexs_event_tags_are_known_to_the_gate → _unknown_tags → load_config → apply_opt_in_languages |
Source · 10 lines
def test_the_indexs_event_tags_are_known_to_the_gate(tmp_path: Path) -> None:
"""F10: a declared `event_tags:` word, and the index's built-in vocabulary, are known tags.
@brief One event vocabulary.
"""
assert _unknown_tags(tmp_path, "event_tags: {broadcasts: producer}\n", "broadcasts") == []
assert _unknown_tags(tmp_path, "guard: {}\n", "publishes") == []
assert _unknown_tags(tmp_path, "guard: {}\n", "broadcasts") != []