Skip to content

Commit cdd3fac

Browse files
fix(doctor): plan to describe, not to build
doctor's prepare is offline, and now plan_only with a scratch work_dir, as `mcpp emit build-database` plans: the std module is described rather than compiled, generated files are compared rather than written, and the lock goes to the scratch directory. e2e 22 relied on doctor precompiling std as a side effect; it now asserts the cache is still empty after doctor and makes the std entry it lists with a build. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 0373bf7 commit cdd3fac

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

‎src/doctor.cppm‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ export int doctor_report() {
206206
// diagnoses, and reports something else, is two defects.
207207
//
208208
// Offline for the call: nothing is downloaded, installed or replaced, so
209-
// a build that would install first is reported as exactly that.
209+
// a build that would install first is reported as exactly that. Planned
210+
// to describe, not to build (`plan_only`, as `mcpp emit build-database`
211+
// plans): the std module is described rather than compiled, generated
212+
// files are compared rather than written, and the lock this planning
213+
// produces goes to a scratch directory, not the project.
210214
const bool inPackage = mcpp::project::find_manifest_root(std::filesystem::current_path()).has_value();
211215
bool prepareWouldInstall = false;
212216
auto pctx = [&]() -> decltype(mcpp::build::prepare_build(false)) {
@@ -215,7 +219,13 @@ export int doctor_report() {
215219
const bool wasQuiet = mcpp::ui::is_quiet();
216220
mcpp::ui::set_quiet(true);
217221
(void)mcpp::build::refusal::take();
218-
auto r = mcpp::build::prepare_build(/*print_fingerprint=*/false);
222+
mcpp::build::BuildOverrides ov;
223+
ov.plan_only = true;
224+
std::error_code tec;
225+
ov.work_dir = std::filesystem::temp_directory_path(tec)
226+
/ std::format("mcpp-doctor-{}", std::chrono::steady_clock::now().time_since_epoch().count());
227+
auto r = mcpp::build::prepare_build(/*print_fingerprint=*/false, /*includeDevDeps=*/false, {}, ov);
228+
std::filesystem::remove_all(ov.work_dir, tec);
219229
prepareWouldInstall = !r && mcpp::build::refusal::take()
220230
== mcpp::build::refusal::Code::OfflineDownloadRequired;
221231
mcpp::ui::set_quiet(wasQuiet);

‎tests/e2e/22_doctor_cache_publish.sh‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ trap "rm -rf $TMP" EXIT
1212
export MCPP_HOME="$TMP/mcpp-home"
1313

1414
# 0) cache list on a genuinely empty cache: friendly message.
15-
# This has to come BEFORE doctor — doctor resolves a build plan, which
16-
# precompiles the std module, and `cache list` now reports std entries too.
17-
# Hiding them is how 16 GB of duplicated std BMIs went unnoticed, so listing
18-
# them is the fix, not a regression.
1915
out=$("$MCPP" cache list 2>&1)
2016
[[ "$out" == *"empty"* ]] || { echo "cache list on empty cache: '$out'"; exit 1; }
2117

@@ -29,8 +25,17 @@ grep -q 'Checking registry' doctor.log || { cat doctor.log; echo "no regis
2925
grep -q 'Checking cache health' doctor.log || { cat doctor.log; echo "no cache check"; exit 1; }
3026
grep -q 'Doctor result' doctor.log || { cat doctor.log; echo "no result line"; exit 1; }
3127

32-
# 2) after doctor, the std module it precompiled must be VISIBLE. std entries
28+
# 1b) doctor changes nothing (2026.10.17.1): its plan is prepared offline and
29+
# builds nothing, so the cache is still empty after it.
30+
out=$("$MCPP" cache list 2>&1)
31+
[[ "$out" == *"empty"* ]] || { echo "doctor wrote to the build cache: '$out'"; exit 1; }
32+
33+
# 2) after a build, the std module it precompiled must be VISIBLE. std entries
3334
# dominate the cache's size, and `cache list` used to walk only dep entries.
35+
# Hiding them is how 16 GB of duplicated std BMIs went unnoticed, so listing
36+
# them is the fix, not a regression.
37+
( cd "$TMP" && "$MCPP" new stdprobe >/dev/null && cd stdprobe && "$MCPP" build > "$TMP/stdprobe.log" 2>&1 ) \
38+
|| { cat "$TMP/stdprobe.log"; echo "the build that precompiles std failed"; exit 1; }
3439
out=$("$MCPP" cache list 2>&1)
3540
[[ "$out" == *"std"* ]] || { echo "cache list omits the std entry: '$out'"; exit 1; }
3641
# The age column must be plausible: file_time_type's epoch is not the Unix

0 commit comments

Comments
 (0)