test: stop worker-teardown console race from failing unit shards (#39813)

Vitest rejects a console-log RPC still in flight when a worker tears
down, failing a shard whose tests all passed. Ignore only that rejection
(the lost line belongs to a finished file and passed-only shards drop
it anyway), and stop the two specs seen in CI from spawning real git and
wsl.exe in fire-and-forget background work.

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-08 02:55:36 -08:00
committed by GitHub
co-authored by OrcaWin
parent b4a522deeb
commit de3da487fa
3 changed files with 20 additions and 0 deletions
@@ -1,6 +1,8 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import type * as LegacyWslRuntimeAuthDrain from './legacy-wsl-runtime-auth-drain'
import type * as WslCodexSessionBridge from '../codex/history/bridges/wsl-codex-session-bridge'
import { createSettings } from './runtime-home-settings-test-fixtures'
import {
createCodexAuthJson,
@@ -16,6 +18,15 @@ import {
vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({
blockedWslDistroForExec: async () => null
}))
// Background WSL drain/bridge spawn wsl.exe and warn after the file ends; these specs cover only routing.
vi.mock('./legacy-wsl-runtime-auth-drain', async (importOriginal) => ({
...(await importOriginal<typeof LegacyWslRuntimeAuthDrain>()),
startLegacyWslRuntimeAuthDrain: async () => {}
}))
vi.mock('../codex/history/bridges/wsl-codex-session-bridge', async (importOriginal) => ({
...(await importOriginal<typeof WslCodexSessionBridge>()),
startWslCodexSessionBridgeInBackground: async () => {}
}))
vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
@@ -294,6 +294,12 @@ vi.mock('../../git/worktrees/catalog/worktree-listing', async (importOriginal) =
describeCreatedWorktree: (await getWorktreeOwnerMocks()).describeCreatedWorktree
}))
// Fire-and-forget reclaim runs real Git on fixture paths and warns after the file ends.
vi.mock(
'../../workspaces/creation/preparation/worktree-create-preparation-project-removal',
() => ({ releaseWorktreeCreatePreparationsForRepo: vi.fn() })
)
const { getWorktreeOwnerMocks } = vi.hoisted(() => {
function createWorktreeOwnerMocks() {
return (() => ({