test_guard_main.py

tests/guard/test_guard_main.py

Tests for clew.guard.main (absorbed from doxygen-guard).

test_a_checked_tree_says_nothing_extra

test_guard_main.TestSkipsAreReported.test_a_checked_tree_says_nothing_extra(self, tmp_path, monkeypatch, capsys)

No skip line when every file was checked.

tests/guard/test_guard_main.py:403

Show on the map →

Called by none

Calls _dirty_tree

Checks

  • assert rc == 1
  • assert "not checked" not in captured.out + captured.err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 16 lines
    def test_a_checked_tree_says_nothing_extra(self, tmp_path, monkeypatch, capsys):
        """The line is evidence of a skip, not decoration: with nothing skipped it must not
        appear, or it becomes noise an owner learns to ignore.

        @brief No skip line when every file was checked. @version 1
        """
        dirty = self._dirty_tree(tmp_path)
        monkeypatch.chdir(tmp_path)

        rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(dirty)])

        captured = capsys.readouterr()
        assert rc == 1
        assert "not checked" not in captured.out + captured.err

Activity · 6 steps
lines 409–409dirty = self._dirty_tree(tmp_path)lines 410–410monkeypatch.chdir(tmp_path)lines 412–412rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(dirty)])lines 414–414captured = capsys.readouterr()lines 415–415assert rc == 1lines 416–416assert "not checked" not in captured.out + captured.err

test_a_configured_language_is_not_reported

test_guard_main.TestUnconfiguredLanguagesAreReported.test_a_configured_language_is_not_reported(self, tmp_path, monkeypatch, capsys)

A language the config enables is checked, not reported as skipped.

tests/guard/test_guard_main.py:470

Show on the map →

Called by none

Calls none

Checks

  • assert rc == 1, "C is configured by default, so the undocumented function must fail"
  • assert "not checked" not in surface

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 11 lines
    def test_a_configured_language_is_not_reported(self, tmp_path, monkeypatch, capsys):
        """@brief A language the config enables is checked, not reported as skipped. @version 1"""
        c_file = tmp_path / "thing.c"
        c_file.write_text("void Undoc_Func(void) {\n    do_stuff();\n}\n")
        monkeypatch.chdir(tmp_path)

        rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(c_file)])

        surface = "".join(capsys.readouterr())
        assert rc == 1, "C is configured by default, so the undocumented function must fail"
        assert "not checked" not in surface

1 more lines, not shown

Activity · 7 steps
lines 472–472c_file = tmp_path / "thing.c"lines 473–473c_file.write_text("void Undoc_Func(void) {\n do_stuff();\n}\n")lines 474–474monkeypatch.chdir(tmp_path)lines 476–476rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(c_file)])lines 478–478surface = "".join(capsys.readouterr())lines 479–479assert rc == 1, "C is configured by default, so the undocumented function must fail"lines 480–480assert "not checked" not in surface

test_a_non_source_file_stays_silent

test_guard_main.TestUnconfiguredLanguagesAreReported.test_a_non_source_file_stays_silent(self, tmp_path, monkeypatch, capsys)

A file no shipped language claims produces no report.

tests/guard/test_guard_main.py:455

Show on the map →

Called by none

Calls none

Checks

  • assert rc == 0
  • assert "not checked" not in "".join(capsys.readouterr())

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 15 lines
    def test_a_non_source_file_stays_silent(self, tmp_path, monkeypatch, capsys):
        """THE CONTROL that keeps the line where it is. The gate ships no language for
        Markdown, so Markdown is not something it failed to check.

        @brief A file no shipped language claims produces no report. @version 1
        """
        doc = tmp_path / "README.md"
        doc.write_text("# hello\n")
        monkeypatch.chdir(tmp_path)

        rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(doc)])

        assert rc == 0
        assert "not checked" not in "".join(capsys.readouterr())
Activity · 6 steps
lines 461–461doc = tmp_path / "README.md"lines 462–462doc.write_text("# hello\n")lines 463–463monkeypatch.chdir(tmp_path)lines 465–465rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(doc)])lines 467–467assert rc == 0lines 468–468assert "not checked" not in "".join(capsys.readouterr())

test_a_symlinked_impact_directory_is_refused

test_guard_main.TestPrecommitPipeline.test_a_symlinked_impact_directory_is_refused(self, tmp_path, monkeypatch)

M5, 1.1.0 SECURITY AUDIT. `run_precommit` validated `output_dir` and then wrote to `output_dir/impact/impact.md` — a DIFFERENT path. A committed `out/impact -> ../../elsewhere` passes the check on `out/`, `mkdir(exist_ok=True)` follows it, and the gate writes the report outside the repository and `git add`s it, all while running as the committing user on a branch they are only reviewing.

tests/guard/test_guard_main.py:233

Show on the map →

Called by none

Calls guard_yaml, list

