test_guard_checks.py

tests/guard/test_guard_checks.py

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

test_body_changed_version_bumped

test_guard_checks.TestCheckVersionStaleness.test_body_changed_version_bumped(self)

tests/guard/test_guard_checks.py:148

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_body_changed_version_bumped → check_version_staleness
Source · 10 lines
    def test_body_changed_version_bumped(self):
        func = _make_func(def_line=5, body_end=6, tags={"brief": ["x"], "version": ["1.1"]})
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)  # version 1.0
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert violations == []
Activity · 6 steps
lines 149–149func = _make_func(def_line=5, body_end=6, tags={"brief": ["x"], "version": ["1.1"]})lines 150–150content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 151–151head_func = _make_func(def_line=5, body_end=6)lines 152–152head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 153–155violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 156–156assert violations == []

test_body_changed_version_not_updated

test_guard_checks.TestCheckVersionStaleness.test_body_changed_version_not_updated(self)

tests/guard/test_guard_checks.py:136

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert len(violations) == 1
  • assert violations[0].check == "version"
  • assert "not updated" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_body_changed_version_not_updated → check_version_staleness
Source · 12 lines
    def test_body_changed_version_not_updated(self):
        func = _make_func(def_line=5, body_end=6)
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert len(violations) == 1
        assert violations[0].check == "version"
        assert "not updated" in violations[0].message
Activity · 8 steps
lines 137–137func = _make_func(def_line=5, body_end=6)lines 138–138content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 139–139head_func = _make_func(def_line=5, body_end=6)lines 140–140head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 141–143violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 144–144assert len(violations) == 1lines 145–145assert violations[0].check == "version"lines 146–146assert "not updated" in violations[0].message

test_body_unchanged_no_violation

test_guard_checks.TestCheckVersionStaleness.test_body_unchanged_no_violation(self)

tests/guard/test_guard_checks.py:127

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_body_unchanged_no_violation → check_version_staleness
Source · 9 lines
    def test_body_unchanged_no_violation(self):
        func = _make_func(def_line=5, body_end=6)
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], content
        )
        assert violations == []
Activity · 5 steps
lines 128–128func = _make_func(def_line=5, body_end=6)lines 129–129content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 130–130head_func = _make_func(def_line=5, body_end=6)lines 131–133violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], content )lines 134–134assert violations == []

test_check_can_be_disabled

test_guard_checks.TestCheckDuplicateTags.test_check_can_be_disabled(self)

tests/guard/test_guard_checks.py:518

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags, deep_merge

Checks

  • assert check_duplicate_tags(func, "test.c", config) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_check_can_be_disabled → check_duplicate_tags
Source · 5 lines
    def test_check_can_be_disabled(self):
        func = _make_func(tags={"brief": ["A.", "B."], "version": ["1.0"]})
        config = deep_merge(CONFIG_DEFAULTS, {"validate": {"duplicate_tags_error": False}})
        assert check_duplicate_tags(func, "test.c", config) == []
Activity · 3 steps
lines 519–519func = _make_func(tags={"brief": ["A.", "B."], "version": ["1.0"]})lines 520–520config = deep_merge(CONFIG_DEFAULTS, {"validate": {"duplicate_tags_error": False}})lines 521–521assert check_duplicate_tags(func, "test.c", config) == []

test_clean_block_passes

test_guard_checks.TestCheckDuplicateTags.test_clean_block_passes(self)

tests/guard/test_guard_checks.py:498

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_clean_block_passes → check_duplicate_tags
Source · 4 lines
    def test_clean_block_passes(self):
        violations = check_duplicate_tags(_make_func(), "test.c", CONFIG_DEFAULTS)
        assert violations == []
Activity · 2 steps
lines 499–499violations = check_duplicate_tags(_make_func(), "test.c", CONFIG_DEFAULTS)lines 500–500assert violations == []

test_configured_tag_satisfies_presence

test_guard_checks.TestConfiguredVersionTag.test_configured_tag_satisfies_presence(self)

tests/guard/test_guard_checks.py:590

Show on the map →

Called by none

Calls _config, _config, _make_func, check_presence

Checks

  • assert check_presence([func], "a.c", self._config("@revision")) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_configured_tag_satisfies_presence → check_presence
REQ-DDB-GUARD-005inferredtest_configured_tag_satisfies_presence → check_presence → _is_void_function
Source · 4 lines
    def test_configured_tag_satisfies_presence(self):
        func = _make_func(tags={"brief": ["B."], "revision": ["1.0"]})
        assert check_presence([func], "a.c", self._config("@revision")) == []
Activity · 2 steps
lines 591–591func = _make_func(tags={"brief": ["B."], "revision": ["1.0"]})lines 592–592assert check_presence([func], "a.c", self._config("@revision")) == []

test_constructor_skipped_for_req_check

test_guard_checks.TestConstructorDestructorSkipping.test_constructor_skipped_for_req_check(self)

tests/guard/test_guard_checks.py:402

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-004measuredtest_constructor_skipped_for_req_check → check_req_coverage
REQ-DDB-GUARD-009inferredtest_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-014inferredtest_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
Source · 19 lines
    def test_constructor_skipped_for_req_check(self):
        from clew.guard.checks import check_req_coverage

        ctor = Function(
            name="Foo",
            def_line=5,
            body_end=10,
            doxygen=DoxygenBlock(
                start_line=2, end_line=4, tags={"brief": ["Constructor."], "version": ["1.0"]}
            ),
            enclosing_class="Foo",
        )
        config = {
            "requirements": {"file": "reqs.csv"},
            "validate": {},
        }
        violations = check_req_coverage([ctor], "test.cpp", config)
        assert violations == []
