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

Show on the map →

Called by none

Calls load_config

Checks

  • assert "re:" in " ".join(exc.value.problems)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_a_1x_regex_exclude_is_refused_with_a_pointer → load_config
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024inferredtest_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
lines 103–103(tmp_path / ".clew.yaml").write_text('guard:\n validate:\n exclude: ["^tests/"]\n')lines 104–104with pytest.raises(ConfigError) as exclines 105–105load_config(tmp_path / ".clew.yaml")lines 106–106assert "re:" in " ".join(exc.value.problems)

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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_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
lines 47–72assert ( 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, } }, } } ) == [] )

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

Show on the map →

Called by none

Calls load_config

Checks

  • assert "event_tags" in " ".join(exc.value.problems)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_bus_tags_moved_to_the_declaration → load_config
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024inferredtest_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
lines 137–137(tmp_path / ".clew.yaml").write_text("guard:\n validate:\n bus: {tags: [emits]}\n")lines 138–138with pytest.raises(ConfigError) as exclines 139–139load_config(tmp_path / ".clew.yaml")lines 140–140assert "event_tags" in " ".join(exc.value.problems)

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

Show on the map →

Called by none

Calls _excluded

Checks

  • assert {"tests/a.c", "gen/out.c"} <= skipped
  • assert "src/tests_util.c" not in skipped and "src/ok.c" not in skipped

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → get_file_at_revision → run_git → git_argv
REQ-DDB-CONFIG-009measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → gate_exclusion
REQ-DDB-GUARD-001measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file
REQ-DDB-GUARD-002inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_version_staleness
REQ-DDB-GUARD-003measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_tags
REQ-DDB-GUARD-004measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage
REQ-DDB-GUARD-005measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_return_presence
REQ-DDB-GUARD-006measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_file_presence
REQ-DDB-GUARD-007measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_duplicate_tags
REQ-DDB-GUARD-009inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-012measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → load_config
REQ-DDB-GUARD-013measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → unconfigured_language
REQ-DDB-GUARD-014inferredtest_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-016inferredtest_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-018measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → parse_source_file
REQ-DDB-GUARD-019measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → parse_content_for_file → language_for_file
REQ-DDB-GUARD-021inferredtest_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-023inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → get_file_at_revision
REQ-DDB-GUARD-024inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → load_config → apply_opt_in_languages
REQ-DDB-GUARD-025measuredtest_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-026measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_bus_tags
REQ-DDB-GUARD-027inferredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → check_req_exists → _uncheckable
REQ-DDB-PIPE-011measuredtest_excludes_are_globs_and_a_regex_says_so → _excluded → validate_file → gate_exclusion → binary_file
REQ-DDB-WIKI-054inferredtest_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
lines 96–96skipped = _excluded(tmp_path, monkeypatch, ["tests/**", "re:^gen/"])lines 97–97assert {"tests/a.c", "gen/out.c"} <= skippedlines 98–98assert "src/tests_util.c" not in skipped and "src/ok.c" not in skipped

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

Show on the map →

Called by none

Calls _unknown_tags

Checks

  • assert _unknown_tags(tmp_path, sources, "node") == []
  • assert _unknown_tags(tmp_path, "guard: {}\n", "node") != []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_node_is_known_when_the_wiki_declares_sources → _unknown_tags → check_unknown_tags
REQ-DDB-GUARD-012measuredtest_node_is_known_when_the_wiki_declares_sources → _unknown_tags → load_config
REQ-DDB-GUARD-024measuredtest_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
lines 148–148sources = "wiki:\n sources:\n - {name: keys, path: keys.toml}\n"lines 149–149assert _unknown_tags(tmp_path, sources, "node") == []lines 150–150assert _unknown_tags(tmp_path, "guard: {}\n", "node") != []

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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_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
lines 41–41errors = validate_config_schema(config)lines 42–42assert any(named in e for e in errors), errors

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

Show on the map →

Called by none

Calls _unknown_tags

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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_the_indexs_event_tags_are_known_to_the_gate → _unknown_tags → check_unknown_tags
REQ-DDB-GUARD-012measuredtest_the_indexs_event_tags_are_known_to_the_gate → _unknown_tags → load_config
REQ-DDB-GUARD-024measuredtest_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") != []

Activity · 3 steps
lines 130–130assert _unknown_tags(tmp_path, "event_tags: {broadcasts: producer}\n", "broadcasts") == []lines 131–131assert _unknown_tags(tmp_path, "guard: {}\n", "publishes") == []lines 132–132assert _unknown_tags(tmp_path, "guard: {}\n", "broadcasts") != []