testing: make test ids locally unique, instead of globally unique

This commit is contained in:
Connor Peet
2021-07-16 12:51:53 -07:00
parent 42c268a626
commit da7d92b8b1
21 changed files with 430 additions and 390 deletions

View File

@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TestIdPathParts } from 'vs/workbench/contrib/testing/common/testId';
import * as vscode from 'vscode';
export const enum ExtHostTestItemEventOp {
@@ -242,6 +243,9 @@ export class TestItemImpl implements vscode.TestItem {
*/
constructor(id: string, label: string, uri: vscode.Uri | undefined) {
const api = getPrivateApiFor(this);
if (id.includes(TestIdPathParts.Delimiter)) {
throw new Error(`Test IDs may not include the ${JSON.stringify(id)} symbol`);
}
Object.defineProperties(this, {
id: {
@@ -256,7 +260,9 @@ export class TestItemImpl implements vscode.TestItem {
},
parent: {
enumerable: false,
get() { return api.parent; },
get() {
return api.parent instanceof TestItemRootImpl ? undefined : api.parent;
},
},
children: {
value: createTestItemCollection(this),
@@ -272,3 +278,9 @@ export class TestItemImpl implements vscode.TestItem {
getPrivateApiFor(this).listener?.({ op: ExtHostTestItemEventOp.Invalidated });
}
}
export class TestItemRootImpl extends TestItemImpl {
constructor(controllerId: string, label: string) {
super(controllerId, label, undefined);
}
}