Activity · 5 steps
lines 403–403from clew.guard.checks import check_req_coveragelines 405–413ctor = Function( name="Foo", def_line=5, body_end=10, doxygen=DoxygenBlock( start_line=2, end_line=4, tags={"brief": ["Constructor."], "version": ["1.0"]} ), enclosing_class="Foo", )lines 414–417config = { "requirements": {"file": "reqs.csv"}, "validate": {}, }lines 418–418violations = check_req_coverage([ctor], "test.cpp", config)lines 419–419assert violations == []

test_constructor_skipped_for_return_check

test_guard_checks.TestConstructorDestructorSkipping.test_constructor_skipped_for_return_check(self)

tests/guard/test_guard_checks.py:370

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-005measuredtest_constructor_skipped_for_return_check → check_return_presence
Source · 16 lines
    def test_constructor_skipped_for_return_check(self):
        from clew.guard.checks import check_return_presence

        ctor = Function(
            name="Foo",
            def_line=5,
            body_end=10,
            doxygen=DoxygenBlock(
                start_line=2, end_line=4, tags={"brief": ["Constructor."], "version": ["1.0"]}
            ),
            enclosing_class="Foo",
        )
        content = "class Foo {\npublic:\nFoo() {}\n};\n"
        violations = check_return_presence([ctor], "test.cpp", CONFIG_DEFAULTS, content)
        assert violations == []
Activity · 5 steps
lines 371–371from clew.guard.checks import check_return_presencelines 373–381ctor = Function( name="Foo", def_line=5, body_end=10, doxygen=DoxygenBlock( start_line=2, end_line=4, tags={"brief": ["Constructor."], "version": ["1.0"]} ), enclosing_class="Foo", )lines 382–382content = "class Foo {\npublic:\nFoo() {}\n};\n"lines 383–383violations = check_return_presence([ctor], "test.cpp", CONFIG_DEFAULTS, content)lines 384–384assert violations == []

test_coverage_message_lists_the_real_exemption_tags

test_guard_checks.TestExemptionTagsAreToolOwned.test_coverage_message_lists_the_real_exemption_tags(self, tmp_path)

The hint is derived from EXEMPTION_TAGS, so it cannot drift out of date.

tests/guard/test_guard_checks.py:560

Show on the map →

Called by none

Calls _make_func, check_req_coverage, deep_merge

Checks

  • assert violations
  • assert "@utility" in message
  • assert "@internal," not in message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-004measuredtest_coverage_message_lists_the_real_exemption_tags → check_req_coverage
REQ-DDB-GUARD-009inferredtest_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-014inferredtest_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
Source · 16 lines
    def test_coverage_message_lists_the_real_exemption_tags(self, tmp_path):
        """The hint is derived from EXEMPTION_TAGS, so it cannot drift out of date."""
        catalog = tmp_path / "reqs.yaml"
        catalog.write_text("requirements:\n  REQ-VAL-001:\n    name: A req\n")
        config = deep_merge(
            CONFIG_DEFAULTS,
            {"requirements": {"file": str(catalog), "format": "yaml"}},
        )
        func = _make_func(tags={"brief": ["B."], "version": ["1.0"]})
        violations = check_req_coverage([func], "a.c", config)
        assert violations
        message = violations[0].message
        assert "@utility" in message
        assert "@internal," not in message

Activity · 9 steps
lines 562–562catalog = tmp_path / "reqs.yaml"lines 563–563catalog.write_text("requirements:\n REQ-VAL-001:\n name: A req\n")lines 564–567config = deep_merge( CONFIG_DEFAULTS, {"requirements": {"file": str(catalog), "format": "yaml"}}, )lines 568–568func = _make_func(tags={"brief": ["B."], "version": ["1.0"]})lines 569–569violations = check_req_coverage([func], "a.c", config)lines 570–570assert violationslines 571–571message = violations[0].messagelines 572–572assert "@utility" in messagelines 573–573assert "@internal," not in message

test_default_remains_version

test_guard_checks.TestConfiguredVersionTag.test_default_remains_version(self)

tests/guard/test_guard_checks.py:601

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert check_presence([func], "a.c", CONFIG_DEFAULTS) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_default_remains_version → check_presence
REQ-DDB-GUARD-005inferredtest_default_remains_version → check_presence → _is_void_function
Source · 3 lines
    def test_default_remains_version(self):
        func = _make_func(tags={"brief": ["B."], "version": ["1.0"]})
        assert check_presence([func], "a.c", CONFIG_DEFAULTS) == []

1 more lines, not shown

Activity · 2 steps
lines 602–602func = _make_func(tags={"brief": ["B."], "version": ["1.0"]})lines 603–603assert check_presence([func], "a.c", CONFIG_DEFAULTS) == []

test_destructor_skipped_for_return_check

test_guard_checks.TestConstructorDestructorSkipping.test_destructor_skipped_for_return_check(self)

tests/guard/test_guard_checks.py:386

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-005measuredtest_destructor_skipped_for_return_check → check_return_presence
Source · 16 lines
    def test_destructor_skipped_for_return_check(self):
        from clew.guard.checks import check_return_presence

        dtor = Function(
            name="~Foo",
            def_line=5,
            body_end=10,
            doxygen=DoxygenBlock(
                start_line=2, end_line=4, tags={"brief": ["Destructor."], "version": ["1.0"]}
            ),
            enclosing_class="Foo",
        )
        content = "class Foo {\npublic:\n~Foo() {}\n};\n"
        violations = check_return_presence([dtor], "test.cpp", CONFIG_DEFAULTS, content)
        assert violations == []
