Skip to content

Commit ea4057a

Browse files
committed
test: model vanished managed adb fixture groups
1 parent 40593e0 commit ea4057a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎test/integration/provider-scenarios/managed-runtime-automation.fixtures.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
3+
import { vi } from 'vitest';
34
import { runCmd } from '@agent-device/host-kit/command';
45
import { Deadline } from '@agent-device/host-kit/retry';
56
import { AppError } from '@agent-device/kernel/errors';
@@ -159,6 +160,7 @@ export async function withManagedAdbFixture<T>(
159160
].join('\n'),
160161
);
161162
fs.chmodSync(adbPath, 0o755);
163+
const restoreGroupSignals = refuseVanishedFixtureGroups();
162164
const previousPath = process.env.PATH;
163165
process.env.PATH = `${root}${path.delimiter}${previousPath ?? ''}`;
164166
try {
@@ -174,7 +176,18 @@ export async function withManagedAdbFixture<T>(
174176
: [],
175177
});
176178
} finally {
179+
restoreGroupSignals();
177180
if (previousPath === undefined) delete process.env.PATH;
178181
else process.env.PATH = previousPath;
179182
}
180183
}
184+
185+
/** The fake adb has no descendants; an exited leader leaves no group to signal. */
186+
function refuseVanishedFixtureGroups(): () => void {
187+
const signal = process.kill.bind(process);
188+
const spy = vi.spyOn(process, 'kill').mockImplementation((pid, kind = 'SIGTERM') => {
189+
if (pid < 0) signal(-pid, 0);
190+
return signal(pid, kind);
191+
});
192+
return () => spy.mockRestore();
193+
}

0 commit comments

Comments
 (0)