test_guard_exclude_counted.py

tests/guard/test_guard_exclude_counted.py

A file `guard.validate.exclude` leaves out is counted in the gate's skip report (PG6; 2.0.0).

test_an_excluded_file_is_counted_as_not_checked

None test_guard_exclude_counted.test_an_excluded_file_is_counted_as_not_checked(Path tmp_path, pytest.MonkeyPatch monkeypatch, pytest.CaptureFixture capsys)

One file excluded by a declared glob: the stderr report counts it, naming the reason.

tests/guard/test_guard_exclude_counted.py:25

Show on the map →

Called by none

Calls none

Checks

  • assert main(["validate", "--no-git", "gen/a.c", "b.c"]) == 0
  • assert "1 file(s) not checked" in err and "validate.exclude" in err, err

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-003measured
REQ-DDB-GUARD-004measured
REQ-DDB-GUARD-005measured
REQ-DDB-GUARD-006measured
REQ-DDB-GUARD-011measured
REQ-DDB-GUARD-012measured
REQ-DDB-GUARD-013measured
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-020measured
REQ-DDB-GUARD-024measured
REQ-DDB-GUARD-026measured
REQ-DDB-GUARD-027measured
REQ-DDB-PIPE-011measured
REQ-DDB-SCHEMA-015measured
Source · 12 lines
def test_an_excluded_file_is_counted_as_not_checked(
    tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture
) -> None:
    """@brief One file excluded by a declared glob: the stderr report counts it, naming the reason."""
    (tmp_path / "gen").mkdir()
    (tmp_path / "gen/a.c").write_text(_BLOCK.format(name="a.c"))
    (tmp_path / "b.c").write_text(_BLOCK.format(name="b.c"))
    (tmp_path / ".clew.yaml").write_text('guard:\n  validate:\n    exclude: ["gen/**"]\n')
    monkeypatch.chdir(tmp_path)
    assert main(["validate", "--no-git", "gen/a.c", "b.c"]) == 0
    err = capsys.readouterr().err
    assert "1 file(s) not checked" in err and "validate.exclude" in err, err

1 more lines, not shown

Activity · 8 steps
lines 29–29(tmp_path / "gen").mkdir()lines 30–30(tmp_path / "gen/a.c").write_text(_BLOCK.format(name="a.c"))lines 31–31(tmp_path / "b.c").write_text(_BLOCK.format(name="b.c"))lines 32–32(tmp_path / ".clew.yaml").write_text('guard:\n validate:\n exclude: ["gen/**"]\n')lines 33–33monkeypatch.chdir(tmp_path)lines 34–34assert main(["validate", "--no-git", "gen/a.c", "b.c"]) == 0lines 35–35err = capsys.readouterr().errlines 36–36assert "1 file(s) not checked" in err and "validate.exclude" in err, err