Skip to content

[tests] Investigate opencode_discovery test pollution in full-suite run #25

@Zeus-Deus

Description

@Zeus-Deus

Context

Discovered while preparing PR #15 for merge: `agent_provider::opencode::discovery::tests::check_against_live_binary_when_present` passes in isolation but fails in the full `cargo test` suite on the `workspace-cloud-push` branch.

This is a separate test-pollution issue from the `process_kill` one that was fixed in commit `38e78d7` (which was caused by `std::env::set_var("HOME", ...)` in expand_tilde tests leaking globally). The opencode_discovery test was failing on this branch even AFTER that fix, and the test file itself was last touched in commit `0dcf05b` (pre-dating PR #15 entirely).

This means some new test added on `workspace-cloud-push` is polluting the opencode_discovery test, but it's not the expand_tilde set_var one (already fixed).

What's needed

  1. Reproduce the failure:
    ```bash
    cargo test --manifest-path src-tauri/Cargo.toml --no-default-features --lib 2>&1 | grep -E "test result|opencode_discovery"
    ```
    On the merged-to-main branch this should show 1 failure (`agent_browser` — pre-existing) plus the opencode_discovery one.

  2. Bisect to find the polluter:

    • Run with progressively narrower test selections until the opencode_discovery failure goes away
    • The polluter is in whatever test was last excluded
  3. Identify the pollution mechanism:

    • Likely candidates: a test that mutates env vars (similar to the expand_tilde bug), opens fds without closing them, spawns a process and leaks the pid, etc.
    • The opencode_discovery test probably does file/binary detection, so any pollution that affects PATH, file existence checks, or process spawning could trip it
  4. Fix it:

    • Refactor the polluting test to not touch global state, OR
    • Save/restore the global state explicitly, OR
    • Mark the test as `serial_test` if reliable isolation is impossible

Acceptance criteria

`cargo test --manifest-path src-tauri/Cargo.toml --no-default-features --lib` runs with no failures except the pre-existing `agent_browser::resolve_binary_finds_native_binary_from_project_root` flake (which exists on main and is unrelated).

Out of scope

  • Fixing the agent_browser flake (separate pre-existing issue)
  • Rewriting the test infrastructure to avoid all pollution categorically

Estimate

30 min to 2 hours depending on how quickly the bisection narrows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions