From d56eef11a238a41b321d988aad34ee8598e1e8ac Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 22 Feb 2021 13:26:17 -0800 Subject: [PATCH] add required ids and support exclude --- test-provider-sample/src/testProvider.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test-provider-sample/src/testProvider.ts b/test-provider-sample/src/testProvider.ts index a00770f2..ca47c428 100644 --- a/test-provider-sample/src/testProvider.ts +++ b/test-provider-sample/src/testProvider.ts @@ -64,6 +64,10 @@ export class MathTestProvider implements vscode.TestProvider { public async runTests(run: vscode.TestRun, cancellation: vscode.CancellationToken) { const runTests = async (tests: Iterable) => { for (const test of tests) { + if (run.exclude?.includes(test)) { + continue; + } + if (test instanceof TestCase) { if (cancellation.isCancellationRequested) { run.setState(test, { state: vscode.TestRunState.Skipped }); @@ -108,11 +112,13 @@ const headingRe = /^(#+)\s*(.+)$/; class TestRoot implements vscode.TestItem { public readonly label = 'Markdown Tests'; + public readonly id = 'markdown'; public children = [] as TestFile[]; } class TestFile implements vscode.TestItem { public readonly label = this.uri.path.split('/').pop()!; + public readonly id = `markdown/${this.uri.toString()}`; public children: (TestHeading | TestCase)[] = []; constructor(public readonly uri: vscode.Uri) {} @@ -168,12 +174,13 @@ class TestFile implements vscode.TestItem { } class TestHeading implements vscode.TestItem { + public readonly id = `markdown/${this.location.uri.toString()}/${this.label}`; public readonly children: (TestHeading | TestCase)[] = []; constructor( public readonly level: number, public readonly label: string, - public readonly location: vscode.Location + public readonly location: vscode.Location, ) {} } @@ -183,7 +190,7 @@ class TestCase implements vscode.TestItem { } public get id() { - return `${this.location.uri.toString()}: ${this.label}`; + return `markdown/${this.location.uri.toString()}/${this.label}`; } constructor(