Activity · 5 steps
lines 387–387from clew.guard.checks import check_return_presencelines 389–397dtor = Function( name="~Foo", def_line=5, body_end=10, doxygen=DoxygenBlock( start_line=2, end_line=4, tags={"brief": ["Destructor."], "version": ["1.0"]} ), enclosing_class="Foo", )lines 398–398content = "class Foo {\npublic:\n~Foo() {}\n};\n"lines 399–399violations = check_return_presence([dtor], "test.cpp", CONFIG_DEFAULTS, content)lines 400–400assert violations == []

test_dg_internal_is_left_to_the_removal_check

test_guard_checks.TestExemptionTagsAreToolOwned.test_dg_internal_is_left_to_the_removal_check(self)

2.0.0 (PG1): not an unknown tag; `check_removed_tags` refuses it, naming `@utility`.

tests/guard/test_guard_checks.py:555

Show on the map →

Called by none

Calls _make_func, check_unknown_tags

Checks

  • assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_dg_internal_is_left_to_the_removal_check → check_unknown_tags
Source · 5 lines
    def test_dg_internal_is_left_to_the_removal_check(self):
        """2.0.0 (PG1): not an unknown tag; `check_removed_tags` refuses it, naming `@utility`."""
        func = _make_func(tags={"brief": ["B."], "version": ["1.0"], "dg_internal": [""]})
        assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []
Activity · 2 steps
lines 557–557func = _make_func(tags={"brief": ["B."], "version": ["1.0"], "dg_internal": [""]})lines 558–558assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []

test_duplicate_brief_flagged

test_guard_checks.TestCheckDuplicateTags.test_duplicate_brief_flagged(self)

tests/guard/test_guard_checks.py:474

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_duplicate_brief_flagged → check_duplicate_tags
Source · 6 lines
    def test_duplicate_brief_flagged(self):
        func = _make_func(tags={"brief": ["First.", "Second."], "version": ["1.0"]})
        violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert "@brief" in violations[0].message
Activity · 4 steps
lines 475–475func = _make_func(tags={"brief": ["First.", "Second."], "version": ["1.0"]})lines 476–476violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)lines 477–477assert len(violations) == 1lines 478–478assert "@brief" in violations[0].message

test_duplicate_file_tag_flagged

test_guard_checks.TestCheckDuplicateTags.test_duplicate_file_tag_flagged(self)

tests/guard/test_guard_checks.py:467

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

  • assert len(violations) == 1
  • assert violations[0].check == "tag"
  • assert "@file appears 2 times" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_duplicate_file_tag_flagged → check_duplicate_tags
Source · 7 lines
    def test_duplicate_file_tag_flagged(self):
        func = _make_func(tags={"brief": ["Do it."], "version": ["1.0"], "file": ["a", "b"]})
        violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert violations[0].check == "tag"
        assert "@file appears 2 times" in violations[0].message
Activity · 5 steps
lines 468–468func = _make_func(tags={"brief": ["Do it."], "version": ["1.0"], "file": ["a", "b"]})lines 469–469violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)lines 470–470assert len(violations) == 1lines 471–471assert violations[0].check == "tag"lines 472–472assert "@file appears 2 times" in violations[0].message

test_duplicate_return_flagged

test_guard_checks.TestCheckDuplicateTags.test_duplicate_return_flagged(self)

tests/guard/test_guard_checks.py:492

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_duplicate_return_flagged → check_duplicate_tags
Source · 6 lines
    def test_duplicate_return_flagged(self):
        func = _make_func(tags={"brief": ["B."], "version": ["1.0"], "return": ["a", "b"]})
        violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert "@return" in violations[0].message
Activity · 4 steps
lines 493–493func = _make_func(tags={"brief": ["B."], "version": ["1.0"], "return": ["a", "b"]})lines 494–494violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)lines 495–495assert len(violations) == 1lines 496–496assert "@return" in violations[0].message

test_internal_is_still_a_recognised_tag

test_guard_checks.TestExemptionTagsAreToolOwned.test_internal_is_still_a_recognised_tag(self)

A project using \\internal for its real purpose must not be flagged.

tests/guard/test_guard_checks.py:550

Show on the map →

Called by none

Calls _make_func, check_unknown_tags

Checks

  • assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_internal_is_still_a_recognised_tag → check_unknown_tags
Source · 5 lines
    def test_internal_is_still_a_recognised_tag(self):
        """A project using \\internal for its real purpose must not be flagged."""
        func = _make_func(tags={"brief": ["B."], "version": ["1.0"], "internal": [""]})
        assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []
Activity · 2 steps
lines 552–552func = _make_func(tags={"brief": ["B."], "version": ["1.0"], "internal": [""]})lines 553–553assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []

test_invalid_pattern

test_guard_checks.TestCheckTags.test_invalid_pattern(self)

tests/guard/test_guard_checks.py:286

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert len(violations) == 1
  • assert "does not match pattern" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-003measuredtest_invalid_pattern → check_tags
Source · 13 lines
    def test_invalid_pattern(self):
        config = {
            "validate": {
                "tags": {
                    "req": {"pattern": r"^REQ-\w+$"},
                },
            }
        }
        funcs = [_make_func(tags={"brief": ["Something."], "version": ["1.0"], "req": ["INVALID"]})]
        violations = check_tags(funcs, "test.c", config)
        assert len(violations) == 1
        assert "does not match pattern" in violations[0].message
