Skip to content

Commit e06a827

Browse files
authored
Mark pending tests as skipped on test run cancel (#1786)
When cancelling an in progress test run, mark the tests that were in flight at the time of cancellation as skipped instead of failed.
1 parent f6b4efe commit e06a827

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/TestExplorer/TestRunManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class TestRunManager {
5454
const key = this.getTestRunKey(folder);
5555
const activeRun = this.activeTestRuns.get(key);
5656
if (activeRun) {
57+
activeRun.testRun.skipPendingTests();
5758
activeRun.tokenSource.cancel();
5859
}
5960
}

src/TestExplorer/TestRunner.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ export class TestRunProxy {
309309
this.testRun?.errored(test, message, this.recordDuration ? duration : undefined);
310310
}
311311

312+
/**
313+
* Skip any pending tests.
314+
* Call this method when a test run is cancelled to mark the pending tests as skipped.
315+
* Otherwise, pending tests will be marked as failing as we assume they crashed.
316+
*/
317+
public skipPendingTests() {
318+
this.runState.pending.forEach(test => {
319+
this.skipped(test);
320+
});
321+
this.runState.pending = [];
322+
}
323+
312324
public async end() {
313325
// If the test run never started (typically due to a build error)
314326
// start it to flush any queued output, and then immediately end it.

0 commit comments

Comments
 (0)