Checks

  • assert rc != 0, "the gate must fail rather than write through the symlink"
  • assert not list(outside.iterdir()), (f"the gate wrote outside the repository through a symlinked impact directory: " f"{list(outside.iterdir())}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-002measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-023measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 57 lines
    def test_a_symlinked_impact_directory_is_refused(self, tmp_path, monkeypatch):
        """M5, 1.1.0 SECURITY AUDIT. `run_precommit` validated `output_dir` and then wrote to
        `output_dir/impact/impact.md` — a DIFFERENT path. A committed
        `out/impact -> ../../elsewhere` passes the check on `out/`, `mkdir(exist_ok=True)`
        follows it, and the gate writes the report outside the repository and `git add`s it,
        all while running as the committing user on a branch they are only reviewing.

        The full write path is validated, which is what the sibling in `_run_impact_command`
        already did with its `output.file`.
        """
        monkeypatch.chdir(tmp_path)
        outside = tmp_path.parent / f"escaped-{tmp_path.name}"
        outside.mkdir(exist_ok=True)
        src = tmp_path / "src"
        src.mkdir()
        c_file = src / "test.c"
        c_file.write_text(
            dedent("""\
                /**
                 * @brief Process data.
                 * @version 1.0
                 * @req REQ-001
                 */
                void Process(void) {
                    event_post(EVENT_DATA_READY);
                }
            """)
        )
        (tmp_path / "reqs.csv").write_text("Req ID,Name,Subsystem\nREQ-001,Data,DataSvc\n")
        (tmp_path / "out").mkdir()
        (tmp_path / "out" / "impact").symlink_to(outside)
        config_file = tmp_path / ".clew.yaml"
        ## FIXTURE CHANGED (2.0.0, R5-CFG F7/F9): the catalog is the top-level `requirements:`
        ## and the report directory is `guard.impact.report_dir` (it was `output_dir/impact/`).
        config_file.write_text(
            dedent("""\
                requirements:
                  file: reqs.csv
                  id_column: "Req ID"
                  name_column: "Name"
                  format: csv
            """)
            + guard_yaml("impact:\n  report_dir: out/impact/\n")
        )

        ## `main` IS THE CLI BOUNDARY and turns a GuardError into an exit code rather than a
        ## traceback — so the refusal is asserted as the gate's own failure, which is what a
        ## committing developer actually sees.
        rc = main(["--config", str(config_file), str(c_file)])

        assert rc != 0, "the gate must fail rather than write through the symlink"
        assert not list(outside.iterdir()), (
            f"the gate wrote outside the repository through a symlinked impact directory: "
            f"{list(outside.iterdir())}"
        )

Activity · 15 steps
lines 243–243monkeypatch.chdir(tmp_path)lines 244–244outside = tmp_path.parent / f"escaped-{tmp_path.name}"lines 245–245outside.mkdir(exist_ok=True)lines 246–246src = tmp_path / "src"lines 247–247src.mkdir()lines 248–248c_file = src / "test.c"lines 249–260c_file.write_text( dedent("""\ /** * @brief Process data. * @version 1.0 * @req REQ-001 */ void Process(void) { event_post(EVENT_DATA_READY); } """) )lines 261–261(tmp_path / "reqs.csv").write_text("Req ID,Name,Subsystem\nREQ-001,Data,DataSvc\n")lines 262–262(tmp_path / "out").mkdir()lines 263–263(tmp_path / "out" / "impact").symlink_to(outside)lines 264–264config_file = tmp_path / ".clew.yaml"lines 267–276config_file.write_text( dedent("""\ requirements: file: reqs.csv id_column: "Req ID" name_column: "Name" format: csv """) + guard_yaml("impact:\n report_dir: out/impact/\n") )lines 281–281rc = main(["--config", str(config_file), str(c_file)])lines 283–283assert rc != 0, "the gate must fail rather than write through the symlink"lines 284–287assert not list(outside.iterdir()), ( f"the gate wrote outside the repository through a symlinked impact directory: " f"{list(outside.iterdir())}" )

test_all_checks_run

test_guard_main.TestValidateFile.test_all_checks_run(self, tmp_path)

tests/guard/test_guard_main.py:54

Checks

  • assert len(violations) == 1
  • assert "Bad_Func" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001inferredtest_all_checks_run → validate_file → get_file_at_revision → run_git → git_argv
REQ-DDB-CONFIG-009measuredtest_all_checks_run → validate_file → gate_exclusion
REQ-DDB-GUARD-001measuredtest_all_checks_run → validate_file
REQ-DDB-GUARD-002inferredtest_all_checks_run → validate_file → check_version_staleness
REQ-DDB-GUARD-003measuredtest_all_checks_run → validate_file → check_tags
REQ-DDB-GUARD-004measuredtest_all_checks_run → validate_file → check_req_coverage
REQ-DDB-GUARD-005measuredtest_all_checks_run → validate_file → check_return_presence
REQ-DDB-GUARD-006measuredtest_all_checks_run → validate_file → check_file_presence
REQ-DDB-GUARD-007measuredtest_all_checks_run → validate_file → check_duplicate_tags
REQ-DDB-GUARD-009inferredtest_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-013measuredtest_all_checks_run → validate_file → unconfigured_language
REQ-DDB-GUARD-014inferredtest_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
REQ-DDB-GUARD-018measuredtest_all_checks_run → validate_file → parse_source_file
REQ-DDB-GUARD-019measuredtest_all_checks_run → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_all_checks_run → validate_file → parse_content_for_file → language_for_file
REQ-DDB-GUARD-021inferredtest_all_checks_run → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-023inferredtest_all_checks_run → validate_file → get_file_at_revision
REQ-DDB-GUARD-024inferredtest_all_checks_run → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief
REQ-DDB-GUARD-025measuredtest_all_checks_run → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void
REQ-DDB-GUARD-026measuredtest_all_checks_run → validate_file → check_bus_tags
REQ-DDB-GUARD-027inferredtest_all_checks_run → validate_file → check_req_exists → _uncheckable
REQ-DDB-PIPE-011measuredtest_all_checks_run → validate_file → gate_exclusion → binary_file
REQ-DDB-WIKI-054inferredtest_all_checks_run → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all
Source · 22 lines
    def test_all_checks_run(self, tmp_path):
        c_file = tmp_path / "test.c"
        c_file.write_text(
            dedent("""\
                /**
                 * @brief Good function.
                 * @version 1.0
                 */
                void Good_Func(void) {
                    x();
                }

                void Bad_Func(void) {
                    y();
                }
            """)
        )
        violations = validate_file(str(c_file), CONFIG_DEFAULTS, no_git=True)
        assert len(violations) == 1
        assert "Bad_Func" in violations[0].message

Activity · 5 steps
lines 55–55c_file = tmp_path / "test.c"lines 56–70c_file.write_text( dedent("""\ /** * @brief Good function. * @version 1.0 */ void Good_Func(void) { x(); } void Bad_Func(void) { y(); } """) )lines 71–71violations = validate_file(str(c_file), CONFIG_DEFAULTS, no_git=True)lines 72–72assert len(violations) == 1lines 73–73assert "Bad_Func" in violations[0].message

test_an_opt_in_language_left_unconfigured_is_named

test_guard_main.TestUnconfiguredLanguagesAreReported.test_an_opt_in_language_left_unconfigured_is_named(self, tmp_path, monkeypatch, capsys)

An unconfigured shipped language is reported, not skipped silently.

tests/guard/test_guard_main.py:442

Show on the map →

Called by none

Calls _rust_tree

Checks

  • assert rc == 0, "nothing is configured to check it, so there is no violation to report"
  • assert "not checked" in surface and "rust" in surface, (f"the gate reported success over an unchecked Rust file in silence: {surface!r}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 13 lines
    def test_an_opt_in_language_left_unconfigured_is_named(self, tmp_path, monkeypatch, capsys):
        """@brief An unconfigured shipped language is reported, not skipped silently. @version 1"""
        rust = self._rust_tree(tmp_path)
        monkeypatch.chdir(tmp_path)

        rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(rust)])

        surface = "".join(capsys.readouterr())
        assert rc == 0, "nothing is configured to check it, so there is no violation to report"
        assert "not checked" in surface and "rust" in surface, (
            f"the gate reported success over an unchecked Rust file in silence: {surface!r}"
        )