Activity · 5 steps
lines 287–293config = { "validate": { "tags": { "req": {"pattern": r"^REQ-\w+$"}, }, } }lines 294–294funcs = [_make_func(tags={"brief": ["Something."], "version": ["1.0"], "req": ["INVALID"]})]lines 295–295violations = check_tags(funcs, "test.c", config)lines 296–296assert len(violations) == 1lines 297–297assert "does not match pattern" in violations[0].message

test_line_numbers_1_indexed

test_guard_checks.TestCheckPresence.test_line_numbers_1_indexed(self)

tests/guard/test_guard_checks.py:100

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert violations[0].line == 1 # 0-indexed + 1

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_line_numbers_1_indexed → check_presence
REQ-DDB-GUARD-005inferredtest_line_numbers_1_indexed → check_presence → _is_void_function
Source · 6 lines
    def test_line_numbers_1_indexed(self):
        funcs = [_make_func(def_line=0, has_doxygen=False)]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert violations[0].line == 1  # 0-indexed + 1

Activity · 3 steps
lines 101–101funcs = [_make_func(def_line=0, has_doxygen=False)]lines 102–102violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 103–103assert violations[0].line == 1

test_missing_both_tags

test_guard_checks.TestCheckPresence.test_missing_both_tags(self)

tests/guard/test_guard_checks.py:64

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert len(violations) == 2

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_missing_both_tags → check_presence
REQ-DDB-GUARD-005inferredtest_missing_both_tags → check_presence → _is_void_function
Source · 5 lines
    def test_missing_both_tags(self):
        funcs = [_make_func(tags={})]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 2
Activity · 3 steps
lines 65–65funcs = [_make_func(tags={})]lines 66–66violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 67–67assert len(violations) == 2

test_missing_brief

test_guard_checks.TestCheckPresence.test_missing_brief(self)

tests/guard/test_guard_checks.py:52

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert len(violations) == 1
  • assert "missing @brief" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_missing_brief → check_presence
REQ-DDB-GUARD-005inferredtest_missing_brief → check_presence → _is_void_function
Source · 6 lines
    def test_missing_brief(self):
        funcs = [_make_func(tags={"version": ["1.0"]})]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert "missing @brief" in violations[0].message
Activity · 4 steps
lines 53–53funcs = [_make_func(tags={"version": ["1.0"]})]lines 54–54violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 55–55assert len(violations) == 1lines 56–56assert "missing @brief" in violations[0].message

test_missing_configured_tag_is_reported_by_that_name

test_guard_checks.TestConfiguredVersionTag.test_missing_configured_tag_is_reported_by_that_name(self)

tests/guard/test_guard_checks.py:594

Show on the map →

Called by none

Calls _config, _config, _make_func, check_presence

Checks

  • assert len(violations) == 1
  • assert "@revision" in violations[0].message
  • assert "@version" not in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_missing_configured_tag_is_reported_by_that_name → check_presence
REQ-DDB-GUARD-005inferredtest_missing_configured_tag_is_reported_by_that_name → check_presence → _is_void_function
Source · 7 lines
    def test_missing_configured_tag_is_reported_by_that_name(self):
        func = _make_func(tags={"brief": ["B."]})
        violations = check_presence([func], "a.c", self._config("@revision"))
        assert len(violations) == 1
        assert "@revision" in violations[0].message
        assert "@version" not in violations[0].message
Activity · 5 steps
lines 595–595func = _make_func(tags={"brief": ["B."]})lines 596–596violations = check_presence([func], "a.c", self._config("@revision"))lines 597–597assert len(violations) == 1lines 598–598assert "@revision" in violations[0].messagelines 599–599assert "@version" not in violations[0].message

test_missing_doxygen

test_guard_checks.TestCheckPresence.test_missing_doxygen(self)

tests/guard/test_guard_checks.py:45

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert len(violations) == 1
  • assert violations[0].check == "presence"
  • assert "no doxygen comment" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_missing_doxygen → check_presence
REQ-DDB-GUARD-005inferredtest_missing_doxygen → check_presence → _is_void_function
Source · 7 lines
    def test_missing_doxygen(self):
        funcs = [_make_func(has_doxygen=False)]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert violations[0].check == "presence"
        assert "no doxygen comment" in violations[0].message
Activity · 5 steps
lines 46–46funcs = [_make_func(has_doxygen=False)]lines 47–47violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 48–48assert len(violations) == 1lines 49–49assert violations[0].check == "presence"lines 50–50assert "no doxygen comment" in violations[0].message

test_missing_version

test_guard_checks.TestCheckPresence.test_missing_version(self)

tests/guard/test_guard_checks.py:58

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert len(violations) == 1
  • assert "missing @version" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_missing_version → check_presence
REQ-DDB-GUARD-005inferredtest_missing_version → check_presence → _is_void_function
Source · 6 lines
    def test_missing_version(self):
        funcs = [_make_func(tags={"brief": ["Something."]})]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert "missing @version" in violations[0].message
Activity · 4 steps
lines 59–59funcs = [_make_func(tags={"brief": ["Something."]})]lines 60–60violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 61–61assert len(violations) == 1lines 62–62assert "missing @version" in violations[0].message

test_multiple_functions

test_guard_checks.TestCheckPresence.test_multiple_functions(self)

tests/guard/test_guard_checks.py:91

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

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

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_multiple_functions → check_presence
REQ-DDB-GUARD-005inferredtest_multiple_functions → check_presence → _is_void_function
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-021inferred
REQ-DDB-GUARD-024inferred
REQ-DDB-GUARD-025measured
Source · 9 lines
    def test_multiple_functions(self):
        funcs = [
            _make_func(name="Good", def_line=5, body_end=10),
            _make_func(name="Bad", def_line=15, body_end=20, has_doxygen=False),
        ]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert len(violations) == 1
        assert "Bad" in violations[0].message
