Skip to content

Commit 874a972

Browse files
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/<me>/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 DeusData#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) <noreply@anthropic.com> Signed-off-by: Joshua Richter <jrichter5781@gmail.com>
1 parent 7b0f553 commit 874a972

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎tests/test_cli.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,15 @@ TEST(cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index) {
20332033
char *old_cache = NULL;
20342034
cli_activation_save_env(&old_home, &old_cache);
20352035
cbm_setenv("HOME", tmpdir, 1);
2036+
/* PATH has to move with HOME. Agent detection asks cbm_find_cli, which
2037+
* reads PATH before anything else, so a real agent binary on the developer's
2038+
* PATH is found even though HOME points at this fixture. Uninstall then
2039+
* tries to edit that agent's config file here, fails because the fixture
2040+
* never created one, and stops before removing the binary and the index —
2041+
* which is exactly what this test measures. Redirecting PATH makes the
2042+
* result the same on every machine. */
2043+
char *old_path = save_test_env("PATH");
2044+
cbm_setenv("PATH", tmpdir, 1);
20362045

20372046
char cache_dir[512];
20382047
char index_path[640];
@@ -2070,6 +2079,7 @@ TEST(cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index) {
20702079
bool binary_preserved =
20712080
installed && strcmp(installed, "binary must survive active-daemon refusal") == 0;
20722081
cli_activation_restore_env(old_home, old_cache);
2082+
restore_test_env("PATH", old_path);
20732083
test_rmdir_r(tmpdir);
20742084

20752085
ASSERT_EQ(rc, 0);

0 commit comments

Comments
 (0)