Skip to content

Commit

Permalink
fix: mark tests as skipped only if they were queued
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Nov 22, 2024
1 parent 2ada398 commit 084365e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class TestRunner extends vscode.Disposable {

private testRun: vscode.TestRun | undefined
private testRunDefer: PromiseWithResolvers<void> | undefined
private testRunRequest: vscode.TestRunRequest | undefined

private disposables: vscode.Disposable[] = []

Expand Down Expand Up @@ -91,8 +92,14 @@ export class TestRunner extends vscode.Disposable {
}

if (task.mode === 'skip' || task.mode === 'todo') {
log.verbose?.(`Marking "${test.label}" as skipped during collection`)
testRun.skipped(test)
const include = this.testRunRequest?.include
if (this.testRunRequest && (!include || this.isTestIncluded(test, include))) {
log.verbose?.(`Marking "${test.label}" as skipped`)
testRun.skipped(test)
}
else {
log.verbose?.(`Ignore "${test.label}" during collection`)
}
}
else if (!task.result && task.type !== 'suite') {
log.verbose?.(`Enqueuing "${test.label}" because it was just collected`)
Expand Down Expand Up @@ -153,6 +160,7 @@ export class TestRunner extends vscode.Disposable {
this.testRunDefer?.resolve()
this.testRun = undefined
this.testRunDefer = undefined
this.testRunRequest = undefined
}

private async watchContinuousTests(request: vscode.TestRunRequest, token: vscode.CancellationToken) {
Expand Down Expand Up @@ -280,6 +288,17 @@ export class TestRunner extends vscode.Disposable {
}
}

private isTestIncluded(test: vscode.TestItem, include: readonly vscode.TestItem[] | vscode.TestItemCollection) {
for (const _item of include) {
const item = 'id' in _item ? _item : _item[1]
if (item === test)
return true
if (this.isTestIncluded(test, item.children))
return true
}
return false
}

private isFileIncluded(file: string, include: readonly vscode.TestItem[] | vscode.TestItemCollection) {
for (const _item of include) {
const item = 'id' in _item ? _item : _item[1]
Expand Down Expand Up @@ -345,6 +364,7 @@ export class TestRunner extends vscode.Disposable {
: this.relative(files[0])

const run = this.testRun = this.controller.createTestRun(request, name)
this.testRunRequest = request

for (const file of files) {
if (file[file.length - 1] === '/') {
Expand Down

0 comments on commit 084365e

Please sign in to comment.