test_finds_changed_function

Tests › tests/guard/test_guard_impact.py

passed Passed in the packaged run.

What this test is for

Why it exists

The test says nothing about why.

Given

  1. c_file = tmp_path / "test.c"
  2. c_file.write_text( dedent("""\ /** * @brief Do stuff. * @version 1.1 * @req REQ-0252 */ void Do_Stuff(void) { new_impl(); } """) )
  3. def mock_runner(cmd): return "@@ -6,1 +6,1 @@\n-old\n+new\n"
→

When

  1. result = collect_changed_functions( [str(c_file)], CONFIG_DEFAULTS, staged=True, run_command=mock_runner, )
→

Then

  1. ✓ len(result) equals 1
  2. ✓ result[0].name equals "Do_Stuff"
  3. ✓ result[0].reqs contains "REQ-0252"
  4. ✓ result[0].new_version equals "1.1"

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) · 51 of 357 steps

… 65 earlier steps

program launcherprogram launcherprogram launcherprogram launcherother filesother filesother filesother filesopt (line 1336)optalt (line 1344)altmain66–67. read_catalog_at → git_text66git_text +1 more68–69. git_argv → _no_ext_diff68_no_ext_diff +1 more70–71. read_catalog_at → _refuse_url70_refuse_url +1 more

… 30 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 168)optloop (line 647)loopopt (line 786)optopt (line 652)optmain102. 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_presence

… 6 steps between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesopt (line 1198)optloop (line 143)loopopt (line 1171)optloop (line 181)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. apply_autobrief → _mask_escaped_at172_mask_escaped_at

… 56 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/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesopt (line 265)optmain229. validate_file → get_file_at_revision229get_file_at_revision230. get_file_at_revision → run_git230run_git231. run_git → git_argv231git_argv232. validate_file → parse_content_for_file232parse_content_for_file233. validate_file → check_version_staleness233check_version_staleness

… 23 steps between

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/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.pyother filesother filesother filesother filesother filesloop (line 188)loopopt (line 114)optopt (line 116)optopt (line 92)optopt (line 94)optopt (line 98)optmain257. get_changed_files → run_git257run_git258. impact_report → collect_changes258collect_changes259. collect_changes → _collect_changed_lines259_collect_changed_lines▶ test enters260. _collect_changed_lines → _get_file_diff260_get_file_diff261. _get_file_diff → get_staged_diff261get_staged_diff262. get_staged_diff → run_git262run_git263. _get_file_diff → get_diff263get_diff264. get_diff → run_git264run_git265. _collect_changed_lines → parse_changed_lines265parse_changed_lines266. _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_index

… 86 later steps

4 more

tests/guard/test_guard_impact.py:48 · its file's page

What it checks (4)

  1. assert len(result) == 1 observes collect_changed_functions via result
  2. assert result[0].name == "Do_Stuff" observes collect_changed_functions via result
  3. assert "REQ-0252" in result[0].reqs observes collect_changed_functions via result
  4. assert result[0].new_version == "1.1" observes collect_changed_functions via result

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_finds_changed_function→collect_changed_functions

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_finds_changed_function · 4 checkscollect_changed_functions… 5 calls …git_argvREQ-DDB-CONFIG-001 · measuredcollect_changed_functionsREQ-DDB-GUARD-008 · measuredcollect_changed_functionscollect_changesREQ-DDB-GUARD-010 · measuredcollect_changed_functions… 5 calls …get_language_configREQ-DDB-GUARD-013 · measuredcollect_changed_functionscollect_changes_extract_changed_functionsparse_source_fileREQ-DDB-GUARD-018 · measuredcollect_changed_functions… 9 calls …parse_doxygen_tagsREQ-DDB-GUARD-019 · measuredcollect_changed_functions… 5 calls …language_for_fileREQ-DDB-GUARD-020 · measuredcollect_changed_functions… 9 calls …_find_python_docstring_blockREQ-DDB-GUARD-021 · inferredcollect_changed_functionscollect_changes_collect_changed_linesparse_changed_linesREQ-DDB-GUARD-023 · measuredcollect_changed_functions… 8 calls …_is_rust_test_itemREQ-DDB-GUARD-024 · inferredcollect_changed_functions… 8 calls …_js_returns_voidREQ-DDB-GUARD-025 · measured
Also reaches 11 requirements

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