Skip to content

test: fix two local-only test failures caused by leftover state - #1422

Draft
l2ysho wants to merge 1 commit into
masterfrom
claude/fervent-rubin-afcf18
Draft

test: fix two local-only test failures caused by leftover state#1422
l2ysho wants to merge 1 commit into
masterfrom
claude/fervent-rubin-afcf18

Conversation

@l2ysho

@l2ysho l2ysho commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Note

Two test-only fixes for failures that never show up in CI but break pnpm run test:local. One made the Python test alternate pass/fail on every other run; the other fails for anyone running the suite from inside an AI agent CLI.

python_support alternated pass/fail

Measured 5/10 with --retry=0, deterministic alternation, pre-existing on master.

  1. useTempPath(..., { remove: false }) left test/tmp/my-python-actor behind — the only test in the repo using remove: false. It was flipped from true in fix: python project detection and project detection #774 with no stated reason.
  2. On the next run usePythonRuntime({ cwd: tmpPath, force: true }) found the leftover .venv and cached <tmpPath>/.venv/bin/python3 as the interpreter.
  3. The test then deleted tmpPath, and so that interpreter.
  4. The template setup invoked the cached path → exit 127, no .venv created, assertion failed.

CI never hit it: fresh checkout every job, plus retry: 3 in vitest.config.ts.

Fix: remove: true, and delete tmpPath before runtime detection so an interrupted run can't leave a venv that gets picked up.

detectAiAgent fails inside any agent CLI

The nine agent env vars were cleared in afterEach only, so the first test ran against whatever the shell exported. Inside Claude Code (CLAUDECODE=1) it returned claude_code instead of undefined. Same for Cursor, Codex, Gemini CLI.

Fix: clear them in beforeEach via vi.stubEnv, restore with vi.unstubAllEnvs(). The old delete also leaked — it removed CLAUDECODE from process.env for every later test in the worker.

Verification

  • python_support: 4/4 consecutive runs with --retry=0 without clearing test/tmp; also passes with a real .venv planted at test/tmp/my-python-actor/.venv (the exact state that used to fail).
  • detectEnvironment: 7/7 with CLAUDECODE=1 set and 7/7 with it unset.
  • Full local suite: 60 files / 557 tests, 0 failures, --retry=0.
  • Lint, format, build clean. No install-size impact.

🤖 Generated with Claude Code

`python_support` left `test/tmp/my-python-actor` behind (`remove: false`),
so the next run detected the stale `.venv` as the Python runtime, cached
that interpreter path, then deleted it — making the test alternate
pass/fail on every other local run.

`detectAiAgent` cleared the agent env vars in `afterEach` only, so the
first test saw whatever the shell exported and failed inside any agent
CLI.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added this to the 149th sprint - Tooling team milestone Sep 10, 2026
@github-actions github-actions Bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Sep 10, 2026
@l2ysho l2ysho added t-builders Issues owned by the Builders team. and removed t-tooling Issues with this label are in the ownership of the tooling team. labels Sep 10, 2026

@apify-factory apify-factory left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nothing blocking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-builders Issues owned by the Builders team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants