From 79080e51d586640ce5b8a7332d09b5a246a2004e Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 18 Aug 2025 11:17:53 -0400 Subject: [PATCH] Mark pending tests as skipped on test run cancel When cancelling an in progress test run, mark the tests that were in flight at the time of cancellation as skipped instead of failed. --- src/TestExplorer/TestRunManager.ts | 1 + src/TestExplorer/TestRunner.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/TestExplorer/TestRunManager.ts b/src/TestExplorer/TestRunManager.ts index af80bdc99..0e203394d 100644 --- a/src/TestExplorer/TestRunManager.ts +++ b/src/TestExplorer/TestRunManager.ts @@ -54,6 +54,7 @@ export class TestRunManager { const key = this.getTestRunKey(folder); const activeRun = this.activeTestRuns.get(key); if (activeRun) { + activeRun.testRun.skipPendingTests(); activeRun.tokenSource.cancel(); } } diff --git a/src/TestExplorer/TestRunner.ts b/src/TestExplorer/TestRunner.ts index cc502f0bd..e6cccbd15 100644 --- a/src/TestExplorer/TestRunner.ts +++ b/src/TestExplorer/TestRunner.ts @@ -309,6 +309,18 @@ export class TestRunProxy { this.testRun?.errored(test, message, this.recordDuration ? duration : undefined); } + /** + * Skip any pending tests. + * Call this method when a test run is cancelled to mark the pending tests as skipped. + * Otherwise, pending tests will be marked as failing as we assume they crashed. + */ + public skipPendingTests() { + this.runState.pending.forEach(test => { + this.skipped(test); + }); + this.runState.pending = []; + } + public async end() { // If the test run never started (typically due to a build error) // start it to flush any queued output, and then immediately end it.