Activity · 4 steps
lines 92–95funcs = [ _make_func(name="Good", def_line=5, body_end=10), _make_func(name="Bad", def_line=15, body_end=20, has_doxygen=False), ]lines 96–96violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 97–97assert len(violations) == 1lines 98–98assert "Bad" in violations[0].message

test_new_function_not_in_head_skipped

test_guard_checks.TestCheckVersionStaleness.test_new_function_not_in_head_skipped(self)

A function absent from HEAD has no prior version to be stale against.

tests/guard/test_guard_checks.py:158

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_new_function_not_in_head_skipped → check_version_staleness
Source · 12 lines
    def test_new_function_not_in_head_skipped(self):
        """A function absent from HEAD has no prior version to be stale against."""
        func = _make_func(name="BrandNew", def_line=5, body_end=6)
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        # HEAD has an unrelated function, not this one
        head_func = _make_func(name="Other", def_line=5, body_end=6)
        head_content = "\n".join(_lines_for(head_func, "int x;\nint y;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert violations == []
Activity · 6 steps
lines 160–160func = _make_func(name="BrandNew", def_line=5, body_end=6)lines 161–161content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 163–163head_func = _make_func(name="Other", def_line=5, body_end=6)lines 164–164head_content = "\n".join(_lines_for(head_func, "int x;\nint y;"))lines 165–167violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 168–168assert violations == []

test_new_function_same_name_different_body_shape_still_new

test_guard_checks.TestCheckVersionStaleness.test_new_function_same_name_different_body_shape_still_new(self)

Regression for issue #10: a new function whose

tests/guard/test_guard_checks.py:252

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_new_function_same_name_different_body_shape_still_new → check_version_staleness
Source · 12 lines
    def test_new_function_same_name_different_body_shape_still_new(self):
        """Regression for issue #10: a new function whose @version line is textually
        identical to HEAD's must not be flagged, even though its enclosing content
        differs in ways that could confuse a positional diff."""
        func = _make_func(name="add_grid_source_params", def_line=5, body_end=6)
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, head_functions=[], head_content=""
        )
        assert violations == []

Activity · 4 steps
lines 256–256func = _make_func(name="add_grid_source_params", def_line=5, body_end=6)lines 257–257content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 258–260violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, head_functions=[], head_content="" )lines 261–261assert violations == []

test_no_doxygen_skipped

test_guard_checks.TestCheckVersionStaleness.test_no_doxygen_skipped(self)

tests/guard/test_guard_checks.py:170

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_no_doxygen_skipped → check_version_staleness
REQ-DDB-GUARD-003measured
Source · 10 lines
    def test_no_doxygen_skipped(self):
        func = _make_func(has_doxygen=False, def_line=5, body_end=6)
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(has_doxygen=False, def_line=5, body_end=6)
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert violations == []
Activity · 6 steps
lines 171–171func = _make_func(has_doxygen=False, def_line=5, body_end=6)lines 172–172content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 173–173head_func = _make_func(has_doxygen=False, def_line=5, body_end=6)lines 174–174head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 175–177violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 178–178assert violations == []
test_guard_checks.TestCheckTags.test_no_doxygen_skipped(self)

tests/guard/test_guard_checks.py:335

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measured
REQ-DDB-GUARD-003measuredtest_no_doxygen_skipped → check_tags
Source · 12 lines
    def test_no_doxygen_skipped(self):
        config = {
            "validate": {
                "tags": {
                    "req": {"pattern": r"^REQ-\w+$"},
                },
            }
        }
        funcs = [_make_func(has_doxygen=False)]
        violations = check_tags(funcs, "test.c", config)
        assert violations == []
Activity · 4 steps
lines 336–342config = { "validate": { "tags": { "req": {"pattern": r"^REQ-\w+$"}, }, } }lines 343–343funcs = [_make_func(has_doxygen=False)]lines 344–344violations = check_tags(funcs, "test.c", config)lines 345–345assert violations == []

test_no_head_functions_no_violation

test_guard_checks.TestCheckVersionStaleness.test_no_head_functions_no_violation(self)

No HEAD to compare against (e.g. new file) — nothing can be stale.

tests/guard/test_guard_checks.py:118

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_no_head_functions_no_violation → check_version_staleness
Source · 9 lines
    def test_no_head_functions_no_violation(self):
        """No HEAD to compare against (e.g. new file) — nothing can be stale."""
        funcs = [_make_func(def_line=5, body_end=6)]
        content = "\n".join(_lines_for(funcs[0], "int a;\nint b;"))
        violations = check_version_staleness(
            funcs, "test.c", CONFIG_DEFAULTS, content, head_functions=None, head_content=None
        )
        assert violations == []
Activity · 4 steps
lines 120–120funcs = [_make_func(def_line=5, body_end=6)]lines 121–121content = "\n".join(_lines_for(funcs[0], "int a;\nint b;"))lines 122–124violations = check_version_staleness( funcs, "test.c", CONFIG_DEFAULTS, content, head_functions=None, head_content=None )lines 125–125assert violations == []

test_no_tag_rules

test_guard_checks.TestCheckTags.test_no_tag_rules(self)

tests/guard/test_guard_checks.py:267

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-003measuredtest_no_tag_rules → check_tags
Source · 5 lines
    def test_no_tag_rules(self):
        funcs = [_make_func()]
        violations = check_tags(funcs, "test.c", CONFIG_DEFAULTS)
        assert violations == []
