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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_body_changed_version_not_updated
test_guard_checks.TestCheckVersionStaleness.test_body_changed_version_not_updated(self)
tests/guard/test_guard_checks.py:136
Checks
assert len(violations) == 1assert violations[0].check == "version"assert "not updated" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_body_unchanged_no_violation
test_guard_checks.TestCheckVersionStaleness.test_body_unchanged_no_violation(self)
tests/guard/test_guard_checks.py:127
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_check_can_be_disabled
test_guard_checks.TestCheckDuplicateTags.test_check_can_be_disabled(self)
tests/guard/test_guard_checks.py:518
Checks
assert check_duplicate_tags(func, "test.c", config) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
test_clean_block_passes
test_guard_checks.TestCheckDuplicateTags.test_clean_block_passes(self)
tests/guard/test_guard_checks.py:498
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
test_configured_tag_satisfies_presence
test_guard_checks.TestConfiguredVersionTag.test_configured_tag_satisfies_presence(self)
tests/guard/test_guard_checks.py:590
Checks
assert check_presence([func], "a.c", self._config("@revision")) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_configured_tag_satisfies_presence → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-004 | measured | test_constructor_skipped_for_req_check → check_req_coverage |
| REQ-DDB-GUARD-009 | inferred | test_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-014 | inferred | test_constructor_skipped_for_req_check → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-005 | measured | test_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
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
Checks
assert violationsassert "@utility" in messageassert "@internal," not in message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-004 | measured | test_coverage_message_lists_the_real_exemption_tags → check_req_coverage |
| REQ-DDB-GUARD-009 | inferred | test_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-014 | inferred | test_coverage_message_lists_the_real_exemption_tags → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_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
test_default_remains_version
test_guard_checks.TestConfiguredVersionTag.test_default_remains_version(self)
tests/guard/test_guard_checks.py:601
Checks
assert check_presence([func], "a.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_default_remains_version → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-005 | measured | test_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
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
Checks
assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_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
test_duplicate_brief_flagged
test_guard_checks.TestCheckDuplicateTags.test_duplicate_brief_flagged(self)
tests/guard/test_guard_checks.py:474
Checks
assert len(violations) == 1assert "@brief" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
test_duplicate_file_tag_flagged
test_guard_checks.TestCheckDuplicateTags.test_duplicate_file_tag_flagged(self)
tests/guard/test_guard_checks.py:467
Checks
assert len(violations) == 1assert violations[0].check == "tag"assert "@file appears 2 times" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
test_duplicate_return_flagged
test_guard_checks.TestCheckDuplicateTags.test_duplicate_return_flagged(self)
tests/guard/test_guard_checks.py:492
Checks
assert len(violations) == 1assert "@return" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
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
Checks
assert check_unknown_tags(func, "a.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_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
test_invalid_pattern
test_guard_checks.TestCheckTags.test_invalid_pattern(self)
tests/guard/test_guard_checks.py:286
Checks
assert len(violations) == 1assert "does not match pattern" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-003 | measured | test_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
test_line_numbers_1_indexed
test_guard_checks.TestCheckPresence.test_line_numbers_1_indexed(self)
tests/guard/test_guard_checks.py:100
Checks
assert violations[0].line == 1 # 0-indexed + 1
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_line_numbers_1_indexed → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
test_missing_both_tags
test_guard_checks.TestCheckPresence.test_missing_both_tags(self)
tests/guard/test_guard_checks.py:64
Checks
assert len(violations) == 2
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_missing_both_tags → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
test_missing_brief
test_guard_checks.TestCheckPresence.test_missing_brief(self)
tests/guard/test_guard_checks.py:52
Checks
assert len(violations) == 1assert "missing @brief" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_missing_brief → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
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
Checks
assert len(violations) == 1assert "@revision" in violations[0].messageassert "@version" not in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_missing_configured_tag_is_reported_by_that_name → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
test_missing_doxygen
test_guard_checks.TestCheckPresence.test_missing_doxygen(self)
tests/guard/test_guard_checks.py:45
Checks
assert len(violations) == 1assert violations[0].check == "presence"assert "no doxygen comment" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_missing_doxygen → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
test_missing_version
test_guard_checks.TestCheckPresence.test_missing_version(self)
tests/guard/test_guard_checks.py:58
Checks
assert len(violations) == 1assert "missing @version" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_missing_version → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
test_multiple_functions
test_guard_checks.TestCheckPresence.test_multiple_functions(self)
tests/guard/test_guard_checks.py:91
Checks
assert len(violations) == 1assert "Bad" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_multiple_functions → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_multiple_functions → check_presence → _is_void_function |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-021 | inferred | |
| REQ-DDB-GUARD-024 | inferred | |
| REQ-DDB-GUARD-025 | measured |
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
test_multiple_version_entries_are_legal
test_guard_checks.TestCheckDuplicateTags.test_multiple_version_entries_are_legal(self)
Doxygen permits repeated \\version notes; flagging them rejected valid doxygen.
tests/guard/test_guard_checks.py:523
Checks
assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_multiple_version_entries_are_legal → check_duplicate_tags |
Source · 10 lines
def test_multiple_version_entries_are_legal(self):
"""Doxygen permits repeated \\version notes; flagging them rejected valid doxygen.
Regression introduced with this check in 1.3.0 and fixed by removing "version"
from _SINGLE_VALUED_TAGS.
"""
func = _make_func(tags={"brief": ["B."], "version": ["1.0", "2.0"]})
assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []
Activity · 2 steps
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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_no_doxygen_skipped
test_guard_checks.TestCheckVersionStaleness.test_no_doxygen_skipped(self)
tests/guard/test_guard_checks.py:170
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_no_doxygen_skipped → check_version_staleness |
| REQ-DDB-GUARD-003 | measured |
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
test_guard_checks.TestCheckTags.test_no_doxygen_skipped(self)
tests/guard/test_guard_checks.py:335
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | |
| REQ-DDB-GUARD-003 | measured | test_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
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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_no_tag_rules
test_guard_checks.TestCheckTags.test_no_tag_rules(self)
tests/guard/test_guard_checks.py:267
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-003 | measured | test_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
test_no_version_tag_skipped
test_guard_checks.TestCheckVersionStaleness.test_no_version_tag_skipped(self)
Functions without
tests/guard/test_guard_checks.py:195
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_no_violations_when_documented
test_guard_checks.TestCheckPresence.test_no_violations_when_documented(self)
tests/guard/test_guard_checks.py:40
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_no_violations_when_documented → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
test_presence_disabled
test_guard_checks.TestCheckPresence.test_presence_disabled(self)
tests/guard/test_guard_checks.py:69
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_presence_disabled → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-004 | measured | test_regular_function_still_requires_req → check_req_coverage |
| REQ-DDB-GUARD-009 | inferred | test_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-014 | inferred | test_regular_function_still_requires_req → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_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
test_repeatable_tags_are_not_flagged
test_guard_checks.TestCheckDuplicateTags.test_repeatable_tags_are_not_flagged(self)
tests/guard/test_guard_checks.py:502
Checks
assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
test_require_contains
test_guard_checks.TestCheckTags.test_require_contains(self)
tests/guard/test_guard_checks.py:317
Checks
assert check_tags(funcs, "test.c", config) == []assert len(violations) == 1assert "does not contain" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-003 | measured | test_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
test_require_prefix
test_guard_checks.TestCheckTags.test_require_prefix(self)
tests/guard/test_guard_checks.py:299
Checks
assert check_tags(funcs, "test.c", config) == []assert len(violations) == 1assert "does not start with" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-003 | measured | test_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
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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
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
Checks
assert {v.message.split()[0] for v in violations} == {"@brief", "@return"}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
test_staleness_disabled
test_guard_checks.TestCheckVersionStaleness.test_staleness_disabled(self)
tests/guard/test_guard_checks.py:180
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-003 | measured | test_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
test_undocumented_function_is_not_flagged
test_guard_checks.TestCheckDuplicateTags.test_undocumented_function_is_not_flagged(self)
tests/guard/test_guard_checks.py:514
Checks
assert check_duplicate_tags(func, "test.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-007 | measured | test_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
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
Checks
assert len(violations) == 1assert "unrecognized version marker" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_valid_pattern
test_guard_checks.TestCheckTags.test_valid_pattern(self)
tests/guard/test_guard_checks.py:272
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-003 | measured | test_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
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
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-002 | measured | test_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
test_version_not_required
test_guard_checks.TestCheckPresence.test_version_not_required(self)
tests/guard/test_guard_checks.py:80
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_version_not_required → check_presence |
| REQ-DDB-GUARD-005 | inferred | test_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 == []