Skip to content

Commit e5481ce

Browse files
committed
timeout fix
1 parent 62d89d4 commit e5481ce

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/test/testing/testController/unittest/testExecutionAdapter.unit.test.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,23 +524,18 @@ suite('Unittest test execution adapter', () => {
524524
// Stub runInBackground to capture which environment was used
525525
const runInBackgroundStub = sinon.stub(extapi, 'runInBackground');
526526
const exitCallbacks: ((code: number, signal: string | null) => void)[] = [];
527+
// Promise that resolves when the production code registers its onExit handler
528+
const onExitRegistered = createDeferred<void>();
527529
const mockProc2 = {
528530
stdout: { on: sinon.stub() },
529531
stderr: { on: sinon.stub() },
530532
onExit: (cb: (code: number, signal: string | null) => void) => {
531533
exitCallbacks.push(cb);
534+
onExitRegistered.resolve();
532535
},
533536
kill: sinon.stub(),
534537
};
535-
runInBackgroundStub.resolves(mockProc2 as any);
536-
537-
// Create a promise that resolves when runInBackground is called
538-
const runInBackgroundCalled = new Promise<void>((resolve) => {
539-
runInBackgroundStub.callsFake(() => {
540-
resolve();
541-
return Promise.resolve(mockProc2 as any);
542-
});
543-
});
538+
runInBackgroundStub.callsFake(() => Promise.resolve(mockProc2 as any));
544539

545540
const testRun = typeMoq.Mock.ofType<TestRun>();
546541
testRun
@@ -565,8 +560,8 @@ suite('Unittest test execution adapter', () => {
565560
mockProject,
566561
);
567562

568-
// Wait for runInBackground to be called
569-
await runInBackgroundCalled;
563+
// Wait for production code to register its onExit handler
564+
await onExitRegistered.promise;
570565

571566
// Simulate process exit to complete the test
572567
exitCallbacks.forEach((cb) => cb(0, null));

0 commit comments

Comments
 (0)