Activity · 3 steps
lines 268–268funcs = [_make_func()]lines 269–269violations = check_tags(funcs, "test.c", CONFIG_DEFAULTS)lines 270–270assert violations == []

test_no_version_tag_skipped

test_guard_checks.TestCheckVersionStaleness.test_no_version_tag_skipped(self)

Functions without

tests/guard/test_guard_checks.py:195

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_no_version_tag_skipped → check_version_staleness
Source · 11 lines
    def test_no_version_tag_skipped(self):
        """Functions without @version are skipped (caught by presence check)."""
        func = _make_func(def_line=5, body_end=6, tags={"brief": ["Something."]})
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6, tags={"brief": ["Something."]})
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert violations == []
Activity · 6 steps
lines 197–197func = _make_func(def_line=5, body_end=6, tags={"brief": ["Something."]})lines 198–198content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 199–199head_func = _make_func(def_line=5, body_end=6, tags={"brief": ["Something."]})lines 200–200head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 201–203violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 204–204assert violations == []

test_no_violations_when_documented

test_guard_checks.TestCheckPresence.test_no_violations_when_documented(self)

tests/guard/test_guard_checks.py:40

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_no_violations_when_documented → check_presence
REQ-DDB-GUARD-005inferredtest_no_violations_when_documented → check_presence → _is_void_function
Source · 5 lines
    def test_no_violations_when_documented(self):
        funcs = [_make_func()]
        violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)
        assert violations == []
Activity · 3 steps
lines 41–41funcs = [_make_func()]lines 42–42violations = check_presence(funcs, "test.c", CONFIG_DEFAULTS)lines 43–43assert violations == []

test_presence_disabled

test_guard_checks.TestCheckPresence.test_presence_disabled(self)

tests/guard/test_guard_checks.py:69

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_presence_disabled → check_presence
REQ-DDB-GUARD-005inferredtest_presence_disabled → check_presence → _is_void_function
Source · 11 lines
    def test_presence_disabled(self):
        config = {
            "validate": {
                "presence": {"require_doxygen": False},
                "version": {"require_present": True},
            }
        }
        funcs = [_make_func(has_doxygen=False)]
        violations = check_presence(funcs, "test.c", config)
        assert violations == []
Activity · 4 steps
lines 70–75config = { "validate": { "presence": {"require_doxygen": False}, "version": {"require_present": True}, } }lines 76–76funcs = [_make_func(has_doxygen=False)]lines 77–77violations = check_presence(funcs, "test.c", config)lines 78–78assert violations == []

test_regular_function_still_requires_req

test_guard_checks.TestConstructorDestructorSkipping.test_regular_function_still_requires_req(self)

tests/guard/test_guard_checks.py:421

Checks

  • assert len(violations) == 1

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-004measuredtest_regular_function_still_requires_req → check_req_coverage
REQ-DDB-GUARD-009inferredtest_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → filter_requirements_by_version
REQ-DDB-GUARD-011inferredtest_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → load_requirements_full
REQ-DDB-GUARD-014inferredtest_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version
REQ-DDB-GUARD-016inferredtest_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id
Source · 20 lines
    def test_regular_function_still_requires_req(self):
        from clew.guard.checks import check_req_coverage

        method = Function(
            name="bar",
            def_line=5,
            body_end=10,
            doxygen=DoxygenBlock(
                start_line=2, end_line=4, tags={"brief": ["Method."], "version": ["1.0"]}
            ),
            enclosing_class="Foo",
        )
        config = {
            "requirements": {"file": "reqs.csv"},
            "validate": {},
        }
        violations = check_req_coverage([method], "test.cpp", config)
        assert len(violations) == 1

Activity · 5 steps
lines 422–422from clew.guard.checks import check_req_coveragelines 424–432method = Function( name="bar", def_line=5, body_end=10, doxygen=DoxygenBlock( start_line=2, end_line=4, tags={"brief": ["Method."], "version": ["1.0"]} ), enclosing_class="Foo", )lines 433–436config = { "requirements": {"file": "reqs.csv"}, "validate": {}, }lines 437–437violations = check_req_coverage([method], "test.cpp", config)lines 438–438assert len(violations) == 1

test_repeatable_tags_are_not_flagged

test_guard_checks.TestCheckDuplicateTags.test_repeatable_tags_are_not_flagged(self)

tests/guard/test_guard_checks.py:502

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

  • assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_repeatable_tags_are_not_flagged → check_duplicate_tags
Source · 12 lines
    def test_repeatable_tags_are_not_flagged(self):
        """@req and @param are legitimately repeatable."""
        func = _make_func(
            tags={
                "brief": ["B."],
                "version": ["1.0"],
                "req": ["REQ-VAL-001", "REQ-VAL-002"],
                "param": ["a first", "b second"],
            }
        )
        assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []
Activity · 2 steps
lines 504–511func = _make_func( tags={ "brief": ["B."], "version": ["1.0"], "req": ["REQ-VAL-001", "REQ-VAL-002"], "param": ["a first", "b second"], } )lines 512–512assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []

test_require_contains

test_guard_checks.TestCheckTags.test_require_contains(self)

tests/guard/test_guard_checks.py:317

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert check_tags(funcs, "test.c", config) == []
  • assert len(violations) == 1
  • assert "does not contain" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-003measuredtest_require_contains → check_tags
Source · 18 lines
    def test_require_contains(self):
        config = {
            "validate": {
                "tags": {
                    "calls": {"require_contains": "::"},
                },
            }
        }
        # Valid
        funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "calls": ["mod::func"]})]
        assert check_tags(funcs, "test.c", config) == []

        # Invalid
        funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "calls": ["modfunc"]})]
        violations = check_tags(funcs, "test.c", config)
        assert len(violations) == 1
        assert "does not contain" in violations[0].message