Activity · 6 steps
lines 444–444rust = self._rust_tree(tmp_path)lines 445–445monkeypatch.chdir(tmp_path)lines 447–447rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(rust)])lines 449–449surface = "".join(capsys.readouterr())lines 450–450assert rc == 0, "nothing is configured to check it, so there is no violation to report"lines 451–453assert "not checked" in surface and "rust" in surface, ( f"the gate reported success over an unchecked Rust file in silence: {surface!r}" )

test_an_unchecked_file_is_named_without_the_verbose_flag

test_guard_main.TestSkipsAreReported.test_an_unchecked_file_is_named_without_the_verbose_flag(self, tmp_path, monkeypatch, capsys)

A toolchain-ignored file is reported on the default surface.

tests/guard/test_guard_main.py:385

Show on the map →

Called by none

Calls _dirty_tree

Checks

  • assert rc == 0, "the ignore is honoured, so there is nothing to fail on"
  • assert "1 file(s) not checked" in surface, (f"the gate passed without saying it checked nothing; surface was {surface!r}" )
  • assert "toolchain.toml" in surface, "the report must name what decided the skip"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-027measured
REQ-DDB-SCHEMA-015measured
Source · 18 lines
    def test_an_unchecked_file_is_named_without_the_verbose_flag(
        self, tmp_path, monkeypatch, capsys
    ):
        """@brief A toolchain-ignored file is reported on the default surface. @version 1"""
        dirty = self._dirty_tree(tmp_path)
        (tmp_path / "toolchain.toml").write_text('[clew.ignore]\npaths = ["gen/**"]\n')
        monkeypatch.chdir(tmp_path)

        rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(dirty)])

        captured = capsys.readouterr()
        surface = captured.out + captured.err
        assert rc == 0, "the ignore is honoured, so there is nothing to fail on"
        assert "1 file(s) not checked" in surface, (
            f"the gate passed without saying it checked nothing; surface was {surface!r}"
        )
        assert "toolchain.toml" in surface, "the report must name what decided the skip"
Activity · 9 steps
lines 389–389dirty = self._dirty_tree(tmp_path)lines 390–390(tmp_path / "toolchain.toml").write_text('[clew.ignore]\npaths = ["gen/**"]\n')lines 391–391monkeypatch.chdir(tmp_path)lines 393–393rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(dirty)])lines 395–395captured = capsys.readouterr()lines 396–396surface = captured.out + captured.errlines 397–397assert rc == 0, "the ignore is honoured, so there is nothing to fail on"lines 398–400assert "1 file(s) not checked" in surface, ( f"the gate passed without saying it checked nothing; surface was {surface!r}" )lines 401–401assert "toolchain.toml" in surface, "the report must name what decided the skip"

test_custom_config

test_guard_main.TestMain.test_custom_config(self, tmp_path)

tests/guard/test_guard_main.py:148

