Skip to content

Commit

Permalink
testing: fix setting states in a run with identical IDs not working
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Aug 30, 2021
1 parent d1e4e27 commit f3fbecd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/vs/workbench/api/common/extHostTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,30 +444,26 @@ class TestRunTracker extends Disposable {
throw new InvalidTestItemError(test.id);
}

if (this.sharedTestIds.has(test.id)) {
if (this.sharedTestIds.has(TestId.fromExtHostTestItem(test, this.dto.controllerId).toString())) {
return;
}

const chain: ITestItem[] = [];
const root = this.dto.colllection.root;
while (true) {
chain.unshift(Convert.TestItem.from(test as TestItemImpl));
const converted = Convert.TestItem.from(test as TestItemImpl);
chain.unshift(converted);

if (this.sharedTestIds.has(test.id)) {
if (this.sharedTestIds.has(converted.extId)) {
break;
}

this.sharedTestIds.add(test.id);
if (!test.parent) {
this.sharedTestIds.add(converted.extId);
if (test === root) {
break;
}

test = test.parent;
}

const root = this.dto.colllection.root;
if (!this.sharedTestIds.has(root.id)) {
this.sharedTestIds.add(root.id);
chain.unshift(Convert.TestItem.from(root));
test = test.parent || root;
}

this.proxy.$addTestsToRun(this.dto.controllerId, this.dto.id, chain);
Expand Down
27 changes: 27 additions & 0 deletions src/vs/workbench/test/browser/api/extHostTesting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,5 +646,32 @@ suite('ExtHost Testing', () => {
undefined,
]]);
});

test('sets state of test with identical local IDs (#131827)', () => {
const testA = single.root.children.get('id-a');
const testB = single.root.children.get('id-b');
const childA = new TestItemImpl('ctrlId', 'id-child', 'child', undefined);
testA!.children.replace([childA]);
const childB = new TestItemImpl('ctrlId', 'id-child', 'child', undefined);
testB!.children.replace([childB]);

const task1 = c.createTestRun('ctrl', single, {}, 'hello world', false);
const tracker = Iterable.first(c.trackers)!;

task1.passed(childA);
task1.passed(childB);
assert.deepStrictEqual(proxy.$addTestsToRun.args, [
[
'ctrl',
tracker.id,
[single.root, testA, childA].map(t => convert.TestItem.from(t as TestItemImpl)),
],
[
'ctrl',
tracker.id,
[single.root, testB, childB].map(t => convert.TestItem.from(t as TestItemImpl)),
],
]);
});
});
});

0 comments on commit f3fbecd

Please sign in to comment.