Skip to content

Commit 0d1c7b3

Browse files
committed
test: preserve recording timeout control with registered child ownership
1 parent e17235a commit 0d1c7b3

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

‎src/daemon-client/__tests__/daemon-client-timeout-route.test.ts‎

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,24 +490,37 @@ test('timeout retains a live registration without captured birth proof and repor
490490
}
491491
});
492492

493-
test('a local record stop timeout leaves the exporting daemon and runner alive and names the retry', async () => {
494-
// A match would terminate the runner, which is the recorder on a physical iOS device or macOS.
493+
test('a local record stop timeout leaves the exporting daemon and runner alive and names the retry', async (t) => {
494+
if (await skipWhenLoopbackUnavailable(t)) return;
495495
mockRunCmdSync.mockReturnValue({ exitCode: 0, stdout: '', stderr: '' });
496-
mockIsDaemon.mockReturnValue(true);
497-
const kill = vi.spyOn(process, 'kill').mockImplementation(() => true);
498-
const { server, port } = await startHangingSocketServer();
496+
const endpoint = await startHangingSocketServer();
497+
const paths = resolveDaemonPaths(mkdtempForTestSync('agent-device-record-timeout-owner-'));
498+
const child = spawnRegisteredDaemonFixture(
499+
paths,
500+
{
501+
socketPort: endpoint.port,
502+
token: 'test-token',
503+
version: 'test',
504+
codeOrigin: 'checkout',
505+
codeSignature: 'test',
506+
},
507+
undefined,
508+
);
509+
const kill = vi.spyOn(process, 'kill');
499510
try {
511+
const info = await waitForRegisteredDaemonFixture(paths, child);
512+
const registration = fs.readFileSync(paths.infoPath, 'utf8');
500513
await assert.rejects(
501514
sendRequest(
502-
{ port, pid: 7, token: 'test-token', processStartTime: 'start' },
515+
info,
503516
{
504517
...buildRequest('ios'),
505518
session: 'e2e-ios-0',
506519
command: 'record',
507520
positionals: ['stop'],
508521
},
509522
'socket',
510-
dummyStatePaths(),
523+
paths,
511524
TIMEOUT_MS,
512525
),
513526
(error: unknown) => {
@@ -520,10 +533,14 @@ test('a local record stop timeout leaves the exporting daemon and runner alive a
520533
return true;
521534
},
522535
);
536+
assert.equal(mockRunCmdSync.mock.calls.length, 0);
537+
assert.equal(kill.mock.calls.length, 0);
538+
assert.equal(process.kill(child.pid, 0), true);
539+
assert.equal(fs.readFileSync(paths.infoPath, 'utf8'), registration);
540+
assert.equal(fs.existsSync(paths.lockPath), true);
523541
} finally {
524-
server.close();
542+
kill.mockRestore();
543+
await finishRegisteredDaemonFixture(paths.baseDir);
544+
await closeLoopbackServer(endpoint.server);
525545
}
526-
assert.equal(mockRunCmdSync.mock.calls.length, 0);
527-
assert.equal(kill.mock.calls.length, 0);
528-
assert.equal(mockStop.mock.calls.length, 0);
529546
});

0 commit comments

Comments
 (0)