Show on the map →

Called by none

Calls guard_yaml

Checks

  • assert result == 0 # Presence check disabled

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 17 lines
    def test_custom_config(self, tmp_path):
        config_file = tmp_path / "custom.yaml"
        config_file.write_text(
            guard_yaml(
                dedent("""\
                validate:
                  presence:
                    require_doxygen: false
            """)
            )
        )
        c_file = tmp_path / "test.c"
        c_file.write_text("void Undoc(void) { x(); }")

        result = main(["--config", str(config_file), "validate", "--no-git", str(c_file)])
        assert result == 0  # Presence check disabled
Activity · 6 steps
lines 149–149config_file = tmp_path / "custom.yaml"lines 150–158config_file.write_text( guard_yaml( dedent("""\ validate: presence: require_doxygen: false """) ) )lines 159–159c_file = tmp_path / "test.c"lines 160–160c_file.write_text("void Undoc(void) { x(); }")lines 162–162result = main(["--config", str(config_file), "validate", "--no-git", str(c_file)])lines 163–163assert result == 0

test_default_subcommand_with_files

test_guard_main.TestMain.test_default_subcommand_with_files(self, tmp_path)

When no subcommand is given, treat args as files (pre-commit mode).

tests/guard/test_guard_main.py:115

Show on the map →

Called by none

Calls none

Checks

  • assert result == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-002measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-022measured
REQ-DDB-GUARD-023measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 17 lines
    def test_default_subcommand_with_files(self, tmp_path):
        """When no subcommand is given, treat args as files (pre-commit mode)."""
        c_file = tmp_path / "test.c"
        c_file.write_text(
            dedent("""\
                /**
                 * @brief Func.
                 * @version 1.0
                 */
                void Func(void) {
                    x();
                }
            """)
        )
        result = main(["--config", NO_REQ_CONFIG, str(c_file)])
        assert result == 0
Activity · 4 steps
lines 117–117c_file = tmp_path / "test.c"lines 118–128c_file.write_text( dedent("""\ /** * @brief Func. * @version 1.0 */ void Func(void) { x(); } """) )lines 129–129result = main(["--config", NO_REQ_CONFIG, str(c_file)])lines 130–130assert result == 0

test_documented_file_no_violations

test_guard_main.TestValidateFile.test_documented_file_no_violations(self)

tests/guard/test_guard_main.py:18

Checks

  • assert len(violations) == 1
  • assert "Undocumented_Function" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001inferredtest_documented_file_no_violations → validate_file → get_file_at_revision → run_git → git_argv
REQ-DDB-CONFIG-009measuredtest_documented_file_no_violations → validate_file → gate_exclusion
REQ-DDB-GUARD-001measuredtest_documented_file_no_violations → validate_file
REQ-DDB-GUARD-002inferredtest_documented_file_no_violations → validate_file → check_version_staleness
REQ-DDB-GUARD-003measuredtest_documented_file_no_violations → validate_file → check_tags
REQ-DDB-GUARD-004measuredtest_documented_file_no_violations → validate_file → check_req_coverage
REQ-DDB-GUARD-005measuredtest_documented_file_no_violations → validate_file → check_return_presence
REQ-DDB-GUARD-006measuredtest_documented_file_no_violations → validate_file → check_file_presence
REQ-DDB-GUARD-007measuredtest_documented_file_no_violations → validate_file → check_duplicate_tags
REQ-DDB-GUARD-009inferredtest_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-013measuredtest_documented_file_no_violations → validate_file → unconfigured_language
REQ-DDB-GUARD-014inferredtest_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
REQ-DDB-GUARD-018measuredtest_documented_file_no_violations → validate_file → parse_source_file
REQ-DDB-GUARD-019measuredtest_documented_file_no_violations → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_documented_file_no_violations → validate_file → parse_content_for_file → language_for_file
REQ-DDB-GUARD-021inferredtest_documented_file_no_violations → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-023inferredtest_documented_file_no_violations → validate_file → get_file_at_revision
REQ-DDB-GUARD-024inferredtest_documented_file_no_violations → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief
REQ-DDB-GUARD-025measuredtest_documented_file_no_violations → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void
REQ-DDB-GUARD-026measuredtest_documented_file_no_violations → validate_file → check_bus_tags
REQ-DDB-GUARD-027inferredtest_documented_file_no_violations → validate_file → check_req_exists → _uncheckable
REQ-DDB-PIPE-011measuredtest_documented_file_no_violations → validate_file → gate_exclusion → binary_file
REQ-DDB-WIKI-054inferredtest_documented_file_no_violations → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all
Source · 13 lines
    def test_documented_file_no_violations(self):
        # Create a minimal fully-documented C file
        config = CONFIG_DEFAULTS.copy()
        # Use simple.c but only the documented functions will pass
        violations = validate_file(
            str(FIXTURES_DIR / "simple.c"),
            config,
            no_git=True,
        )
        # simple.c has one undocumented function
        assert len(violations) == 1
        assert "Undocumented_Function" in violations[0].message
Activity · 4 steps
lines 20–20config = CONFIG_DEFAULTS.copy()lines 22–26violations = validate_file( str(FIXTURES_DIR / "simple.c"), config, no_git=True, )lines 28–28assert len(violations) == 1lines 29–29assert "Undocumented_Function" in violations[0].message

test_excluded_file

