testing: fixes if no document hierarchy is provided

This commit is contained in:
Connor Peet
2021-02-22 15:23:02 -08:00
parent e4a082af7f
commit 9cd0f2e8a4
2 changed files with 19 additions and 5 deletions
+12 -5
View File
@@ -267,11 +267,8 @@ export class ExtHostTesting implements ExtHostTestingShape {
} }
} }
const internal = this.getInternalTestForReference(test); this.flushCollectionDiffs();
if (internal) { this.proxy.$updateTestStateInRun(req.runId, test.id, TestState.from(state));
this.flushCollectionDiffs();
this.proxy.$updateTestStateInRun(req.runId, internal.item.extId, TestState.from(state));
}
}, },
tests: includeTests.map(t => TestItemFilteredWrapper.unwrap(t.actual)), tests: includeTests.map(t => TestItemFilteredWrapper.unwrap(t.actual)),
exclude: excludeTests.map(([, t]) => TestItemFilteredWrapper.unwrap(t.actual)), exclude: excludeTests.map(([, t]) => TestItemFilteredWrapper.unwrap(t.actual)),
@@ -331,6 +328,14 @@ export class ExtHostTesting implements ExtHostTestingShape {
return; return;
} }
const onDidInvalidateTest = new Emitter<vscode.TestItem>();
workspaceHierarchy.onDidInvalidateTest?.(node => {
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(node, document);
if (wrapper.hasNodeMatchingFilter) {
onDidInvalidateTest.fire(wrapper);
}
});
const onDidChangeTest = new Emitter<vscode.TestItem>(); const onDidChangeTest = new Emitter<vscode.TestItem>();
workspaceHierarchy.onDidChangeTest(node => { workspaceHierarchy.onDidChangeTest(node => {
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(node, document); const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(node, document);
@@ -373,6 +378,8 @@ export class ExtHostTesting implements ExtHostTestingShape {
onDidChangeTest.dispose(); onDidChangeTest.dispose();
TestItemFilteredWrapper.removeFilter(document); TestItemFilteredWrapper.removeFilter(document);
}, },
discoveredInitialTests: workspaceHierarchy.discoveredInitialTests,
onDidInvalidateTest: onDidInvalidateTest.event,
onDidChangeTest: onDidChangeTest.event onDidChangeTest: onDidChangeTest.event
}; };
} }
@@ -271,6 +271,13 @@ export class SingleUseTestCollection implements IDisposable {
const deletedChildren = internal.previousChildren; const deletedChildren = internal.previousChildren;
const currentChildren = new Set<string>(); const currentChildren = new Set<string>();
for (const child of actual.children) { for (const child of actual.children) {
// If a child was recreated, delete the old object before calling
// addItem() anew.
const previous = this.testIdToInternal.object.get(child.id);
if (previous && previous.actual !== child) {
this.removeItembyId(child.id);
}
const c = this.addItem(child, providerId, internal.item.extId); const c = this.addItem(child, providerId, internal.item.extId);
deletedChildren.delete(c.item.extId); deletedChildren.delete(c.item.extId);
currentChildren.add(c.item.extId); currentChildren.add(c.item.extId);