test_existing_declaration_is_not_overwritten_without_force

Tests › tests/test_propose.py

passed Passed in the packaged run.

What this test is for

Why it exists

The one file this command is about is the one file it must not clobber: replacing a hand-tuned declaration with an all-comments draft DISABLES every convention it declared while the build keeps succeeding — a silently different answer, which is worse than a crash.

Given

  1. root, db = _acme(tmp_path)
  2. declaration = root / DECLARATION_NAME
3 more
  1. original = "shared_key_patterns:\n writers:\n - name_prefix: 'HAND_SET_'\n"
  2. declaration.write_text(original, encoding="utf-8")
  3. argv = ["--repo-root", str(root), "--db", str(db), "-o", str(declaration)]
→

When

  1. propose_main(argv)
  2. propose_main([*argv, "--force"])
  3. load_declaration(root)
→

Then

  1. ✓ propose_main(argv) equals 2
  2. ✓ declaration.read_text(encoding="utf-8") equals original
  3. ✓ propose_main([*argv, "--force"]) equals 0
  4. ✓ declaration.read_text(encoding="utf-8") differs from original
  5. ✓ load_declaration(root) equals {}

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

clew — `main` (clew/cli.py) · 119 of 400 steps

command-line usercommand-line usercommand-line usercommand-line userclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyother filesother filesother filesother filesopt (line 3996)optalt (line 1171)altopt (line 529)optmain1. main → propose_main1propose_main2. propose_main → build_parser2build_parser▶ test enters3–11. propose_main → _configure_logging3_configure_logging +8 more12. build_context → derive_scope12derive_scope13. derive_scope → _declared_index_scope13_declared_index_scope14. _declared_index_scope → load_declaration_located14load_declaration_located15–18. load_declaration_located → _read_mapping15_read_mapping +3 more19–20. _checked_section → _checked_list_section19_checked_list_section +1 more

… 14 steps between

command-line usercommand-line usercommand-line usercommand-line userclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyother filesother filesother filesother filesloop (line 569)loopopt (line 571)optopt (line 547)opttry (line 548)trymain35. _checked_tests → _checked_list_section35_checked_list_section36. _checked_tests → 36… 1 call not run37–40. _checked_section → check_manifest_document37check_manifest_document +3 more41. _checked_section → _check_section_keys41_check_section_keys42. _declared_index_scope → _existing_paths42_existing_paths

… 1 step between

command-line usercommand-line usercommand-line usercommand-line usercommand-line usercommand-line userclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/propose/astdefs.pyclew/propose/astdefs.pyclew/propose/astdefs.pyclew/propose/astdefs.pyclew/propose/astdefs.pyclew/propose/astdefs.pyother filesother filesother filesother filesother filesother filesopt (line 696)opttry (line 1003)tryopt (line 847)optloop (line 746)looploop (line 1055)loopopt (line 1075)optopt (line 385)optloop (line 239)looploop (line 268)loopopt (line 270)optelif (line 274)elifloop (line 369)loopopt (line 4002)optmain44. _declared_index_scope → _existing_paths44_existing_paths45. derive_scope → whole_repo_scope45whole_repo_scope46. whole_repo_scope → _gitignored_paths46_gitignored_paths47. _gitignored_paths → git_argv47git_argv48–49. git_argv → _no_ext_diff48_no_ext_diff +1 more50. _gitignored_paths → git_env50git_env51. whole_repo_scope → list51list52–56. whole_repo_scope → nested_repo_roots52nested_repo_roots +4 more57. nested_repo_roots → _nested_repos_under57_nested_repos_under58. whole_repo_scope → _gitignored_paths58_gitignored_paths59–60. whole_repo_scope → _pruned_dirs59_pruned_dirs +1 more61. _pruned_dirs → _skip_dir61_skip_dir62–64. _pruned_dirs → _descendable62_descendable +2 more65–68. whole_repo_scope → _declaration_note65_declaration_note +3 more69. derive_scope → whole_repo_scope69whole_repo_scope70–73. build_context → repo_source_files70repo_source_files +3 more74–75. _grammar_available → has_language74has_language +1 more76. _ts_language_for → _try_import_ts_module76_try_import_ts_module77–85. build_context → scope_membership77scope_membership +8 more86–88. _ast_parse_one_file → _disambiguate_header86_disambiguate_header +2 more89. scan_repo → _absorb_file89_absorb_file90. _absorb_file → definition_record90definition_record91–109. definition_record → _signature91_signature +18 more110. _absorb_file → _accessor_site110_accessor_site111. _accessor_site → callee_name111callee_name112–113. build_context → load_declaration112load_declaration +1 more114–117. propose → _sections114_sections +3 more118. _blocking → is_derived118is_derived119–127. _sections → _blocked_section119_blocked_section +8 more128. candidate_dirs → 128… 1 call not run129–130. report_not_indexed → _dir_lines129_dir_lines +1 more131. propose → scope_summary131scope_summary132. scope_summary → is_derived132is_derived133. scope_summary → ast_readable_in_scope133ast_readable_in_scope134–147. propose → render_declaration134render_declaration +13 more148. _rejections → _wrap148_wrap149–150. _section_block → _notes149_notes +1 more151. propose_main → _resolve_db151_resolve_db▶ test enters152. _resolve_db → find_index152find_index153. find_index → registered_index153registered_index154. propose_main → _emit154_emit155–156. main → export_main155export_main +1 more

… 244 later steps

4 more

tests/test_propose.py:654 · its file's page

What it checks (5)

  1. assert propose_main(argv) == 2 observes propose_main
  2. assert declaration.read_text(encoding="utf-8") == original, "the declaration was clobbered" not attributed
  3. assert propose_main([*argv, "--force"]) == 0 observes propose_main
  4. assert declaration.read_text(encoding="utf-8") != original not attributed
  5. assert load_declaration(root) == {}, "the written draft must be inert" observes load_declaration

Where the product reaches it

  • main → propose_main → propose → build_context → load_declaration (flow)
  • main → propose_main (flow)

Call flow

test_existing_declaration_is_not_overwritten_without_force→_acme→propose_main→load_declaration

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_existing_declaration_is_not_overwritten_without_force · 5 checksload_declarationREQ-DDB-CONFIG-001 · measured_acme_indexwrite_build_signatureREQ-DDB-CONFIG-006 · measured_acme_indexwrite_build_signatureREQ-DDB-CONFIG-007 · measuredpropose_main_resolve_dbfind_indexREQ-DDB-GUARD-010 · measuredload_declaration… 4 calls …_validate_nodeREQ-DDB-GUARD-012 · inferred_acme_indexwrite_build_signatureREQ-DDB-PIPE-005 · measuredpropose_main… 4 calls …_parseable_fileREQ-DDB-PIPE-011 · measuredpropose_main… 5 calls …has_languageREQ-DDB-PIPE-012 · inferredload_declaration… 4 calls …allREQ-DDB-WIKI-054 · inferred
Also reaches 9 requirements

Its run touches their code; that is reach, not proof.