test_the_build_runs_in_process_and_keeps_stdout_clean¶
Tests › tests/test_mcp_server.py
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
repo = tmp_path / "tiny"(repo / "src").mkdir(parents=True)
4 more
(repo / "src" / "app.c").write_text( "/** @brief Add two numbers. */\nint add(int a, int b) { return a + b; }\n", encoding="utf-8", )(repo / "Doxyfile").write_text( f"INPUT = {repo / 'src'}\nGENERATE_SQLITE3 = YES\nRECURSIVE = YES\n", encoding="utf-8", )target = st.Target( repo_path=str(repo), slug="tiny-test", db_path=str(tmp_path / "state" / "clew.db") )with _captured_stdout() as leaked: result = DocsDbServer.__new__(DocsDbServer)._run_build(target, None)
When
- —
Then
- ✓ result["ok"] is True
- ✓ leaked.getvalue() equals ""
- ✓ result["built"] is True
- ✓ Path(target.db_path).is_file() holds
- ✓ result["output"] contains "memberdef"
- ✓ 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
… 4 steps between
… 16 steps between
… 29 steps between
… 25 steps between
6 more
- clew — `main` (clew/cli.py) · 31 of 400 steps
- Build, refresh and check the index · 21 of 153 steps
- Build this wiki from the index · 6 of 400 steps
- `main` (clew/guard/main.py) · 3 of 357 steps
- clew-mcp — `main` (clew/mcp_server/server.py) · 1 of 17 steps
- `main` (scripts/incremental_probe.py) · 1 of 3 steps
tests/test_mcp_server.py:945 · its file's page
What it checks (6)
assert result["ok"] is True, resultnot attributedassert leaked.getvalue() == "", "the build must never write to this process's stdout"not attributedassert result["built"] is Truenot attributedassert Path(target.db_path).is_file()not attributedassert "memberdef" in result["output"], "the build summary must be captured, not discarded"not attributedassert "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)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-MCP-003 | catalog | unknown |
| REQ-DDB-QUERY-006 | catalog | unknown |
| REQ-DDB-QUERY-008 | catalog | unknown |
| REQ-DDB-QUERY-009 | catalog | unknown |
Also reaches 50 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CLI-001 measured
- REQ-DDB-CONFIG-001 measured
- REQ-DDB-CONFIG-004 measured
- REQ-DDB-CONFIG-005 measured
- REQ-DDB-CONFIG-006 measured
- REQ-DDB-CONFIG-007 measured
- REQ-DDB-CONFIG-008 measured
- REQ-DDB-CONFIG-009 measured
- REQ-DDB-INDEX-001 measured
- REQ-DDB-INDEX-002 measured
- REQ-DDB-INDEX-003 measured
- REQ-DDB-INDEX-004 measured
- REQ-DDB-INDEX-005 measured
- REQ-DDB-INDEX-006 measured
- REQ-DDB-INDEX-007 measured
- REQ-DDB-INDEX-008 measured
- REQ-DDB-INDEX-009 measured
- REQ-DDB-INDEX-010 measured
- REQ-DDB-INDEX-011 measured
- REQ-DDB-MCP-001 measured
- REQ-DDB-MCP-004 measured
- REQ-DDB-PIPE-001 measured
- REQ-DDB-PIPE-003 measured
- REQ-DDB-PIPE-004 measured
- REQ-DDB-PIPE-005 measured
- REQ-DDB-PIPE-006 measured
- REQ-DDB-PIPE-007 measured
- REQ-DDB-PIPE-008 measured
- REQ-DDB-PIPE-009 measured
- REQ-DDB-PIPE-010 measured
- REQ-DDB-PIPE-011 measured
- REQ-DDB-PIPE-012 measured
- REQ-DDB-PIPE-013 measured
- REQ-DDB-PIPE-014 measured
- REQ-DDB-PIPE-015 measured
- REQ-DDB-QUERY-003 measured
- REQ-DDB-QUERY-011 measured
- REQ-DDB-SCHEMA-001 measured
- REQ-DDB-SCHEMA-002 measured
- REQ-DDB-SCHEMA-003 measured
- REQ-DDB-SCHEMA-004 measured
- REQ-DDB-SCHEMA-005 measured
- REQ-DDB-SCHEMA-006 measured
- REQ-DDB-SCHEMA-007 measured
- REQ-DDB-SCHEMA-009 measured
- REQ-DDB-SCHEMA-011 measured
- REQ-DDB-SCHEMA-012 measured
- REQ-DDB-SCHEMA-013 measured
- REQ-DDB-SCHEMA-014 measured
- REQ-DDB-SCHEMA-015 measured