From 874a972fb7c4eb06e739dce0a390fffb85d31f83 Mon Sep 17 00:00:00 2001 From: Joshua Richter Date: Thu, 3 Sep 2026 19:05:05 -0400 Subject: [PATCH] test(cli): point PATH at the fixture so uninstall isolation holds on any machine cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index moved HOME and CBM_CACHE_DIR into a temporary directory but left PATH alone. Agent detection reads PATH first, so a real agent binary on the developer's machine was found even though HOME pointed at the empty fixture. Uninstall then tried to edit that agent's config file inside the fixture, failed because the fixture never created one, and stopped before removing the binary and the index. The test measures exactly that removal, so it failed. On this machine the agent is Goose, at /Users//go/bin/goose. Same tree and same built runner, only PATH differs: goose on PATH 291 passed, 1 failed goose off PATH 292 passed, 0 failed With this change the suite reports 292 passed, 0 failed while goose is still on PATH, so the fix is the redirect and not a quieter environment. This only stops the suite from depending on what the developer has installed. The abort it exposed is a real defect and is reported in #1954: one agent config that cannot be edited stops teardown for every other agent and for the executable and indexes. Eleven other tests that call cli_activation_save_env leave PATH open the same way. They pass today, so I left them alone rather than change what they exercise without evidence. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Joshua Richter --- tests/test_cli.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_cli.c b/tests/test_cli.c index f1507bd2a..a95b4a84f 100644 --- a/tests/test_cli.c +++ b/tests/test_cli.c @@ -2033,6 +2033,15 @@ TEST(cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index) { char *old_cache = NULL; cli_activation_save_env(&old_home, &old_cache); cbm_setenv("HOME", tmpdir, 1); + /* PATH has to move with HOME. Agent detection asks cbm_find_cli, which + * reads PATH before anything else, so a real agent binary on the developer's + * PATH is found even though HOME points at this fixture. Uninstall then + * tries to edit that agent's config file here, fails because the fixture + * never created one, and stops before removing the binary and the index — + * which is exactly what this test measures. Redirecting PATH makes the + * result the same on every machine. */ + char *old_path = save_test_env("PATH"); + cbm_setenv("PATH", tmpdir, 1); char cache_dir[512]; char index_path[640]; @@ -2070,6 +2079,7 @@ TEST(cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index) { bool binary_preserved = installed && strcmp(installed, "binary must survive active-daemon refusal") == 0; cli_activation_restore_env(old_home, old_cache); + restore_test_env("PATH", old_path); test_rmdir_r(tmpdir); ASSERT_EQ(rc, 0);