Skip to content

Commit 588cd55

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 2f9828d commit 588cd55

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
@@ -1707,6 +1707,15 @@ TEST(cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index) {
17071707
char *old_cache = NULL;
17081708
cli_activation_save_env(&old_home, &old_cache);
17091709
cbm_setenv("HOME", tmpdir, 1);
1710+
/* PATH has to move with HOME. Agent detection asks cbm_find_cli, which
1711+
* reads PATH before anything else, so a real agent binary on the developer's
1712+
* PATH is found even though HOME points at this fixture. Uninstall then
1713+
* tries to edit that agent's config file here, fails because the fixture
1714+
* never created one, and stops before removing the binary and the index —
1715+
* which is exactly what this test measures. Redirecting PATH makes the
1716+
* result the same on every machine. */
1717+
char *old_path = save_test_env("PATH");
1718+
cbm_setenv("PATH", tmpdir, 1);
17101719

17111720
char cache_dir[512];
17121721
char index_path[640];
@@ -1744,6 +1753,7 @@ TEST(cli_uninstall_quiesces_active_cohort_before_removing_binary_and_index) {
17441753
bool binary_preserved =
17451754
installed && strcmp(installed, "binary must survive active-daemon refusal") == 0;
17461755
cli_activation_restore_env(old_home, old_cache);
1756+
restore_test_env("PATH", old_path);
17471757
test_rmdir_r(tmpdir);
17481758

17491759
ASSERT_EQ(rc, 0);

0 commit comments

Comments
 (0)