test_precommit_with_impact

Tests › tests/guard/test_guard_main.py

passed Passed in the packaged run.

What this test is for

Why it exists

The test says nothing about why.

Given

  1. monkeypatch.chdir(tmp_path)
  2. src = tmp_path / "src"
9 more
  1. src.mkdir()
  2. c_file = src / "test.c"
  3. 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(); } """) )
  4. req_file = tmp_path / "reqs.csv"
  5. req_file.write_text("Req ID,Name,Subsystem\nREQ-001,Data Processing,DataSvc\n")
  6. config_file = tmp_path / ".clew.yaml"
  7. 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") )
  8. result = main(["--config", str(config_file), str(c_file)])
  9. doc = json.loads((tmp_path / "out" / "impact" / "impact.json").read_text())
→

When

  1. —
→

Then

  1. ✓ result equals 0
  2. ✓ {"unmapped", "unmapped_files"} is at most set(doc)

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.

`main` (clew/guard/main.py) · 194 of 357 steps

program launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pytry (line 717)tryopt (line 730)optmain1. main → _check_retired_subcommand1_check_retired_subcommand▶ test enters2. _check_retired_subcommand → _first_positional2_first_positional3–5. main → _run3_run +2 more6–7. _run → build_parser6build_parser +1 more

… 5 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesother filesother filesother filesopt (line 733)optopt (line 705)optopt (line 445)optloop (line 417)loopopt (line 420)optalt (line 421)altopt (line 715)optloop (line 793)loopopt (line 795)optloop (line 651)loopopt (line 653)optloop (line 391)looploop (line 267)looptry (line 269)tryopt (line 1336)optalt (line 1344)altloop (line 973)looploop (line 974)looploop (line 287)looploop (line 288)looptry (line 345)tryloop (line 326)looploop (line 69)loopopt (line 178)optmain13–14. build_parser → _add_files_parser13_add_files_parser +1 more15–17. _run → _has_subcommand15_has_subcommand +2 more18. _run → load_config18load_config19. load_config → refuse_doxygen_guard_leftovers19refuse_doxygen_guard_leftovers20. load_config → _fresh_defaults20_fresh_defaults21–22. load_config → read_requirements_section21read_requirements_section +1 more23–25. _validate_node → _validate_map_of23_validate_map_of +2 more26–27. _validate_node → _validate_dict_node26_validate_dict_node +1 more28. _validate_dict_node → _suggest_key28_suggest_key29. _suggest_key → list29list30. _validate_dict_node → _validate_node30_validate_node31. load_config → _shared_facts31_shared_facts32. _shared_facts → list32list33. load_config → read_guard_section33read_guard_section34. load_config → _fresh_defaults34_fresh_defaults35–43. load_config → validate_config_schema35validate_config_schema +8 more44. apply_opt_in_languages → deep_merge44deep_merge45. deep_merge → deep_merge45deep_merge46. load_config → deep_merge46deep_merge47. _run → run_precommit47run_precommit48. run_precommit → report_dir48report_dir49. run_precommit → resolve_version_gate49resolve_version_gate50. resolve_version_gate → get_validate50get_validate51. resolve_version_gate → _detect_current_version51_detect_current_version52. _detect_current_version → get_validate52get_validate53–54. run_precommit → _report_violations53_report_violations +1 more55. _validate_files → load_requirements_full55load_requirements_full56. load_requirements_full → _get_requirements_config56_get_requirements_config57. _get_requirements_config → get_requirements57get_requirements58. _get_requirements_config → resolve_contained_path58resolve_contained_path59. load_requirements_full → _validate_requirements59_validate_requirements60. _validate_requirements → get_validate60get_validate61. _validate_requirements → _summarise_id61_summarise_id62. _validate_files → load_external_requirements62load_external_requirements63. load_external_requirements → get_requirements63get_requirements64. load_external_requirements → read_catalog_at64read_catalog_at65–67. read_catalog_at → _refuse_url65_refuse_url +2 more68–69. git_argv → _no_ext_diff68_no_ext_diff +1 more70–71. read_catalog_at → _refuse_url70_refuse_url +1 more72. _validate_files → get_requirements72get_requirements73. _validate_files → check_satisfies73check_satisfies74. check_satisfies → link_ids74link_ids75. link_ids → satisfies_ids75satisfies_ids76. _validate_files → load_failure_mode_ids76load_failure_mode_ids77. load_failure_mode_ids → _get_requirements_config77_get_requirements_config78. load_failure_mode_ids → _raw_entries78_raw_entries79. load_failure_mode_ids → modes_of79modes_of80. _validate_files → validate_file80validate_file81. validate_file → get_validate81get_validate82. validate_file → excluded_by82excluded_by83–84. excluded_by → compile_globs83compile_globs +1 more85. validate_file → gate_exclusion85gate_exclusion86–87. gate_exclusion → _gate_matcher86_gate_matcher +1 more88–89. load_toolchain_config → _read_toml88_read_toml +1 more

… 8 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyother filesother filesother filesother filesother filesopt (line 184)optloop (line 186)loopopt (line 189)optopt (line 98)optopt (line 168)optloop (line 647)loopopt (line 786)optopt (line 652)optmain98–99. load_toolchain_config → _entry_globs98_entry_globs +1 more100. _gate_matcher → compile_globs100compile_globs101. gate_exclusion → matches101matches102. gate_exclusion → binary_file102binary_file103. validate_file → parse_source_file103parse_source_file104–109. parse_source_file → parse_source_file_with_content104parse_source_file_with_content +5 more110. parse_content_for_file → language_for_file110language_for_file111–112. language_for_file → language_for_extension111language_for_extension +1 more113. language_for_file → _language_from_config113_language_from_config114. parse_content_for_file → parse_functions114parse_functions115. parse_functions → parse_functions_ts115parse_functions_ts116. parse_functions_ts → get_parser_for_language116get_parser_for_language117. parse_functions_ts → get_language_spec117get_language_spec118–119. parse_functions_ts → _collect_functions118_collect_functions +1 more120. _is_rust_test_item → _rust_attributes120_rust_attributes121. _collect_functions → _enclosing_class_for121_enclosing_class_for122. _enclosing_class_for → _rust_impl_self_type122_rust_impl_self_type123. _collect_functions → _declared_function123_declared_function124–125. _collect_functions → _append_declaration124_append_declaration +1 more

… 1 step between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyother filesother filesother filesother filesother filesloop (line 647)loopopt (line 377)optalt (line 380)altopt (line 383)optopt (line 384)optopt (line 400)optopt (line 658)optopt (line 681)optopt (line 683)optalt (line 684)altopt (line 227)opttry (line 241)trymain127–128. _append_declaration → _qualified_enclosing127_qualified_enclosing +1 more129–137. _collect_functions → _resolve_function_node129_resolve_function_node +8 more138–140. _find_preceding_doxygen → _collect_rust_doc138_collect_rust_doc +2 more141. _find_preceding_doxygen → _collect_c_comment141_collect_c_comment142. _find_preceding_doxygen → _find_python_docstring_block142_find_python_docstring_block143. _find_preceding_doxygen → parse_doxygen_tags143parse_doxygen_tags144. _find_preceding_doxygen → apply_autobrief144apply_autobrief145. _find_preceding_doxygen → _last_row145_last_row146–149. _collect_functions → _qualified_enclosing146_qualified_enclosing +3 more150. _js_returns_void → _function_carrier150_function_carrier151. _collect_functions → _produced_class151_produced_class152. _produced_class → _function_carrier152_function_carrier153. _collect_functions → _collect_functions153_collect_functions154. _collect_functions → _collect_functions154_collect_functions155. validate_file → unconfigured_language155unconfigured_language156. validate_file → check_file_presence156check_file_presence157. check_file_presence → get_validate157get_validate158–159. check_file_presence → _find_file_doxygen_start158_find_file_doxygen_start +1 more

… 3 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesother filesopt (line 1198)optloop (line 143)loopopt (line 1171)optloop (line 181)looploop (line 118)loopopt (line 120)optopt (line 247)optloop (line 631)looploop (line 635)looploop (line 638)loopmain163. _extract_file_block_text → _docstring_block163_docstring_block164. _check_file_block_tags → parse_doxygen_tags164parse_doxygen_tags165–170. parse_doxygen_tags → _mask_escaped_at165_mask_escaped_at +5 more171. _check_file_block_tags → apply_autobrief171apply_autobrief172–174. apply_autobrief → _mask_escaped_at172_mask_escaped_at +2 more175. validate_file → check_presence175check_presence176. check_presence → get_validate176get_validate177–180. check_presence → _is_void_function177_is_void_function +3 more181. validate_file → check_return_presence181check_return_presence182. check_return_presence → get_validate182get_validate183–184. check_return_presence → _require_return183_require_return +1 more185. validate_file → check_tags185check_tags186. check_tags → get_validate186get_validate187. check_tags → _validate_tag_value187_validate_tag_value188. validate_file → check_req_coverage188check_req_coverage189. check_req_coverage → get_requirements189get_requirements190. check_req_coverage → _has_active_requirements190_has_active_requirements191. _has_active_requirements → load_requirements_full191load_requirements_full192. _has_active_requirements → filter_requirements_by_version192filter_requirements_by_version

… 4 steps between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyloop (line 361)loopopt (line 374)optopt (line 251)optmain197. filter_requirements_by_version → compare_versions197compare_versions198. filter_requirements_by_version → parse_version198parse_version199. check_req_coverage → _has_version_gate199_has_version_gate200. _has_version_gate → get_validate200get_validate201. _has_version_gate → get_requirements201get_requirements202. check_req_coverage → _exemption_hint202_exemption_hint203. validate_file → check_bus_tags203check_bus_tags204. check_bus_tags → get_validate204get_validate205. check_bus_tags → _bus_tags205_bus_tags206. _bus_tags → get_validate206get_validate

… 2 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesother filesloop (line 1337)looploop (line 252)looploop (line 780)loopopt (line 788)optloop (line 1022)loopopt (line 1026)optopt (line 260)optloop (line 1096)loopopt (line 265)optloop ×2 (line 598)loop ×2main209–210. check_bus_tags → _crosses_bus209_crosses_bus +1 more211. validate_file → check_unknown_tags211check_unknown_tags212. check_unknown_tags → get_validate212get_validate213. check_unknown_tags → _event_tags213_event_tags214–216. check_unknown_tags → _suggest_tag214_suggest_tag +2 more217. _edit_distance → list217list218. validate_file → check_removed_tags218check_removed_tags219. validate_file → check_exemption_reasons219check_exemption_reasons220. check_exemption_reasons → get_validate220get_validate221. validate_file → check_duplicate_tags221check_duplicate_tags222. check_duplicate_tags → get_validate222get_validate223. validate_file → check_req_exists223check_req_exists224. check_req_exists → get_validate224get_validate225. check_req_exists → _uncheckable225_uncheckable226. validate_file → check_fails_when_exists226check_fails_when_exists227. validate_file → check_fails_when_markers227check_fails_when_markers228. check_fails_when_markers → marker228marker229. validate_file → get_file_at_revision229get_file_at_revision230–231. get_file_at_revision → run_git230run_git +1 more232. validate_file → parse_content_for_file232parse_content_for_file233. validate_file → check_version_staleness233check_version_staleness234. check_version_staleness → get_validate234get_validate235–236. check_version_staleness → _index_by_identity235_index_by_identity ×2

… 5 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesother filesloop (line 607)loopopt (line 482)optopt (line 853)optopt (line 114)optopt (line 116)optmain242–243. check_version_staleness → _check_one_version242_check_one_version +1 more244. _validate_files → _report_skips244_report_skips245. run_precommit → report_dir245report_dir246. run_precommit → validate_output_path246validate_output_path247. validate_output_path → resolve_contained_path247resolve_contained_path248. run_precommit → get_requirements248get_requirements249. run_precommit → get_branch_diff_range249get_branch_diff_range250–251. get_branch_diff_range → get_merge_base250get_merge_base +1 more252–253. get_branch_diff_range → _rev_parse_head252_rev_parse_head +1 more254. run_precommit → impact_base254impact_base255. run_precommit → impact_report255impact_report256. impact_report → get_changed_files256get_changed_files257. get_changed_files → run_git257run_git258–260. impact_report → collect_changes258collect_changes +2 more261. _get_file_diff → get_staged_diff261get_staged_diff262. get_staged_diff → run_git262run_git263. _get_file_diff → get_diff263get_diff264. get_diff → run_git264run_git

… 1 step between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyother filesother filesother filesother filesopt (line 94)optopt (line 98)optloop (line 188)looploop (line 583)loopopt (line 587)optopt (line 482)optopt (line 673)optloop (line 684)looploop ×2 (line 625)loop ×2main266. _collect_changed_lines → _get_file_diff266_get_file_diff267. _collect_changed_lines → parse_changed_lines267parse_changed_lines268. collect_changes → _extract_changed_functions268_extract_changed_functions269. _extract_changed_functions → parse_source_file269parse_source_file270. impact_report → find_index270find_index271. find_index → registered_index271registered_index272–275. impact_report → build_report272build_report +3 more276–277. build_report → _place_untagged276_place_untagged +1 more278. run_precommit → _write_report278_write_report279–280. _write_report → validate_output_path279validate_output_path ×2281. _write_report → format_markdown281format_markdown282. format_markdown → _unmapped_markdown282_unmapped_markdown283–284. format_markdown → _markdown_row283_markdown_row +1 more

… 3 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/coverage.pyclew/guard/coverage.pyclew/guard/coverage.pyclew/guard/coverage.pyclew/guard/coverage.pyother filesother filesother filesother filesother filesopt (line 482)optloop (line 179)looploop (line 182)looploop (line 208)looploop (line 150)loopopt (line 57)optmain288. _markdown_row → _cell288_cell289. format_markdown → _unmapped_markdown289_unmapped_markdown290. _write_report → format_json290format_json291. run_precommit → git_add291git_add292. git_add → run_git292run_git293. run_precommit → format_markdown293format_markdown294. run_precommit → _coverage_gate294_coverage_gate295. _coverage_gate → get_requirements295get_requirements296. _coverage_gate → analyze_coverage296analyze_coverage297. analyze_coverage → load_requirements_full297load_requirements_full298. analyze_coverage → collect_tagged_functions298collect_tagged_functions299. collect_tagged_functions → find_source_files299find_source_files300. find_source_files → get_validate300get_validate301–306. find_source_files → _git_ls_files301_git_ls_files +5 more307. collect_tagged_functions → _process_source_file307_process_source_file308. _process_source_file → parse_source_file_with_content308parse_source_file_with_content309. _process_source_file → _extract_tagged_function309_extract_tagged_function310–312. analyze_coverage → _collect_req_ids310_collect_req_ids +2 more313. _exempt → get_requirements313get_requirements314. _exempt → exemption314exemption315. exemption → list315list316. analyze_coverage → traceability316traceability317. traceability → is_test_path317is_test_path318. is_test_path → _matcher318_matcher319. analyze_coverage → covered_via319covered_via320. covered_via → get_requirements320get_requirements

… 4 steps between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/coverage.pyclew/guard/coverage.pyclew/guard/coverage.pyclew/guard/coverage.pyother filesother filesother filesother filesopt (line 250)optmain325. _tagged_at_pin → git_text325git_text326. _realised → exemption326exemption327. _coverage_gate → coverage_gaps327coverage_gaps328. _coverage_gate → format_coverage_text328format_coverage_text329–331. format_coverage_text → traceability_line329traceability_line +2 more332. _coverage_gate → traceability_line332traceability_line333–334. _run → build_parser333build_parser +1 more

… 23 later steps

4 more

tests/guard/test_guard_main.py:184 · its file's page

What it checks (2)

  1. assert result == 0 not attributed
  2. assert {"unmapped", "unmapped_files"} <= set(doc) not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_precommit_with_impact→guard_yaml

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.

Also reaches 29 requirements

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