test_the_build_runs_in_process_and_keeps_stdout_clean

Tests › tests/test_mcp_server.py

passed Passed in the packaged run.

What this test is for

Why it exists

On this server `sys.stdout` IS the JSON-RPC transport, and the pipeline renders progress bars, doxygen warnings and a table summary while it builds. In-process those would be spliced into the protocol stream, so every writer goes through `_common.active_console` and the build wraps itself in `_common.captured_output`.

Verifies REQ-DDB-MCP-003 REQ-DDB-QUERY-006 REQ-DDB-QUERY-008 REQ-DDB-QUERY-009

Given

  1. repo = tmp_path / "tiny"
  2. (repo / "src").mkdir(parents=True)
4 more
  1. (repo / "src" / "app.c").write_text( "/** @brief Add two numbers. */\nint add(int a, int b) { return a + b; }\n", encoding="utf-8", )
  2. (repo / "Doxyfile").write_text( f"INPUT = {repo / 'src'}\nGENERATE_SQLITE3 = YES\nRECURSIVE = YES\n", encoding="utf-8", )
  3. target = st.Target( repo_path=str(repo), slug="tiny-test", db_path=str(tmp_path / "state" / "clew.db") )
  4. with _captured_stdout() as leaked: result = DocsDbServer.__new__(DocsDbServer)._run_build(target, None)
→

When

  1. —
→

Then

  1. ✓ result["ok"] is True
  2. ✓ leaked.getvalue() equals ""
  3. ✓ result["built"] is True
  4. ✓ Path(target.db_path).is_file() holds
  5. ✓ result["output"] contains "memberdef"
  6. ✓ result["output"] contains "scope:"

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.

thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 38 of 142 steps

thread startthread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyother filesother filesother filesother filesother filestry (line 1664)trytry (line 1003)tryopt (line 845)optloop (line 1239)loopopt (line 847)optloop (line 746)looploop (line 1055)loopopt (line 1075)opt_first_build_worker1. _first_build_worker → first_party_sub_index1first_party_sub_index2. first_party_sub_index → whole_repo_scope2whole_repo_scope3. whole_repo_scope → _gitignored_paths3_gitignored_paths▶ test enters4. _gitignored_paths → git_argv4git_argv5–6. git_argv → _no_ext_diff5_no_ext_diff +1 more7. list → link7link8. _gitignored_paths → git_env8git_env9. whole_repo_scope → list9list10. whole_repo_scope → nested_repo_roots10nested_repo_roots11. nested_repo_roots → _nested_repos_under11_nested_repos_under12–14. _nested_repos_under → _warn_unwalkable12_warn_unwalkable +2 more15. nested_repo_roots → _nested_repos_under15_nested_repos_under16. whole_repo_scope → _gitignored_paths16_gitignored_paths17–18. whole_repo_scope → _pruned_dirs17_pruned_dirs +1 more19. _pruned_dirs → _skip_dir19_skip_dir20–22. _pruned_dirs → _descendable20_descendable +2 more23–26. whole_repo_scope → _declaration_note23_declaration_note +3 more27–28. first_party_sub_index → _under_any27_under_any +1 more

… 4 steps between

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pytry (line 1664)tryopt (line 1666)optopt (line 352)opt_first_build_worker33. _first_build_worker → target_for33target_for34. target_for → _safe_index_name34_safe_index_name35. target_for → state_home35state_home▶ test enters36. _first_build_worker → _run_build36_run_build37. _run_build → nested_tree_cache37nested_tree_cache▶ test enters38–39. _run_build → _run_build_walked38_run_build_walked +1 more40. _sub_index_rejection → first_party_sub_index40first_party_sub_index41. _sub_index_rejection → _buildable_sub_indexes41_buildable_sub_indexes

… 16 steps between

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyother filesother filesother filesother filesopt (line 3215)opttry (line 3260)try_first_build_worker58. _offered_sub_indexes → list58list59. _run_build_walked → _buildable_sub_indexes59_buildable_sub_indexes60. _run_build_walked → discover_doxyfile60discover_doxyfile61. _run_build_walked → captured_output61captured_output62. _run_build_walked → build_lock62build_lock63–64. build_lock → _os_lock63_os_lock +1 more65. _run_build_walked → db_status65db_status66–67. db_status → _options_meta66_options_meta +1 more

… 29 steps between

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/mcp_server/freshness.pyclew/declaration.pyclew/declaration.pyclew/declaration.pyclew/declaration.pytry (line 3260)tryalt (line 1171)altopt (line 485)opt_first_build_worker97–98. notices → _derived_notice97_derived_notice +1 more99. _run_build_walked → declared_scope_rejection99declared_scope_rejection100. declared_scope_rejection → _declared_index_scope100_declared_index_scope101. _declared_index_scope → load_declaration_located101load_declaration_located102. load_declaration_located → _read_mapping102_read_mapping103. _read_mapping → _parsed_declaration103_parsed_declaration104. load_declaration_located → _checked_sections104_checked_sections

… 25 steps between

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/declaration.pyclew/declaration.pyclew/declaration.pyclew/declaration.pyother filesother filesother filesother filesloop (line 1416)looptry (line 3260)trycatch (line 3328)catch_first_build_worker130. _existing_paths → _is_within130_is_within131. _declared_index_scope → _existing_paths131_existing_paths132. _run_build_walked → _sub_index_scope132_sub_index_scope133. _sub_index_scope → first_party_sub_index133first_party_sub_index134. _sub_index_scope → derive_sub_indexes134derive_sub_indexes135. _sub_index_scope → declared_sub_index_excludes135declared_sub_index_excludes136. declared_sub_index_excludes → load_declaration136load_declaration137. load_declaration → load_declaration_located137load_declaration_located▶ test enters138. _run_build_walked → _bounded_output138_bounded_output139. _bounded_output → all139all140. _run_build_walked → _failure_result140_failure_result141. _run_build_walked → _bounded_output141_bounded_output142. _run_build_walked → 142… 2 calls not run
6 more

tests/test_mcp_server.py:945 · its file's page

What it checks (6)

  1. assert result["ok"] is True, result not attributed
  2. assert leaked.getvalue() == "", "the build must never write to this process's stdout" not attributed
  3. assert result["built"] is True not attributed
  4. assert Path(target.db_path).is_file() not attributed
  5. assert "memberdef" in result["output"], "the build summary must be captured, not discarded" not attributed
  6. assert "scope:" in result["output"], "the pipeline's own explanation must reach the caller" not attributed

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.

Requirements it verifies (4)

requirementlinked byimplementers exercised
REQ-DDB-MCP-003catalogunknown
REQ-DDB-QUERY-006catalogunknown
REQ-DDB-QUERY-008catalogunknown
REQ-DDB-QUERY-009catalogunknown
Also reaches 50 requirements

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