test_guard_main.TestValidateFile.test_excluded_file(self, tmp_path, monkeypatch)

tests/guard/test_guard_main.py:37

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001inferredtest_excluded_file → validate_file → get_file_at_revision → run_git → git_argv
REQ-DDB-CONFIG-009inferredtest_excluded_file → validate_file → gate_exclusion
REQ-DDB-GUARD-001measuredtest_excluded_file → validate_file
REQ-DDB-GUARD-002inferredtest_excluded_file → validate_file → check_version_staleness
REQ-DDB-GUARD-003inferredtest_excluded_file → validate_file → check_tags
REQ-DDB-GUARD-004inferredtest_excluded_file → validate_file → check_req_coverage
REQ-DDB-GUARD-005inferredtest_excluded_file → validate_file → check_return_presence
REQ-DDB-GUARD-006inferredtest_excluded_file → validate_file → check_file_presence
REQ-DDB-GUARD-007inferredtest_excluded_file → validate_file → check_duplicate_tags
REQ-DDB-GUARD-009inferredtest_excluded_file → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_excluded_file → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-013measuredtest_excluded_file → validate_file → unconfigured_language
REQ-DDB-GUARD-014inferredtest_excluded_file → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_excluded_file → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
REQ-DDB-GUARD-018inferredtest_excluded_file → validate_file → parse_source_file
REQ-DDB-GUARD-019inferredtest_excluded_file → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-020inferredtest_excluded_file → validate_file → parse_content_for_file → language_for_file
REQ-DDB-GUARD-021inferredtest_excluded_file → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-023inferredtest_excluded_file → validate_file → get_file_at_revision
REQ-DDB-GUARD-024inferredtest_excluded_file → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief
REQ-DDB-GUARD-025inferredtest_excluded_file → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void
REQ-DDB-GUARD-026inferredtest_excluded_file → validate_file → check_bus_tags
REQ-DDB-GUARD-027inferredtest_excluded_file → validate_file → check_req_exists → _uncheckable
REQ-DDB-PIPE-011inferredtest_excluded_file → validate_file → gate_exclusion → binary_file
REQ-DDB-WIKI-054inferredtest_excluded_file → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all
Source · 17 lines
    def test_excluded_file(self, tmp_path, monkeypatch):
        ## 2.0.0 (R5-CFG F18): excludes are repo-relative globs, so the gate runs from the repo root
        ## (as pre-commit runs it); `gen/` is the directory at the root.
        monkeypatch.chdir(tmp_path)
        c_file = tmp_path / "gen" / "auto.c"
        c_file.parent.mkdir()
        c_file.write_text("void Func(void) { }")
        config = {
            "validate": {
                **CONFIG_DEFAULTS["validate"],
                "exclude": ["gen/"],
            },
            "impact": CONFIG_DEFAULTS["impact"],
        }
        violations = validate_file(str(c_file), config, no_git=True)
        assert violations == []
Activity · 7 steps
lines 40–40monkeypatch.chdir(tmp_path)lines 41–41c_file = tmp_path / "gen" / "auto.c"lines 42–42c_file.parent.mkdir()lines 43–43c_file.write_text("void Func(void) { }")lines 44–50config = { "validate": { **CONFIG_DEFAULTS["validate"], "exclude": ["gen/"], }, "impact": CONFIG_DEFAULTS["impact"], }lines 51–51violations = validate_file(str(c_file), config, no_git=True)lines 52–52assert violations == []

test_impact_no_files_returns_0

test_guard_main.TestMain.test_impact_no_files_returns_0(self)

tests/guard/test_guard_main.py:176

Show on the map →

Called by none

Calls none

Checks

  • assert result == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-GUARD-009measured
REQ-DDB-GUARD-010measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-021measured
REQ-DDB-GUARD-023measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-INDEX-007measured
REQ-DDB-MCP-001measured
Source · 5 lines
    def test_impact_no_files_returns_0(self):
        result = main(["impact", "--staged"])
        assert result == 0

Activity · 2 steps
lines 177–177result = main(["impact", "--staged"])lines 178–178assert result == 0

test_literal_version_resolves

test_guard_main.TestVersionGateFailsClosed.test_literal_version_resolves(self, tmp_path, monkeypatch)

tests/guard/test_guard_main.py:349

Show on the map →

Called by none

Calls _project

Checks

  • assert main(["validate", "--no-git", str(c_file)]) == 1

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-009measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-015measured
Source · 8 lines
    def test_literal_version_resolves(self, tmp_path, monkeypatch):
        c_file = self._project(tmp_path)
        cfg = tmp_path / ".clew.yaml"
        cfg.write_text(cfg.read_text().replace('"auto:git"', '"v1.0.0"'))
        monkeypatch.chdir(tmp_path)
        # Gate resolves, so the requirement is active and the missing @req is caught.
        assert main(["validate", "--no-git", str(c_file)]) == 1
Activity · 5 steps
lines 350–350c_file = self._project(tmp_path)lines 351–351cfg = tmp_path / ".clew.yaml"lines 352–352cfg.write_text(cfg.read_text().replace('"auto:git"', '"v1.0.0"'))lines 353–353monkeypatch.chdir(tmp_path)lines 355–355assert main(["validate", "--no-git", str(c_file)]) == 1

test_no_files_returns_zero

test_guard_main.TestMain.test_no_files_returns_zero(self)

