test_guard_main.py¶
tests/guard/test_guard_main.py
Tests for clew.guard.main (absorbed from doxygen-guard).
test_a_checked_tree_says_nothing_extra
test_guard_main.TestSkipsAreReported.test_a_checked_tree_says_nothing_extra(self, tmp_path, monkeypatch, capsys)
No skip line when every file was checked.
tests/guard/test_guard_main.py:403
Checks
assert rc == 1assert "not checked" not in captured.out + captured.err
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 16 lines
def test_a_checked_tree_says_nothing_extra(self, tmp_path, monkeypatch, capsys):
"""The line is evidence of a skip, not decoration: with nothing skipped it must not
appear, or it becomes noise an owner learns to ignore.
@brief No skip line when every file was checked. @version 1
"""
dirty = self._dirty_tree(tmp_path)
monkeypatch.chdir(tmp_path)
rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(dirty)])
captured = capsys.readouterr()
assert rc == 1
assert "not checked" not in captured.out + captured.err
Activity · 6 steps
test_a_configured_language_is_not_reported
test_guard_main.TestUnconfiguredLanguagesAreReported.test_a_configured_language_is_not_reported(self, tmp_path, monkeypatch, capsys)
A language the config enables is checked, not reported as skipped.
tests/guard/test_guard_main.py:470
Checks
assert rc == 1, "C is configured by default, so the undocumented function must fail"assert "not checked" not in surface
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 11 lines
def test_a_configured_language_is_not_reported(self, tmp_path, monkeypatch, capsys):
"""@brief A language the config enables is checked, not reported as skipped. @version 1"""
c_file = tmp_path / "thing.c"
c_file.write_text("void Undoc_Func(void) {\n do_stuff();\n}\n")
monkeypatch.chdir(tmp_path)
rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(c_file)])
surface = "".join(capsys.readouterr())
assert rc == 1, "C is configured by default, so the undocumented function must fail"
assert "not checked" not in surface1 more lines, not shown
Activity · 7 steps
test_a_non_source_file_stays_silent
test_guard_main.TestUnconfiguredLanguagesAreReported.test_a_non_source_file_stays_silent(self, tmp_path, monkeypatch, capsys)
A file no shipped language claims produces no report.
tests/guard/test_guard_main.py:455
Checks
assert rc == 0assert "not checked" not in "".join(capsys.readouterr())
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 15 lines
def test_a_non_source_file_stays_silent(self, tmp_path, monkeypatch, capsys):
"""THE CONTROL that keeps the line where it is. The gate ships no language for
Markdown, so Markdown is not something it failed to check.
@brief A file no shipped language claims produces no report. @version 1
"""
doc = tmp_path / "README.md"
doc.write_text("# hello\n")
monkeypatch.chdir(tmp_path)
rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(doc)])
assert rc == 0
assert "not checked" not in "".join(capsys.readouterr())
Activity · 6 steps
test_a_symlinked_impact_directory_is_refused
test_guard_main.TestPrecommitPipeline.test_a_symlinked_impact_directory_is_refused(self, tmp_path, monkeypatch)
M5, 1.1.0 SECURITY AUDIT. `run_precommit` validated `output_dir` and then wrote to `output_dir/impact/impact.md` — a DIFFERENT path. A committed `out/impact -> ../../elsewhere` passes the check on `out/`, `mkdir(exist_ok=True)` follows it, and the gate writes the report outside the repository and `git add`s it, all while running as the committing user on a branch they are only reviewing.
tests/guard/test_guard_main.py:233
Checks
assert rc != 0, "the gate must fail rather than write through the symlink"assert not list(outside.iterdir()), (f"the gate wrote outside the repository through a symlinked impact directory: " f"{list(outside.iterdir())}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-002 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-023 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 57 lines
def test_a_symlinked_impact_directory_is_refused(self, tmp_path, monkeypatch):
"""M5, 1.1.0 SECURITY AUDIT. `run_precommit` validated `output_dir` and then wrote to
`output_dir/impact/impact.md` — a DIFFERENT path. A committed
`out/impact -> ../../elsewhere` passes the check on `out/`, `mkdir(exist_ok=True)`
follows it, and the gate writes the report outside the repository and `git add`s it,
all while running as the committing user on a branch they are only reviewing.
The full write path is validated, which is what the sibling in `_run_impact_command`
already did with its `output.file`.
"""
monkeypatch.chdir(tmp_path)
outside = tmp_path.parent / f"escaped-{tmp_path.name}"
outside.mkdir(exist_ok=True)
src = tmp_path / "src"
src.mkdir()
c_file = src / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Process data.
* @version 1.0
* @req REQ-001
*/
void Process(void) {
event_post(EVENT_DATA_READY);
}
""")
)
(tmp_path / "reqs.csv").write_text("Req ID,Name,Subsystem\nREQ-001,Data,DataSvc\n")
(tmp_path / "out").mkdir()
(tmp_path / "out" / "impact").symlink_to(outside)
config_file = tmp_path / ".clew.yaml"
## FIXTURE CHANGED (2.0.0, R5-CFG F7/F9): the catalog is the top-level `requirements:`
## and the report directory is `guard.impact.report_dir` (it was `output_dir/impact/`).
config_file.write_text(
dedent("""\
requirements:
file: reqs.csv
id_column: "Req ID"
name_column: "Name"
format: csv
""")
+ guard_yaml("impact:\n report_dir: out/impact/\n")
)
## `main` IS THE CLI BOUNDARY and turns a GuardError into an exit code rather than a
## traceback — so the refusal is asserted as the gate's own failure, which is what a
## committing developer actually sees.
rc = main(["--config", str(config_file), str(c_file)])
assert rc != 0, "the gate must fail rather than write through the symlink"
assert not list(outside.iterdir()), (
f"the gate wrote outside the repository through a symlinked impact directory: "
f"{list(outside.iterdir())}"
)
Activity · 15 steps
test_all_checks_run
test_guard_main.TestValidateFile.test_all_checks_run(self, tmp_path)
tests/guard/test_guard_main.py:54
Checks
assert len(violations) == 1assert "Bad_Func" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_all_checks_run → validate_file → get_file_at_revision → run_git → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_all_checks_run → validate_file → gate_exclusion |
| REQ-DDB-GUARD-001 | measured | test_all_checks_run → validate_file |
| REQ-DDB-GUARD-002 | inferred | test_all_checks_run → validate_file → check_version_staleness |
| REQ-DDB-GUARD-003 | measured | test_all_checks_run → validate_file → check_tags |
| REQ-DDB-GUARD-004 | measured | test_all_checks_run → validate_file → check_req_coverage |
| REQ-DDB-GUARD-005 | measured | test_all_checks_run → validate_file → check_return_presence |
| REQ-DDB-GUARD-006 | measured | test_all_checks_run → validate_file → check_file_presence |
| REQ-DDB-GUARD-007 | measured | test_all_checks_run → validate_file → check_duplicate_tags |
| REQ-DDB-GUARD-009 | inferred | test_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-013 | measured | test_all_checks_run → validate_file → unconfigured_language |
| REQ-DDB-GUARD-014 | inferred | test_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_all_checks_run → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id |
| REQ-DDB-GUARD-018 | measured | test_all_checks_run → validate_file → parse_source_file |
| REQ-DDB-GUARD-019 | measured | test_all_checks_run → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_all_checks_run → validate_file → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_all_checks_run → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-023 | inferred | test_all_checks_run → validate_file → get_file_at_revision |
| REQ-DDB-GUARD-024 | inferred | test_all_checks_run → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief |
| REQ-DDB-GUARD-025 | measured | test_all_checks_run → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-026 | measured | test_all_checks_run → validate_file → check_bus_tags |
| REQ-DDB-GUARD-027 | inferred | test_all_checks_run → validate_file → check_req_exists → _uncheckable |
| REQ-DDB-PIPE-011 | measured | test_all_checks_run → validate_file → gate_exclusion → binary_file |
| REQ-DDB-WIKI-054 | inferred | test_all_checks_run → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 22 lines
def test_all_checks_run(self, tmp_path):
c_file = tmp_path / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Good function.
* @version 1.0
*/
void Good_Func(void) {
x();
}
void Bad_Func(void) {
y();
}
""")
)
violations = validate_file(str(c_file), CONFIG_DEFAULTS, no_git=True)
assert len(violations) == 1
assert "Bad_Func" in violations[0].message
Activity · 5 steps
test_an_opt_in_language_left_unconfigured_is_named
test_guard_main.TestUnconfiguredLanguagesAreReported.test_an_opt_in_language_left_unconfigured_is_named(self, tmp_path, monkeypatch, capsys)
An unconfigured shipped language is reported, not skipped silently.
tests/guard/test_guard_main.py:442
Checks
assert rc == 0, "nothing is configured to check it, so there is no violation to report"assert "not checked" in surface and "rust" in surface, (f"the gate reported success over an unchecked Rust file in silence: {surface!r}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 13 lines
def test_an_opt_in_language_left_unconfigured_is_named(self, tmp_path, monkeypatch, capsys):
"""@brief An unconfigured shipped language is reported, not skipped silently. @version 1"""
rust = self._rust_tree(tmp_path)
monkeypatch.chdir(tmp_path)
rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(rust)])
surface = "".join(capsys.readouterr())
assert rc == 0, "nothing is configured to check it, so there is no violation to report"
assert "not checked" in surface and "rust" in surface, (
f"the gate reported success over an unchecked Rust file in silence: {surface!r}"
)
Activity · 6 steps
test_an_unchecked_file_is_named_without_the_verbose_flag
test_guard_main.TestSkipsAreReported.test_an_unchecked_file_is_named_without_the_verbose_flag(self, tmp_path, monkeypatch, capsys)
A toolchain-ignored file is reported on the default surface.
tests/guard/test_guard_main.py:385
Checks
assert rc == 0, "the ignore is honoured, so there is nothing to fail on"assert "1 file(s) not checked" in surface, (f"the gate passed without saying it checked nothing; surface was {surface!r}" )assert "toolchain.toml" in surface, "the report must name what decided the skip"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 18 lines
def test_an_unchecked_file_is_named_without_the_verbose_flag(
self, tmp_path, monkeypatch, capsys
):
"""@brief A toolchain-ignored file is reported on the default surface. @version 1"""
dirty = self._dirty_tree(tmp_path)
(tmp_path / "toolchain.toml").write_text('[clew.ignore]\npaths = ["gen/**"]\n')
monkeypatch.chdir(tmp_path)
rc = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(dirty)])
captured = capsys.readouterr()
surface = captured.out + captured.err
assert rc == 0, "the ignore is honoured, so there is nothing to fail on"
assert "1 file(s) not checked" in surface, (
f"the gate passed without saying it checked nothing; surface was {surface!r}"
)
assert "toolchain.toml" in surface, "the report must name what decided the skip"
Activity · 9 steps
test_custom_config
test_guard_main.TestMain.test_custom_config(self, tmp_path)
tests/guard/test_guard_main.py:148
Checks
assert result == 0 # Presence check disabled
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 17 lines
def test_custom_config(self, tmp_path):
config_file = tmp_path / "custom.yaml"
config_file.write_text(
guard_yaml(
dedent("""\
validate:
presence:
require_doxygen: false
""")
)
)
c_file = tmp_path / "test.c"
c_file.write_text("void Undoc(void) { x(); }")
result = main(["--config", str(config_file), "validate", "--no-git", str(c_file)])
assert result == 0 # Presence check disabled
Activity · 6 steps
test_default_subcommand_with_files
test_guard_main.TestMain.test_default_subcommand_with_files(self, tmp_path)
When no subcommand is given, treat args as files (pre-commit mode).
tests/guard/test_guard_main.py:115
Checks
assert result == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-002 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-022 | measured | |
| REQ-DDB-GUARD-023 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 17 lines
def test_default_subcommand_with_files(self, tmp_path):
"""When no subcommand is given, treat args as files (pre-commit mode)."""
c_file = tmp_path / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Func.
* @version 1.0
*/
void Func(void) {
x();
}
""")
)
result = main(["--config", NO_REQ_CONFIG, str(c_file)])
assert result == 0
Activity · 4 steps
test_documented_file_no_violations
test_guard_main.TestValidateFile.test_documented_file_no_violations(self)
tests/guard/test_guard_main.py:18
Checks
assert len(violations) == 1assert "Undocumented_Function" in violations[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_documented_file_no_violations → validate_file → get_file_at_revision → run_git → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_documented_file_no_violations → validate_file → gate_exclusion |
| REQ-DDB-GUARD-001 | measured | test_documented_file_no_violations → validate_file |
| REQ-DDB-GUARD-002 | inferred | test_documented_file_no_violations → validate_file → check_version_staleness |
| REQ-DDB-GUARD-003 | measured | test_documented_file_no_violations → validate_file → check_tags |
| REQ-DDB-GUARD-004 | measured | test_documented_file_no_violations → validate_file → check_req_coverage |
| REQ-DDB-GUARD-005 | measured | test_documented_file_no_violations → validate_file → check_return_presence |
| REQ-DDB-GUARD-006 | measured | test_documented_file_no_violations → validate_file → check_file_presence |
| REQ-DDB-GUARD-007 | measured | test_documented_file_no_violations → validate_file → check_duplicate_tags |
| REQ-DDB-GUARD-009 | inferred | test_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-013 | measured | test_documented_file_no_violations → validate_file → unconfigured_language |
| REQ-DDB-GUARD-014 | inferred | test_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_documented_file_no_violations → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id |
| REQ-DDB-GUARD-018 | measured | test_documented_file_no_violations → validate_file → parse_source_file |
| REQ-DDB-GUARD-019 | measured | test_documented_file_no_violations → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_documented_file_no_violations → validate_file → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_documented_file_no_violations → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-023 | inferred | test_documented_file_no_violations → validate_file → get_file_at_revision |
| REQ-DDB-GUARD-024 | inferred | test_documented_file_no_violations → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief |
| REQ-DDB-GUARD-025 | measured | test_documented_file_no_violations → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-026 | measured | test_documented_file_no_violations → validate_file → check_bus_tags |
| REQ-DDB-GUARD-027 | inferred | test_documented_file_no_violations → validate_file → check_req_exists → _uncheckable |
| REQ-DDB-PIPE-011 | measured | test_documented_file_no_violations → validate_file → gate_exclusion → binary_file |
| REQ-DDB-WIKI-054 | inferred | test_documented_file_no_violations → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 13 lines
def test_documented_file_no_violations(self):
# Create a minimal fully-documented C file
config = CONFIG_DEFAULTS.copy()
# Use simple.c but only the documented functions will pass
violations = validate_file(
str(FIXTURES_DIR / "simple.c"),
config,
no_git=True,
)
# simple.c has one undocumented function
assert len(violations) == 1
assert "Undocumented_Function" in violations[0].message
Activity · 4 steps
test_excluded_file
test_guard_main.TestValidateFile.test_excluded_file(self, tmp_path, monkeypatch)
tests/guard/test_guard_main.py:37
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_excluded_file → validate_file → get_file_at_revision → run_git → git_argv |
| REQ-DDB-CONFIG-009 | inferred | test_excluded_file → validate_file → gate_exclusion |
| REQ-DDB-GUARD-001 | measured | test_excluded_file → validate_file |
| REQ-DDB-GUARD-002 | inferred | test_excluded_file → validate_file → check_version_staleness |
| REQ-DDB-GUARD-003 | inferred | test_excluded_file → validate_file → check_tags |
| REQ-DDB-GUARD-004 | inferred | test_excluded_file → validate_file → check_req_coverage |
| REQ-DDB-GUARD-005 | inferred | test_excluded_file → validate_file → check_return_presence |
| REQ-DDB-GUARD-006 | inferred | test_excluded_file → validate_file → check_file_presence |
| REQ-DDB-GUARD-007 | inferred | test_excluded_file → validate_file → check_duplicate_tags |
| REQ-DDB-GUARD-009 | inferred | test_excluded_file → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | inferred | test_excluded_file → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-013 | measured | test_excluded_file → validate_file → unconfigured_language |
| REQ-DDB-GUARD-014 | inferred | test_excluded_file → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_excluded_file → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id |
| REQ-DDB-GUARD-018 | inferred | test_excluded_file → validate_file → parse_source_file |
| REQ-DDB-GUARD-019 | inferred | test_excluded_file → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | inferred | test_excluded_file → validate_file → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_excluded_file → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-023 | inferred | test_excluded_file → validate_file → get_file_at_revision |
| REQ-DDB-GUARD-024 | inferred | test_excluded_file → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief |
| REQ-DDB-GUARD-025 | inferred | test_excluded_file → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-026 | inferred | test_excluded_file → validate_file → check_bus_tags |
| REQ-DDB-GUARD-027 | inferred | test_excluded_file → validate_file → check_req_exists → _uncheckable |
| REQ-DDB-PIPE-011 | inferred | test_excluded_file → validate_file → gate_exclusion → binary_file |
| REQ-DDB-WIKI-054 | inferred | test_excluded_file → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 17 lines
def test_excluded_file(self, tmp_path, monkeypatch):
## 2.0.0 (R5-CFG F18): excludes are repo-relative globs, so the gate runs from the repo root
## (as pre-commit runs it); `gen/` is the directory at the root.
monkeypatch.chdir(tmp_path)
c_file = tmp_path / "gen" / "auto.c"
c_file.parent.mkdir()
c_file.write_text("void Func(void) { }")
config = {
"validate": {
**CONFIG_DEFAULTS["validate"],
"exclude": ["gen/"],
},
"impact": CONFIG_DEFAULTS["impact"],
}
violations = validate_file(str(c_file), config, no_git=True)
assert violations == []
Activity · 7 steps
test_impact_no_files_returns_0
test_guard_main.TestMain.test_impact_no_files_returns_0(self)
tests/guard/test_guard_main.py:176
Checks
assert result == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-GUARD-009 | measured | |
| REQ-DDB-GUARD-010 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-021 | measured | |
| REQ-DDB-GUARD-023 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-MCP-001 | measured |
Source · 5 lines
def test_impact_no_files_returns_0(self):
result = main(["impact", "--staged"])
assert result == 0
Activity · 2 steps
test_literal_version_resolves
test_guard_main.TestVersionGateFailsClosed.test_literal_version_resolves(self, tmp_path, monkeypatch)
tests/guard/test_guard_main.py:349
Checks
assert main(["validate", "--no-git", str(c_file)]) == 1
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-009 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 8 lines
def test_literal_version_resolves(self, tmp_path, monkeypatch):
c_file = self._project(tmp_path)
cfg = tmp_path / ".clew.yaml"
cfg.write_text(cfg.read_text().replace('"auto:git"', '"v1.0.0"'))
monkeypatch.chdir(tmp_path)
# Gate resolves, so the requirement is active and the missing @req is caught.
assert main(["validate", "--no-git", str(c_file)]) == 1
Activity · 5 steps
test_no_files_returns_zero
test_guard_main.TestMain.test_no_files_returns_zero(self)
tests/guard/test_guard_main.py:79
Checks
assert result == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-024 | measured |
Source · 4 lines
def test_no_files_returns_zero(self):
result = main(["validate"])
assert result == 0
Activity · 2 steps
test_no_gate_declared_is_not_an_error
test_guard_main.TestVersionGateFailsClosed.test_no_gate_declared_is_not_an_error(self, tmp_path, monkeypatch)
tests/guard/test_guard_main.py:357
Checks
assert main(["validate", "--no-git", str(c_file)]) in (0, 1)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured |
Source · 10 lines
def test_no_gate_declared_is_not_an_error(self, tmp_path, monkeypatch):
c_file = self._project(tmp_path)
(tmp_path / ".clew.yaml").write_text(
guard_yaml("impact:\n requirements:\n file: reqs.yaml\n format: yaml\n")
)
monkeypatch.chdir(tmp_path)
# No version_gate declared: nothing to resolve, so no error from resolution.
assert main(["validate", "--no-git", str(c_file)]) in (0, 1)
Activity · 4 steps
test_precommit_fails_when_gate_unresolvable
test_guard_main.TestVersionGateFailsClosed.test_precommit_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys)
tests/guard/test_guard_main.py:342
Checks
assert result == 1assert "no version could be resolved" in capsys.readouterr().err
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | measured |
Source · 7 lines
def test_precommit_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys):
c_file = self._project(tmp_path)
monkeypatch.chdir(tmp_path)
result = main([str(c_file)])
assert result == 1
assert "no version could be resolved" in capsys.readouterr().err
Activity · 5 steps
test_precommit_with_impact
test_guard_main.TestPrecommitPipeline.test_precommit_with_impact(self, tmp_path, monkeypatch)
tests/guard/test_guard_main.py:184
Checks
assert result == 0assert {"unmapped", "unmapped_files"} <= set(doc)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-002 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-009 | measured | |
| REQ-DDB-GUARD-010 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-022 | measured | |
| REQ-DDB-GUARD-023 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-MCP-001 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 49 lines
def test_precommit_with_impact(self, tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
src = tmp_path / "src"
src.mkdir()
c_file = src / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Process data.
* @version 1.0
* @req REQ-001
*/
void Process(void) {
event_post(EVENT_DATA_READY);
}
/**
* @brief Handle data event.
* @version 1.0
* @req REQ-001
*/
void OnDataReady(void) {
consume();
}
""")
)
req_file = tmp_path / "reqs.csv"
req_file.write_text("Req ID,Name,Subsystem\nREQ-001,Data Processing,DataSvc\n")
config_file = tmp_path / ".clew.yaml"
## FIXTURE CHANGED (2.0.0, R5-CFG F7/F9): the catalog is the top-level `requirements:`
## and the report directory is `guard.impact.report_dir` (it was `output_dir/impact/`).
config_file.write_text(
dedent("""\
requirements:
file: reqs.csv
id_column: "Req ID"
name_column: "Name"
format: csv
""")
+ guard_yaml("impact:\n report_dir: out/impact/\n")
)
result = main(["--config", str(config_file), str(c_file)])
assert result == 0
## THE HOOK WRITES THE FULL REPORT (2.2; entropic, after clew#74): the hook's
## impact.json had no `unmapped`/`unmapped_files` (nor `tests`/`via`), which only the
## `impact` subcommand produced, so a consumer reading the hook's file saw less.
doc = json.loads((tmp_path / "out" / "impact" / "impact.json").read_text())
assert {"unmapped", "unmapped_files"} <= set(doc)
Activity · 13 steps
test_retired_subcommand_not_treated_as_file_path
test_guard_main.TestMain.test_retired_subcommand_not_treated_as_file_path(self, capsys)
A retired subcommand must not silently degrade to pre-commit mode and exit 0.
tests/guard/test_guard_main.py:170
Checks
assert result == 1assert "trace" in capsys.readouterr().err
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured |
Source · 6 lines
def test_retired_subcommand_not_treated_as_file_path(self, capsys):
"""A retired subcommand must not silently degrade to pre-commit mode and exit 0."""
result = main(["trace", "--all", "src/"])
assert result == 1
assert "trace" in capsys.readouterr().err
Activity · 3 steps
test_retired_trace_subcommand_fails_loudly
test_guard_main.TestMain.test_retired_trace_subcommand_fails_loudly(self, capsys)
tests/guard/test_guard_main.py:165
Checks
assert result == 1assert "was removed" in capsys.readouterr().err
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured |
Source · 5 lines
def test_retired_trace_subcommand_fails_loudly(self, capsys):
result = main(["trace", "--req", "REQ-NONEXISTENT-9999"])
assert result == 1
assert "was removed" in capsys.readouterr().err
Activity · 3 steps
test_unknown_extension_skipped
test_guard_main.TestValidateFile.test_unknown_extension_skipped(self, tmp_path)
tests/guard/test_guard_main.py:31
Checks
assert violations == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_unknown_extension_skipped → validate_file → get_file_at_revision → run_git → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_unknown_extension_skipped → validate_file → gate_exclusion |
| REQ-DDB-GUARD-001 | measured | test_unknown_extension_skipped → validate_file |
| REQ-DDB-GUARD-002 | inferred | test_unknown_extension_skipped → validate_file → check_version_staleness |
| REQ-DDB-GUARD-003 | inferred | test_unknown_extension_skipped → validate_file → check_tags |
| REQ-DDB-GUARD-004 | inferred | test_unknown_extension_skipped → validate_file → check_req_coverage |
| REQ-DDB-GUARD-005 | inferred | test_unknown_extension_skipped → validate_file → check_return_presence |
| REQ-DDB-GUARD-006 | inferred | test_unknown_extension_skipped → validate_file → check_file_presence |
| REQ-DDB-GUARD-007 | inferred | test_unknown_extension_skipped → validate_file → check_duplicate_tags |
| REQ-DDB-GUARD-008 | measured | |
| REQ-DDB-GUARD-009 | inferred | test_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version |
| REQ-DDB-GUARD-010 | measured | |
| REQ-DDB-GUARD-011 | inferred | test_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → load_requirements_full |
| REQ-DDB-GUARD-013 | measured | test_unknown_extension_skipped → validate_file → unconfigured_language |
| REQ-DDB-GUARD-014 | inferred | test_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_unknown_extension_skipped → validate_file → check_req_coverage → _has_active_requirements → filter_requirements_by_version → _summarise_id |
| REQ-DDB-GUARD-018 | measured | test_unknown_extension_skipped → validate_file → parse_source_file |
| REQ-DDB-GUARD-019 | inferred | test_unknown_extension_skipped → validate_file → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | inferred | test_unknown_extension_skipped → validate_file → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_unknown_extension_skipped → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-023 | measured | test_unknown_extension_skipped → validate_file → get_file_at_revision |
| REQ-DDB-GUARD-024 | inferred | test_unknown_extension_skipped → validate_file → check_file_presence → _check_file_block_tags → apply_autobrief |
| REQ-DDB-GUARD-025 | inferred | test_unknown_extension_skipped → validate_file → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-026 | inferred | test_unknown_extension_skipped → validate_file → check_bus_tags |
| REQ-DDB-GUARD-027 | inferred | test_unknown_extension_skipped → validate_file → check_req_exists → _uncheckable |
| REQ-DDB-PIPE-011 | measured | test_unknown_extension_skipped → validate_file → gate_exclusion → binary_file |
| REQ-DDB-WIKI-054 | inferred | test_unknown_extension_skipped → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 6 lines
def test_unknown_extension_skipped(self, tmp_path):
py_file = tmp_path / "script.rs"
py_file.write_text("fn foo() {}")
violations = validate_file(str(py_file), CONFIG_DEFAULTS, no_git=True)
assert violations == []
Activity · 4 steps
test_unsupported_extension_returns_none
test_guard_main.TestParseSourceFile.test_unsupported_extension_returns_none(self, tmp_path)
tests/guard/test_guard_main.py:293
Checks
assert result is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured | test_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config |
| REQ-DDB-GUARD-018 | measured | test_unsupported_extension_returns_none → parse_source_file |
| REQ-DDB-GUARD-019 | inferred | test_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | inferred | test_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-024 | inferred | test_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item |
| REQ-DDB-GUARD-025 | inferred | test_unsupported_extension_returns_none → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
Source · 7 lines
def test_unsupported_extension_returns_none(self, tmp_path):
rs_file = tmp_path / "lib.rs"
rs_file.write_text("fn main() {}")
result = parse_source_file(str(rs_file), CONFIG_DEFAULTS)
assert result is None
Activity · 4 steps
test_validate_clean_file
test_guard_main.TestMain.test_validate_clean_file(self, tmp_path)
tests/guard/test_guard_main.py:83
Checks
assert result == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 16 lines
def test_validate_clean_file(self, tmp_path):
c_file = tmp_path / "clean.c"
c_file.write_text(
dedent("""\
/**
* @brief Clean function.
* @version 1.0
*/
void Clean_Func(void) {
do_stuff();
}
""")
)
result = main(["--config", NO_REQ_CONFIG, "validate", "--no-git", str(c_file)])
assert result == 0
Activity · 4 steps
test_validate_dirty_file
test_guard_main.TestMain.test_validate_dirty_file(self, tmp_path)
tests/guard/test_guard_main.py:99
Checks
assert result == 1
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 12 lines
def test_validate_dirty_file(self, tmp_path):
c_file = tmp_path / "dirty.c"
c_file.write_text(
dedent("""\
void Undoc_Func(void) {
do_stuff();
}
""")
)
result = main(["validate", "--no-git", str(c_file)])
assert result == 1
Activity · 4 steps
test_validate_fails_when_gate_unresolvable
test_guard_main.TestVersionGateFailsClosed.test_validate_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys)
tests/guard/test_guard_main.py:335
Checks
assert result == 1assert "no version could be resolved" in capsys.readouterr().err
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | measured |
Source · 7 lines
def test_validate_fails_when_gate_unresolvable(self, tmp_path, monkeypatch, capsys):
c_file = self._project(tmp_path)
monkeypatch.chdir(tmp_path)
result = main(["validate", "--no-git", str(c_file)])
assert result == 1
assert "no version could be resolved" in capsys.readouterr().err
Activity · 5 steps
test_validate_nonexistent_file
test_guard_main.TestMain.test_validate_nonexistent_file(self)
tests/guard/test_guard_main.py:111
Checks
assert result == 0 # Warning logged, no violations
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 4 lines
def test_validate_nonexistent_file(self):
result = main(["validate", "--no-git", "/nonexistent/path.c"])
assert result == 0 # Warning logged, no violations
Activity · 2 steps
test_verbose_flag
test_guard_main.TestMain.test_verbose_flag(self, tmp_path)
tests/guard/test_guard_main.py:132
Checks
assert result == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-003 | measured | |
| REQ-DDB-GUARD-004 | measured | |
| REQ-DDB-GUARD-005 | measured | |
| REQ-DDB-GUARD-006 | measured | |
| REQ-DDB-GUARD-007 | measured | |
| REQ-DDB-GUARD-011 | measured | |
| REQ-DDB-GUARD-012 | measured | |
| REQ-DDB-GUARD-013 | measured | |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-018 | measured | |
| REQ-DDB-GUARD-019 | measured | |
| REQ-DDB-GUARD-020 | measured | |
| REQ-DDB-GUARD-024 | measured | |
| REQ-DDB-GUARD-025 | measured | |
| REQ-DDB-GUARD-026 | measured | |
| REQ-DDB-GUARD-027 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 16 lines
def test_verbose_flag(self, tmp_path):
c_file = tmp_path / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Func.
* @version 1.0
*/
void Func(void) {
x();
}
""")
)
result = main(["--config", NO_REQ_CONFIG, "-v", "validate", "--no-git", str(c_file)])
assert result == 0