test_doxyfile_refusal_messages.py¶
tests/test_doxyfile_refusal_messages.py
Tests for gh#4 — the no-Doxyfile message misdescribes a supported path.
test_a_missing_explicit_doxyfile_does_not_propose_passing_one
None test_doxyfile_refusal_messages.test_a_missing_explicit_doxyfile_does_not_propose_passing_one(Path tmp_path)
The explicitly-passed-but-absent case never proposes doxyfile again.
tests/test_doxyfile_refusal_messages.py:62
Checks
assert outcome.kind == DOXYFILE_EXPLICIT_MISSINGassert str(missing) in outcome.message, "the message must name the path that was tried"assert "--repo-root" in outcome.message, "it must name the flag that changes the outcome"assert "pass --doxyfile" not in outcome.message.lower(), ("it must not propose the flag the user just used" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_a_missing_explicit_doxyfile_does_not_propose_passing_one → describe_doxyfile_resolution |
Source · 16 lines
def test_a_missing_explicit_doxyfile_does_not_propose_passing_one(tmp_path: Path) -> None:
"""The literal gh#4 complaint. The user passed --doxyfile; the path is not on
disk; the old text answered "Pass --doxyfile". "Never proposes an action
already taken" is the property, so this asserts the ABSENCE of that advice as
well as the presence of the path that was actually tried."""
missing = tmp_path / "nope" / "Doxyfile"
outcome = describe_doxyfile_resolution(explicit=missing, repo_root=None, candidates=[])
assert outcome.kind == DOXYFILE_EXPLICIT_MISSING
assert str(missing) in outcome.message, "the message must name the path that was tried"
assert "--repo-root" in outcome.message, "it must name the flag that changes the outcome"
assert "pass --doxyfile" not in outcome.message.lower(), (
"it must not propose the flag the user just used"
)
Activity · 6 steps
test_a_rejected_candidate_says_where_and_why
None test_doxyfile_refusal_messages.test_a_rejected_candidate_says_where_and_why(Path tmp_path)
A rejected candidate says where it was found and why it was not used.
tests/test_doxyfile_refusal_messages.py:110
Checks
assert outcome.kind == DOXYFILE_REJECTEDassert not outcome.is_error, "refusing to guess still proceeds via synthesis"assert "sample/Doxyfile" in outcome.message, "it must say WHERE the candidate was found"assert "--doxyfile" in outcome.message, "it must name the flag that selects one"assert "guess" in lowered or "wrong" in lowered, "it must say WHY it was not adopted"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_a_rejected_candidate_says_where_and_why → describe_doxyfile_resolution |
Source · 22 lines
def test_a_rejected_candidate_says_where_and_why(tmp_path: Path) -> None:
"""`discover_doxyfile` refuses to guess among strays rather than picking
alphabetically, because it was once caught selecting a test FIXTURE's Doxyfile
to index a whole project. The message must carry that reasoning — a bare "not
used" invites the reader to conclude the tool failed to find what it plainly
did find."""
repo = tmp_path / "repo"
(repo / "sample").mkdir(parents=True)
stray = repo / "sample" / "Doxyfile"
stray.write_text("PROJECT_NAME = fixture\n")
candidates = [stray]
outcome = describe_doxyfile_resolution(explicit=None, repo_root=repo, candidates=candidates)
assert outcome.kind == DOXYFILE_REJECTED
assert not outcome.is_error, "refusing to guess still proceeds via synthesis"
assert "sample/Doxyfile" in outcome.message, "it must say WHERE the candidate was found"
lowered = outcome.message.lower()
assert "--doxyfile" in outcome.message, "it must name the flag that selects one"
assert "guess" in lowered or "wrong" in lowered, "it must say WHY it was not adopted"
Activity · 12 steps
test_candidates_are_reported_without_being_adopted
None test_doxyfile_refusal_messages.test_candidates_are_reported_without_being_adopted(Path tmp_path)
Candidate enumeration is exposed so the message can name what was found.
tests/test_doxyfile_refusal_messages.py:175
Checks
assert discover_doxyfile(repo) is None, "a stray must still not be adopted"assert [p.relative_to(repo).as_posix() for p in candidates] == ["sample/Doxyfile"]assert discover_doxyfile(repo) == repo / "docs" / "Doxyfile"assert repo / "docs" / "Doxyfile" not in rejected_doxyfile_candidates(repo)assert rejected_doxyfile_candidates(bare) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_candidates_are_reported_without_being_adopted → discover_doxyfile |
Source · 29 lines
def test_candidates_are_reported_without_being_adopted(tmp_path: Path) -> None:
"""`discover_doxyfile` still returns None for a stray — the refusal behaviour is
unchanged — while the candidates it declined are separately readable, which is
what lets the message say where they were. Both halves asserted together,
because a change that started ADOPTING strays would fix the message and
reintroduce the fixture-indexing defect."""
from clew.doxygen import rejected_doxyfile_candidates
repo = tmp_path / "repo"
(repo / "sample").mkdir(parents=True)
(repo / "sample" / "Doxyfile").write_text("x\n")
assert discover_doxyfile(repo) is None, "a stray must still not be adopted"
candidates = rejected_doxyfile_candidates(repo)
assert [p.relative_to(repo).as_posix() for p in candidates] == ["sample/Doxyfile"]
# A TRUSTED location is never reported as a rejected candidate — otherwise the
# message would name the very file it went on to adopt.
(repo / "docs").mkdir()
(repo / "docs" / "Doxyfile").write_text("x\n")
assert discover_doxyfile(repo) == repo / "docs" / "Doxyfile"
assert repo / "docs" / "Doxyfile" not in rejected_doxyfile_candidates(repo)
# A repo with no strays at all has nothing to report.
bare = tmp_path / "bare"
bare.mkdir()
assert rejected_doxyfile_candidates(bare) == []
Activity · 14 steps
test_no_doxyfile_anywhere_is_described_as_supported
None test_doxyfile_refusal_messages.test_no_doxyfile_anywhere_is_described_as_supported(Path tmp_path)
A repo with no Doxyfile is described as supported, not as an error.
tests/test_doxyfile_refusal_messages.py:94
Checks
assert outcome.kind == DOXYFILE_ABSENTassert not outcome.is_error, "a repo with no Doxyfile is a supported configuration"assert "synthesi" in outcome.message.lower(), "it must say synthesis is what happens next"assert str(repo) in outcome.message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_no_doxyfile_anywhere_is_described_as_supported → describe_doxyfile_resolution |
Source · 14 lines
def test_no_doxyfile_anywhere_is_described_as_supported(tmp_path: Path) -> None:
"""The bullet the issue leads with. A repo that ships none gets synthesis, and
the message must SAY that rather than reading as a refusal — this is the
sentence a reader meets on the route the tool handles well."""
repo = tmp_path / "repo"
repo.mkdir()
outcome = describe_doxyfile_resolution(explicit=None, repo_root=repo, candidates=[])
assert outcome.kind == DOXYFILE_ABSENT
assert not outcome.is_error, "a repo with no Doxyfile is a supported configuration"
assert "synthesi" in outcome.message.lower(), "it must say synthesis is what happens next"
assert str(repo) in outcome.message
Activity · 7 steps
test_only_the_unresolvable_situations_are_errors
None test_doxyfile_refusal_messages.test_only_the_unresolvable_situations_are_errors(Path tmp_path)
Only the two no-target situations are errors.
tests/test_doxyfile_refusal_messages.py:160
Checks
assert describe_doxyfile_resolution(None, None, []).is_errorassert describe_doxyfile_resolution(tmp_path / "n" / "Doxyfile", None, []).is_errorassert not describe_doxyfile_resolution(None, repo, []).is_errorassert not describe_doxyfile_resolution(None, repo, [repo / "s" / "Doxyfile"]).is_error
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_only_the_unresolvable_situations_are_errors → describe_doxyfile_resolution |
Source · 13 lines
def test_only_the_unresolvable_situations_are_errors(tmp_path: Path) -> None:
"""The is_error split is the behavioural claim in a message-only change: the
two synthesis routes must stay non-errors, or a supported path becomes a
refusal — which is the regression this change could most easily introduce."""
repo = tmp_path / "repo"
repo.mkdir()
assert describe_doxyfile_resolution(None, None, []).is_error
assert describe_doxyfile_resolution(tmp_path / "n" / "Doxyfile", None, []).is_error
assert not describe_doxyfile_resolution(None, repo, []).is_error
assert not describe_doxyfile_resolution(None, repo, [repo / "s" / "Doxyfile"]).is_error
Activity · 6 steps
test_the_cli_refusal_uses_the_new_message
None test_doxyfile_refusal_messages.test_the_cli_refusal_uses_the_new_message(Path tmp_path, caplog)
The CLI still refuses, and now with the discriminating message.
tests/test_doxyfile_refusal_messages.py:206
Checks
assert excinfo.value.code == 1assert str(missing.resolve()) in caplog.textassert "pass --doxyfile" not in caplog.text.lower()
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → report_stats |
| REQ-DDB-CLI-002 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → _doxygen_or_partial → _doxygen_stage → _run_doxygen_from_args → run_doxygen → doxygen_supports_sqlite3 |
| REQ-DDB-CONFIG-001 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _apply_declared_document → stated_document_meta |
| REQ-DDB-CONFIG-003 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-CONFIG-004 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_preprocessor |
| REQ-DDB-CONFIG-005 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig |
| REQ-DDB-CONFIG-006 | measured | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _recorded_entry_patterns → recorded_explicit |
| REQ-DDB-CONFIG-007 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature |
| REQ-DDB-CONFIG-009 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _apply_toolchain_exclusions → load_toolchain_config |
| REQ-DDB-GUARD-012 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → load_guard_config → read_guard_config → read_requirements_section |
| REQ-DDB-GUARD-019 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → apply_autobrief |
| REQ-DDB-INDEX-001 | measured | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _verify_extra_input_is_read → effective_file_patterns |
| REQ-DDB-INDEX-002 | measured | test_the_cli_refusal_uses_the_new_message → _run_pipeline → build_lock |
| REQ-DDB-INDEX-003 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → report_index_coverage |
| REQ-DDB-INDEX-004 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols |
| REQ-DDB-INDEX-005 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → stamp_external_provenance |
| REQ-DDB-INDEX-006 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → record_code_text → code_text_rows |
| REQ-DDB-INDEX-007 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → record_owners |
| REQ-DDB-INDEX-008 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_licenses |
| REQ-DDB-INDEX-009 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc |
| REQ-DDB-INDEX-010 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes |
| REQ-DDB-INDEX-011 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_property_keys |
| REQ-DDB-MCP-001 | measured | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _operator_excludes → meta_section |
| REQ-DDB-MCP-004 | measured | |
| REQ-DDB-PIPE-001 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_database |
| REQ-DDB-PIPE-003 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → build_call_edges |
| REQ-DDB-PIPE-004 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → python_entry_seeds |
| REQ-DDB-PIPE-005 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature |
| REQ-DDB-PIPE-006 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → run_rustdoc → _require_nightly_rustdoc → clean_subprocess_env |
| REQ-DDB-PIPE-007 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig_gates |
| REQ-DDB-PIPE-008 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs |
| REQ-DDB-PIPE-009 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → prune_dominated_fuzzy_call_edges |
| REQ-DDB-PIPE-010 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _build_inferred_edges |
| REQ-DDB-PIPE-011 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → build_harvest_plan → js_symbol_harvester |
| REQ-DDB-PIPE-013 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings |
| REQ-DDB-PIPE-014 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc → within_repo |
| REQ-DDB-PIPE-015 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_config_defaults |
| REQ-DDB-QUERY-003 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → mark_test_scope |
| REQ-DDB-QUERY-011 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads → _ensure_threads_tables |
| REQ-DDB-SCHEMA-001 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads |
| REQ-DDB-SCHEMA-002 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _writer_dispatch_map |
| REQ-DDB-SCHEMA-003 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table |
| REQ-DDB-SCHEMA-004 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest |
| REQ-DDB-SCHEMA-005 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_key_alias_prefixes |
| REQ-DDB-SCHEMA-006 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-007 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table |
| REQ-DDB-SCHEMA-009 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_event_edges |
| REQ-DDB-SCHEMA-011 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → extract_context_conflicts |
| REQ-DDB-SCHEMA-012 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest → declaration_origin |
| REQ-DDB-SCHEMA-013 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → import_data_model_keys |
| REQ-DDB-SCHEMA-014 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs → ensure_file_docs_table |
| REQ-DDB-SCHEMA-015 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_the_cli_refusal_uses_the_new_message → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols → _recover_into → all |
Source · 13 lines
def test_the_cli_refusal_uses_the_new_message(tmp_path: Path, caplog) -> None:
"""End-to-end at the real refusal site, because a classifier that is correct in
isolation and unwired changes nothing a user sees. Only the no-repo-root
branches reach sys.exit; the synthesis branches are covered by the integration
build tests."""
missing = tmp_path / "nope" / "Doxyfile"
args = _args(doxyfile=str(missing), output=str(tmp_path / "clew.db"))
with caplog.at_level("ERROR"), pytest.raises(SystemExit) as excinfo:
cli._run_pipeline(args)
assert excinfo.value.code == 1
assert str(missing.resolve()) in caplog.text
assert "pass --doxyfile" not in caplog.text.lower()1 more lines, not shown
Activity · 7 steps
test_the_four_situations_produce_four_distinct_sentences
None test_doxyfile_refusal_messages.test_the_four_situations_produce_four_distinct_sentences(Path tmp_path)
The four sentences are mutually distinct.
tests/test_doxyfile_refusal_messages.py:134
Checks
assert len(set(kinds)) == 4, f"situations must be distinguishable, got {kinds}"assert len(set(messages)) == 4, "each situation needs its own sentence"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_the_four_situations_produce_four_distinct_sentences → describe_doxyfile_resolution |
Source · 24 lines
def test_the_four_situations_produce_four_distinct_sentences(tmp_path: Path) -> None:
"""The point of the change is DISCRIMINATION, so this is the assertion that
actually pins it. Four messages that all improved but two of which still read
alike would leave the reader exactly where they started."""
repo = tmp_path / "repo"
(repo / "sample").mkdir(parents=True)
(repo / "sample" / "Doxyfile").write_text("x\n")
outcomes = [
describe_doxyfile_resolution(
explicit=tmp_path / "n" / "Doxyfile", repo_root=None, candidates=[]
),
describe_doxyfile_resolution(explicit=None, repo_root=None, candidates=[]),
describe_doxyfile_resolution(explicit=None, repo_root=repo, candidates=[]),
describe_doxyfile_resolution(
explicit=None, repo_root=repo, candidates=[repo / "sample" / "Doxyfile"]
),
]
kinds = [o.kind for o in outcomes]
assert len(set(kinds)) == 4, f"situations must be distinguishable, got {kinds}"
messages = [o.message for o in outcomes]
assert len(set(messages)) == 4, "each situation needs its own sentence"
Activity · 8 steps
test_with_no_target_at_all_the_message_names_synthesis
None test_doxyfile_refusal_messages.test_with_no_target_at_all_the_message_names_synthesis(Path tmp_path)
With neither flag, nothing was searched — say so, and name synthesis.
tests/test_doxyfile_refusal_messages.py:80
Checks
assert outcome.kind == DOXYFILE_NO_TARGETassert "--repo-root" in outcome.messageassert "None" not in outcome.message, "no message should render a missing path as 'None'"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_with_no_target_at_all_the_message_names_synthesis → describe_doxyfile_resolution |
Source · 12 lines
def test_with_no_target_at_all_the_message_names_synthesis(tmp_path: Path) -> None:
"""No --doxyfile and no --repo-root: no directory was ever searched, so
"Doxyfile not found" is not even true. The old text rendered the path as the
literal string "None". The reader needs to know a repo root is what is missing,
and that a repo with no Doxyfile is nonetheless indexable."""
outcome = describe_doxyfile_resolution(explicit=None, repo_root=None, candidates=[])
assert outcome.kind == DOXYFILE_NO_TARGET
assert "--repo-root" in outcome.message
assert "None" not in outcome.message, "no message should render a missing path as 'None'"