tests/guard/test_guard_main.py:79

Show on the map →

Called by none

Calls none

Checks

  • assert result == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-024measured
Source · 4 lines
    def test_no_files_returns_zero(self):
        result = main(["validate"])
        assert result == 0
Activity · 2 steps
lines 80–80result = main(["validate"])lines 81–81assert result == 0

test_no_gate_declared_is_not_an_error

test_guard_main.TestVersionGateFailsClosed.test_no_gate_declared_is_not_an_error(self, tmp_path, monkeypatch)

tests/guard/test_guard_main.py:357

Show on the map →

Called by none

Calls _project, guard_yaml

Checks

  • assert main(["validate", "--no-git", str(c_file)]) in (0, 1)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
Source · 10 lines
    def test_no_gate_declared_is_not_an_error(self, tmp_path, monkeypatch):
        c_file = self._project(tmp_path)
        (tmp_path / ".clew.yaml").write_text(
            guard_yaml("impact:\n  requirements:\n    file: reqs.yaml\n    format: yaml\n")
        )
        monkeypatch.chdir(tmp_path)
        # No version_gate declared: nothing to resolve, so no error from resolution.
        assert main(["validate", "--no-git", str(c_file)]) in (0, 1)

Activity · 4 steps
lines 358–358c_file = self._project(tmp_path)lines 359–361(tmp_path / ".clew.yaml").write_text( guard_yaml("impact:\n requirements:\n file: reqs.yaml\n format: yaml\n") )lines 362–362monkeypatch.chdir(tmp_path)lines 364–364assert main(["validate", "--no-git", str(c_file)]) in (0, 1)

test_precommit_fails_when_gate_unresolvable

test_guard_main.TestVersionGateFailsClosed.test_precommit_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys)

tests/guard/test_guard_main.py:342

Show on the map →

Called by none

Calls _project

Checks

  • assert result == 1
  • assert "no version could be resolved" in capsys.readouterr().err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024measured
Source · 7 lines
    def test_precommit_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys):
        c_file = self._project(tmp_path)
        monkeypatch.chdir(tmp_path)
        result = main([str(c_file)])
        assert result == 1
        assert "no version could be resolved" in capsys.readouterr().err
Activity · 5 steps
lines 343–343c_file = self._project(tmp_path)lines 344–344monkeypatch.chdir(tmp_path)lines 345–345result = main([str(c_file)])lines 346–346assert result == 1lines 347–347assert "no version could be resolved" in capsys.readouterr().err

test_precommit_with_impact

test_guard_main.TestPrecommitPipeline.test_precommit_with_impact(self, tmp_path, monkeypatch)

tests/guard/test_guard_main.py:184

Show on the map →

Called by none

Calls guard_yaml

Checks

  • assert result == 0
  • assert {"unmapped", "unmapped_files"} <= set(doc)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-002measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-009measured
REQ-DDB-GUARD-010measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-022measured
REQ-DDB-GUARD-023measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-INDEX-007measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 49 lines
    def test_precommit_with_impact(self, tmp_path, monkeypatch):
        monkeypatch.chdir(tmp_path)
        src = tmp_path / "src"
        src.mkdir()
        c_file = src / "test.c"
        c_file.write_text(
            dedent("""\
                /**
                 * @brief Process data.
                 * @version 1.0
                 * @req REQ-001
                 */
                void Process(void) {
                    event_post(EVENT_DATA_READY);
                }

                /**
                 * @brief Handle data event.
                 * @version 1.0
                 * @req REQ-001
                 */
                void OnDataReady(void) {
                    consume();
                }
            """)
        )
        req_file = tmp_path / "reqs.csv"
        req_file.write_text("Req ID,Name,Subsystem\nREQ-001,Data Processing,DataSvc\n")
        config_file = tmp_path / ".clew.yaml"
        ## FIXTURE CHANGED (2.0.0, R5-CFG F7/F9): the catalog is the top-level `requirements:`
        ## and the report directory is `guard.impact.report_dir` (it was `output_dir/impact/`).
        config_file.write_text(
            dedent("""\
                requirements:
                  file: reqs.csv
                  id_column: "Req ID"
                  name_column: "Name"
                  format: csv
            """)
            + guard_yaml("impact:\n  report_dir: out/impact/\n")
        )
        result = main(["--config", str(config_file), str(c_file)])
        assert result == 0
        ## THE HOOK WRITES THE FULL REPORT (2.2; entropic, after clew#74): the hook's
        ## impact.json had no `unmapped`/`unmapped_files` (nor `tests`/`via`), which only the
        ## `impact` subcommand produced, so a consumer reading the hook's file saw less.
        doc = json.loads((tmp_path / "out" / "impact" / "impact.json").read_text())
        assert {"unmapped", "unmapped_files"} <= set(doc)