Activity · 7 steps
lines 318–324config = { "validate": { "tags": { "calls": {"require_contains": "::"}, }, } }lines 326–326funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "calls": ["mod::func"]})]lines 327–327assert check_tags(funcs, "test.c", config) == []lines 330–330funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "calls": ["modfunc"]})]lines 331–331violations = check_tags(funcs, "test.c", config)lines 332–332assert len(violations) == 1lines 333–333assert "does not contain" in violations[0].message

test_require_prefix

test_guard_checks.TestCheckTags.test_require_prefix(self)

tests/guard/test_guard_checks.py:299

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert check_tags(funcs, "test.c", config) == []
  • assert len(violations) == 1
  • assert "does not start with" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-003measuredtest_require_prefix → check_tags
Source · 18 lines
    def test_require_prefix(self):
        config = {
            "validate": {
                "tags": {
                    "sends": {"require_prefix": ["EVENT:", "FSM:"]},
                },
            }
        }
        # Valid prefix
        funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "sends": ["EVENT:READY"]})]
        assert check_tags(funcs, "test.c", config) == []

        # Invalid prefix
        funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "sends": ["BADPREFIX"]})]
        violations = check_tags(funcs, "test.c", config)
        assert len(violations) == 1
        assert "does not start with" in violations[0].message
Activity · 7 steps
lines 300–306config = { "validate": { "tags": { "sends": {"require_prefix": ["EVENT:", "FSM:"]}, }, } }lines 308–308funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "sends": ["EVENT:READY"]})]lines 309–309assert check_tags(funcs, "test.c", config) == []lines 312–312funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"], "sends": ["BADPREFIX"]})]lines 313–313violations = check_tags(funcs, "test.c", config)lines 314–314assert len(violations) == 1lines 315–315assert "does not start with" in violations[0].message

test_reviewed_marker_clears_staleness

test_guard_checks.TestCheckVersionStaleness.test_reviewed_marker_clears_staleness(self)

Adding [reviewed] to

tests/guard/test_guard_checks.py:206

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_reviewed_marker_clears_staleness → check_version_staleness
Source · 15 lines
    def test_reviewed_marker_clears_staleness(self):
        """Adding [reviewed] to @version counts as updating the version."""
        func = _make_func(
            def_line=5,
            body_end=6,
            tags={"brief": ["Something."], "version": ["1.0 [reviewed]"]},
        )
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)  # version "1.0", no marker
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert violations == []
Activity · 6 steps
lines 208–212func = _make_func( def_line=5, body_end=6, tags={"brief": ["Something."], "version": ["1.0 [reviewed]"]}, )lines 213–213content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 214–214head_func = _make_func(def_line=5, body_end=6)lines 215–215head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 216–218violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 219–219assert violations == []

test_stacked_blocks_flag_the_single_valued_tags

test_guard_checks.TestCheckDuplicateTags.test_stacked_blocks_flag_the_single_valued_tags(self)

and

tests/guard/test_guard_checks.py:480

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

  • assert {v.message.split()[0] for v in violations} == {"@brief", "@return"}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_stacked_blocks_flag_the_single_valued_tags → check_duplicate_tags
Source · 12 lines
    def test_stacked_blocks_flag_the_single_valued_tags(self):
        """The real shape of the bug: two whole blocks means two of each tag.

        @version is excluded from the set — doxygen permits repeated \\version notes —
        so a stacked block is caught via @brief and @return instead.
        """
        func = _make_func(
            tags={"brief": ["Old.", "New."], "version": ["1.1", "1.0"], "return": ["a", "b"]}
        )
        violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)
        assert {v.message.split()[0] for v in violations} == {"@brief", "@return"}
Activity · 3 steps
lines 486–488func = _make_func( tags={"brief": ["Old.", "New."], "version": ["1.1", "1.0"], "return": ["a", "b"]} )lines 489–489violations = check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS)lines 490–490assert {v.message.split()[0] for v in violations} == {"@brief", "@return"}

test_staleness_disabled

test_guard_checks.TestCheckVersionStaleness.test_staleness_disabled(self)

tests/guard/test_guard_checks.py:180

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_staleness_disabled → check_version_staleness
Source · 15 lines
    def test_staleness_disabled(self):
        config = {
            "validate": {
                "version": {"require_increment_on_change": False, "tag": "@version"},
            }
        }
        func = _make_func(def_line=5, body_end=6)
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", config, content, [head_func], head_content
        )
        assert violations == []
Activity · 7 steps
lines 181–185config = { "validate": { "version": {"require_increment_on_change": False, "tag": "@version"}, } }lines 186–186func = _make_func(def_line=5, body_end=6)lines 187–187content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 188–188head_func = _make_func(def_line=5, body_end=6)lines 189–189head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 190–192violations = check_version_staleness( [func], "test.c", config, content, [head_func], head_content )lines 193–193assert violations == []

test_tag_not_present_no_violation

test_guard_checks.TestCheckTags.test_tag_not_present_no_violation(self)

Tags that aren't present in the doxygen block don't trigger violations.

tests/guard/test_guard_checks.py:347

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-003measuredtest_tag_not_present_no_violation → check_tags
Source · 13 lines
    def test_tag_not_present_no_violation(self):
        """Tags that aren't present in the doxygen block don't trigger violations."""
        config = {
            "validate": {
                "tags": {
                    "req": {"pattern": r"^REQ-\w+$"},
                },
            }
        }
        funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"]})]
        violations = check_tags(funcs, "test.c", config)
        assert violations == []
