Skip to content

test(launcher): stop a Windows teardown turning a passing run red - #1988

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
abhisheksharma2411:fix/windows-launcher-test-cleanup
Nov 18, 2026
Merged

lizhengfeng101 merged 1 commit into
alibaba:mainfrom
abhisheksharma2411:fix/windows-launcher-test-cleanup

Conversation

@abhisheksharma2411

Copy link
Copy Markdown
Contributor

Description

Fixes #1987.

The windows job fails after the launcher suite has printed every "passed" line it has, with no assertion having failed:

ocr launcher exit-code tests passed
ocr launcher signal policy tests passed
skipping POSIX signal relay cases on win32
Error: EBUSY: resource busy or locked, unlink '...\node_modules\@alibaba-group\ocr-win32-x64\bin\opencodereview.exe'
    at rimrafSync

createLauncherFixture copies the running node executable to the fixture binary path on Windows, where POSIX gets a symlink, and the cases then run it. Windows keeps an executable's image mapped for a short time after the process that ran it exits, so removing it straight afterwards can fail with EBUSY. Two places remove it and either can meet the lock: testSpawnFailure's unlinkSync, and the rmSync in the finally. force: true does not help — it suppresses ENOENT, not EBUSY.

The stack above comes from the finally, which means the real failure was in testSpawnFailure and the teardown error replaced it on the way out. That is the part that makes this hard to read: the error on screen is never the one that actually went wrong.

What changed

Both removals retry. fs.rm retries exactly this class of error when maxRetries is set. It ignores the retry options unless recursive is also set, even for a single file, so that is passed too — with a comment, because it reads like a mistake otherwise.

Teardown no longer decides the exit code. Removing a temp directory is housekeeping, not an assertion about the launcher, so it cannot fail a run whose assertions all passed. And when the run did fail, the teardown error is printed beside the real one rather than replacing it.

The suite body moved into runLauncherIntegrationTests and the fixture lifecycle into runWithTeardown, which takes the remover as a parameter so both outcomes can be tested without arranging a locked file.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

node bin/ocr.test.js passes on macOS. Three new assertions cover the teardown policy: a passing run stays passing when the fixture cannot be removed, a failing run still returns its own error, and the fixture is removed on the happy path. A fourth checks that the teardown failure is reported in both cases rather than swallowed — the point is to be quiet about it, not silent.

Mutation-checked rather than assumed:

  • rethrowing the teardown error instead of reporting it fails the first case;
  • letting the teardown error overwrite the run's error fails the second.

What I could not test: the retry itself. Reproducing the lock needs a Windows host, and I would rather say so than add a test that only asserts the option is present. The reasoning is the error in the CI log plus Node's documented retry behaviour for EBUSY; the Windows job on this PR is the real check.

I also left the file's existing formatting alone — Prettier reports the same issues on main and is not wired into CI, so reformatting would only add noise here.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have added tests that prove the fix is effective
  • New and existing unit tests pass locally with my changes
  • Documentation updated — not applicable

AI/LLM Disclosure

Claude assisted with the investigation, the change, the tests and this description. The CI log reading, the mutation checks and the local test runs are from my own machine, and I have said plainly which part I could not verify.

Related Issues

Closes #1987

On Windows the fixture binary is a copy of the running node executable,
and the image stays mapped briefly after the process exits, so removing
it can fail with EBUSY. Both removals now retry, and teardown no longer
decides the exit code or replaces the run's own error.

Signed-off-by: Abhishek Sharma <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review skipped: no items were selected.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit f921d6a into alibaba:main Nov 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows CI: launcher test exits 1 from its own teardown after every assertion has passed

2 participants