Activity · 13 steps
lines 185–185monkeypatch.chdir(tmp_path)lines 186–186src = tmp_path / "src"lines 187–187src.mkdir()lines 188–188c_file = src / "test.c"lines 189–209c_file.write_text( dedent("""\ /** * @brief Process data. * @version 1.0 * @req REQ-001 */ void Process(void) { event_post(EVENT_DATA_READY); } /** * @brief Handle data event. * @version 1.0 * @req REQ-001 */ void OnDataReady(void) { consume(); } """) )lines 210–210req_file = tmp_path / "reqs.csv"lines 211–211req_file.write_text("Req ID,Name,Subsystem\nREQ-001,Data Processing,DataSvc\n")lines 212–212config_file = tmp_path / ".clew.yaml"lines 215–224config_file.write_text( dedent("""\ requirements: file: reqs.csv id_column: "Req ID" name_column: "Name" format: csv """) + guard_yaml("impact:\n report_dir: out/impact/\n") )lines 225–225result = main(["--config", str(config_file), str(c_file)])lines 226–226assert result == 0lines 230–230doc = json.loads((tmp_path / "out" / "impact" / "impact.json").read_text())lines 231–231assert {"unmapped", "unmapped_files"} <= set(doc)

test_retired_subcommand_not_treated_as_file_path

test_guard_main.TestMain.test_retired_subcommand_not_treated_as_file_path(self, capsys)

A retired subcommand must not silently degrade to pre-commit mode and exit 0.

tests/guard/test_guard_main.py:170

Show on the map →

Called by none

Calls none

Checks

  • assert result == 1
  • assert "trace" in capsys.readouterr().err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-013measured
Source · 6 lines
    def test_retired_subcommand_not_treated_as_file_path(self, capsys):
        """A retired subcommand must not silently degrade to pre-commit mode and exit 0."""
        result = main(["trace", "--all", "src/"])
        assert result == 1
        assert "trace" in capsys.readouterr().err
Activity · 3 steps
lines 172–172result = main(["trace", "--all", "src/"])lines 173–173assert result == 1lines 174–174assert "trace" in capsys.readouterr().err

test_retired_trace_subcommand_fails_loudly

test_guard_main.TestMain.test_retired_trace_subcommand_fails_loudly(self, capsys)

tests/guard/test_guard_main.py:165

Show on the map →

Called by none

Calls none

Checks

  • assert result == 1
  • assert "was removed" in capsys.readouterr().err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-013measured
Source · 5 lines
    def test_retired_trace_subcommand_fails_loudly(self, capsys):
        result = main(["trace", "--req", "REQ-NONEXISTENT-9999"])
        assert result == 1
        assert "was removed" in capsys.readouterr().err
Activity · 3 steps
lines 166–166result = main(["trace", "--req", "REQ-NONEXISTENT-9999"])lines 167–167assert result == 1lines 168–168assert "was removed" in capsys.readouterr().err

test_unknown_extension_skipped

test_guard_main.TestValidateFile.test_unknown_extension_skipped(self, tmp_path)

tests/guard/test_guard_main.py:31

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_unknown_extension_skipped → validate_file → get_file_at_revision → run_git → git_argv
REQ-DDB-CONFIG-009measuredtest_unknown_extension_skipped → validate_file → gate_exclusion
REQ-DDB-GUARD-001measuredtest_unknown_extension_skipped → validate_file
REQ-DDB-GUARD-002inferredtest_unknown_extension_skipped → validate_file → check_version_staleness
REQ-DDB-GUARD-003inferredtest_unknown_extension_skipped → validate_file → check_tags
REQ-DDB-GUARD-004inferredtest_unknown_extension_skipped → validate_file → check_req_coverage
REQ-DDB-GUARD-005inferredtest_unknown_extension_skipped → validate_file → check_return_presence
REQ-DDB-GUARD-006inferredtest_unknown_extension_skipped → validate_file → check_file_presence
REQ-DDB-GUARD-007inferredtest_unknown_extension_skipped → validate_file → check_duplicate_tags
REQ-DDB-GUARD-008measured
REQ-DDB-GUARD-009inferredtest_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-010measured
REQ-DDB-GUARD-011inferredtest_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-013measuredtest_unknown_extension_skipped → validate_file → unconfigured_language
REQ-DDB-GUARD-014inferredtest_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
REQ-DDB-GUARD-018measuredtest_unknown_extension_skipped → validate_file → parse_source_file
REQ-DDB-GUARD-019inferredtest_unknown_extension_skipped → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-020inferredtest_unknown_extension_skipped → validate_file → parse_content_for_file → language_for_file
REQ-DDB-GUARD-021inferredtest_unknown_extension_skipped → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-023measuredtest_unknown_extension_skipped → validate_file → get_file_at_revision
REQ-DDB-GUARD-024inferredtest_unknown_extension_skipped → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief
REQ-DDB-GUARD-025inferredtest_unknown_extension_skipped → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void
REQ-DDB-GUARD-026inferredtest_unknown_extension_skipped → validate_file → check_bus_tags
REQ-DDB-GUARD-027inferredtest_unknown_extension_skipped → validate_file → check_req_exists → _uncheckable
REQ-DDB-PIPE-011measuredtest_unknown_extension_skipped → validate_file → gate_exclusion → binary_file
REQ-DDB-WIKI-054inferredtest_unknown_extension_skipped → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all
Source · 6 lines
    def test_unknown_extension_skipped(self, tmp_path):
        py_file = tmp_path / "script.rs"
        py_file.write_text("fn foo() {}")
        violations = validate_file(str(py_file), CONFIG_DEFAULTS, no_git=True)
        assert violations == []
Activity · 4 steps
lines 32–32py_file = tmp_path / "script.rs"lines 33–33py_file.write_text("fn foo() {}")lines 34–34violations = validate_file(str(py_file), CONFIG_DEFAULTS, no_git=True)lines 35–35assert violations == []