Activity · 4 steps
lines 349–355config = { "validate": { "tags": { "req": {"pattern": r"^REQ-\w+$"}, }, } }lines 356–356funcs = [_make_func(tags={"brief": ["X."], "version": ["1.0"]})]lines 357–357violations = check_tags(funcs, "test.c", config)lines 358–358assert violations == []

test_undocumented_function_is_not_flagged

test_guard_checks.TestCheckDuplicateTags.test_undocumented_function_is_not_flagged(self)

tests/guard/test_guard_checks.py:514

Show on the map →

Called by none

Calls _make_func, check_duplicate_tags

Checks

  • assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-007measuredtest_undocumented_function_is_not_flagged → check_duplicate_tags
Source · 4 lines
    def test_undocumented_function_is_not_flagged(self):
        func = _make_func(has_doxygen=False)
        assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []
Activity · 2 steps
lines 515–515func = _make_func(has_doxygen=False)lines 516–516assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []

test_unknown_version_marker_rejected

test_guard_checks.TestCheckVersionStaleness.test_unknown_version_marker_rejected(self)

Unknown markers like [typo] are rejected.

tests/guard/test_guard_checks.py:221

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert len(violations) == 1
  • assert "unrecognized version marker" in violations[0].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_unknown_version_marker_rejected → check_version_staleness
Source · 16 lines
    def test_unknown_version_marker_rejected(self):
        """Unknown markers like [typo] are rejected."""
        func = _make_func(
            def_line=5,
            body_end=6,
            tags={"brief": ["Something."], "version": ["1.0 [typo]"]},
        )
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)  # version "1.0", no marker
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert len(violations) == 1
        assert "unrecognized version marker" in violations[0].message
Activity · 7 steps
lines 223–227func = _make_func( def_line=5, body_end=6, tags={"brief": ["Something."], "version": ["1.0 [typo]"]}, )lines 228–228content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 229–229head_func = _make_func(def_line=5, body_end=6)lines 230–230head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 231–233violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 234–234assert len(violations) == 1lines 235–235assert "unrecognized version marker" in violations[0].message

test_valid_pattern

test_guard_checks.TestCheckTags.test_valid_pattern(self)

tests/guard/test_guard_checks.py:272

Show on the map →

Called by none

Calls _make_func, check_tags

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-003measuredtest_valid_pattern → check_tags
Source · 14 lines
    def test_valid_pattern(self):
        config = {
            "validate": {
                "tags": {
                    "req": {"pattern": r"^REQ-\w+$"},
                },
            }
        }
        funcs = [
            _make_func(tags={"brief": ["Something."], "version": ["1.0"], "req": ["REQ-0001"]})
        ]
        violations = check_tags(funcs, "test.c", config)
        assert violations == []
Activity · 4 steps
lines 273–279config = { "validate": { "tags": { "req": {"pattern": r"^REQ-\w+$"}, }, } }lines 280–282funcs = [ _make_func(tags={"brief": ["Something."], "version": ["1.0"], "req": ["REQ-0001"]}) ]lines 283–283violations = check_tags(funcs, "test.c", config)lines 284–284assert violations == []

test_version_bump_still_works

test_guard_checks.TestCheckVersionStaleness.test_version_bump_still_works(self)

Normal version bump (no marker) still passes.

tests/guard/test_guard_checks.py:237

Show on the map →

Called by none

Calls _lines_for, _make_func, check_version_staleness

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-002measuredtest_version_bump_still_works → check_version_staleness
Source · 15 lines
    def test_version_bump_still_works(self):
        """Normal version bump (no marker) still passes."""
        func = _make_func(
            def_line=5,
            body_end=6,
            tags={"brief": ["Something."], "version": ["1.1"]},
        )
        content = "\n".join(_lines_for(func, "int a;\nint b;"))
        head_func = _make_func(def_line=5, body_end=6)  # version "1.0"
        head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))
        violations = check_version_staleness(
            [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content
        )
        assert violations == []
Activity · 6 steps
lines 239–243func = _make_func( def_line=5, body_end=6, tags={"brief": ["Something."], "version": ["1.1"]}, )lines 244–244content = "\n".join(_lines_for(func, "int a;\nint b;"))lines 245–245head_func = _make_func(def_line=5, body_end=6)lines 246–246head_content = "\n".join(_lines_for(head_func, "int a;\nint c;"))lines 247–249violations = check_version_staleness( [func], "test.c", CONFIG_DEFAULTS, content, [head_func], head_content )lines 250–250assert violations == []

test_version_not_required

test_guard_checks.TestCheckPresence.test_version_not_required(self)

tests/guard/test_guard_checks.py:80

Show on the map →

Called by none

Calls _make_func, check_presence

Checks

  • assert violations == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measuredtest_version_not_required → check_presence
REQ-DDB-GUARD-005inferredtest_version_not_required → check_presence → _is_void_function
Source · 11 lines
    def test_version_not_required(self):
        config = {
            "validate": {
                "presence": {"require_doxygen": True},
                "version": {"require_present": False},
            }
        }
        funcs = [_make_func(tags={"brief": ["Something."]})]
        violations = check_presence(funcs, "test.c", config)
        assert violations == []
Activity · 4 steps
lines 81–86config = { "validate": { "presence": {"require_doxygen": True}, "version": {"require_present": False}, } }lines 87–87funcs = [_make_func(tags={"brief": ["Something."]})]lines 88–88violations = check_presence(funcs, "test.c", config)lines 89–89assert violations == []