test_unsupported_extension_returns_none

test_guard_main.TestParseSourceFile.test_unsupported_extension_returns_none(self, tmp_path)

tests/guard/test_guard_main.py:293

Checks

  • assert result is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-013measuredtest_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config
REQ-DDB-GUARD-018measuredtest_unsupported_extension_returns_none → parse_source_file
REQ-DDB-GUARD-019inferredtest_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020inferredtest_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file
REQ-DDB-GUARD-021inferredtest_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025inferredtest_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void
Source · 7 lines
    def test_unsupported_extension_returns_none(self, tmp_path):
        rs_file = tmp_path / "lib.rs"
        rs_file.write_text("fn main() {}")
        result = parse_source_file(str(rs_file), CONFIG_DEFAULTS)
        assert result is None

Activity · 4 steps
lines 294–294rs_file = tmp_path / "lib.rs"lines 295–295rs_file.write_text("fn main() {}")lines 296–296result = parse_source_file(str(rs_file), CONFIG_DEFAULTS)lines 297–297assert result is None

test_validate_clean_file

test_guard_main.TestMain.test_validate_clean_file(self, tmp_path)

tests/guard/test_guard_main.py:83

Show on the map →

Called by none

Calls none

Checks

  • assert result == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 16 lines
    def test_validate_clean_file(self, tmp_path):
        c_file = tmp_path / "clean.c"
        c_file.write_text(
            dedent("""\
                /**
                 * @brief Clean function.
                 * @version 1.0
                 */
                void Clean_Func(void) {
                    do_stuff();
                }
            """)
        )
        result = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(c_file)])
        assert result == 0
Activity · 4 steps
lines 84–84c_file = tmp_path / "clean.c"lines 85–95c_file.write_text( dedent("""\ /** * @brief Clean function. * @version 1.0 */ void Clean_Func(void) { do_stuff(); } """) )lines 96–96result = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(c_file)])lines 97–97assert result == 0

test_validate_dirty_file

test_guard_main.TestMain.test_validate_dirty_file(self, tmp_path)

tests/guard/test_guard_main.py:99

Show on the map →

Called by none

Calls none

Checks

  • assert result == 1

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-015measured
Source · 12 lines
    def test_validate_dirty_file(self, tmp_path):
        c_file = tmp_path / "dirty.c"
        c_file.write_text(
            dedent("""\
                void Undoc_Func(void) {
                    do_stuff();
                }
            """)
        )
        result = main(["validate", "--no-git", str(c_file)])
        assert result == 1
Activity · 4 steps
lines 100–100c_file = tmp_path / "dirty.c"lines 101–107c_file.write_text( dedent("""\ void Undoc_Func(void) { do_stuff(); } """) )lines 108–108result = main(["validate", "--no-git", str(c_file)])lines 109–109assert result == 1

test_validate_fails_when_gate_unresolvable

test_guard_main.TestVersionGateFailsClosed.test_validate_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys)

tests/guard/test_guard_main.py:335

Show on the map →

Called by none

Calls _project

Checks

  • assert result == 1
  • assert "no version could be resolved" in capsys.readouterr().err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024measured
Source · 7 lines
    def test_validate_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys):
        c_file = self._project(tmp_path)
        monkeypatch.chdir(tmp_path)
        result = main(["validate", "--no-git", str(c_file)])
        assert result == 1
        assert "no version could be resolved" in capsys.readouterr().err
Activity · 5 steps
lines 336–336c_file = self._project(tmp_path)lines 337–337monkeypatch.chdir(tmp_path)lines 338–338result = main(["validate", "--no-git", str(c_file)])lines 339–339assert result == 1lines 340–340assert "no version could be resolved" in capsys.readouterr().err

test_validate_nonexistent_file

test_guard_main.TestMain.test_validate_nonexistent_file(self)

tests/guard/test_guard_main.py:111

Show on the map →

Called by none

Calls none

Checks

  • assert result == 0 # Warning logged, no violations

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-016measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-027measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-015measured
Source · 4 lines
    def test_validate_nonexistent_file(self):
        result = main(["validate", "--no-git", "/nonexistent/path.c"])
        assert result == 0  # Warning logged, no violations
Activity · 2 steps
lines 112–112result = main(["validate", "--no-git", "/nonexistent/path.c"])lines 113–113assert result == 0

test_verbose_flag

test_guard_main.TestMain.test_verbose_flag(self, tmp_path)

tests/guard/test_guard_main.py:132

Show on the map →

Called by none

Calls none

Checks

  • assert result == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-007measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-025measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 16 lines
    def test_verbose_flag(self, tmp_path):
        c_file = tmp_path / "test.c"
        c_file.write_text(
            dedent("""\
                /**
                 * @brief Func.
                 * @version 1.0
                 */
                void Func(void) {
                    x();
                }
            """)
        )
        result = main(["--config", NO_REQ_CONFIG, "-v", "validate", "--no-git", str(c_file)])
        assert result == 0
Activity · 4 steps
lines 133–133c_file = tmp_path / "test.c"lines 134–144c_file.write_text( dedent("""\ /** * @brief Func. * @version 1.0 */ void Func(void) { x(); } """) )lines 145–145result = main(["--config", NO_REQ_CONFIG, "-v", "validate", "--no-git", str(c_file)])lines 146–146assert result == 0