testing: peek failure message for any child of tests in open files
Fixes #125224
This commit is contained in:
parent
11d9ddbfbd
commit
711a920e93
5 changed files with 50 additions and 34 deletions
|
@ -30,7 +30,7 @@ export namespace Iterable {
|
|||
return iterable[Symbol.iterator]().next().value;
|
||||
}
|
||||
|
||||
export function some<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): boolean {
|
||||
export function some<T>(iterable: Iterable<T>, predicate: (t: T) => unknown): boolean {
|
||||
for (const element of iterable) {
|
||||
if (predicate(element)) {
|
||||
return true;
|
||||
|
|
|
@ -64,7 +64,7 @@ import { TestingContextKeys } from 'vs/workbench/contrib/testing/common/testingC
|
|||
import { ITestingPeekOpener } from 'vs/workbench/contrib/testing/common/testingPeekOpener';
|
||||
import { isFailedState } from 'vs/workbench/contrib/testing/common/testingStates';
|
||||
import { buildTestUri, ParsedTestUri, parseTestUri, TestUriType } from 'vs/workbench/contrib/testing/common/testingUri';
|
||||
import { getPathForTestInResult, ITestResult, maxCountPriority, TestResultItemChange, TestResultItemChangeReason } from 'vs/workbench/contrib/testing/common/testResult';
|
||||
import { getPathForTestInResult, ITestResult, maxCountPriority, resultItemParents, TestResultItemChange, TestResultItemChangeReason } from 'vs/workbench/contrib/testing/common/testResult';
|
||||
import { ITestResultService, ResultChangeEvent } from 'vs/workbench/contrib/testing/common/testResultService';
|
||||
import { getAllTestsInHierarchy, ITestService } from 'vs/workbench/contrib/testing/common/testService';
|
||||
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
@ -196,9 +196,11 @@ export class TestingPeekOpener extends Disposable implements ITestingPeekOpener
|
|||
|
||||
// don't show the peek if the user asked to only auto-open peeks for visible tests,
|
||||
// and this test is not in any of the editors' models.
|
||||
const testUri = evt.item.item.uri?.toString();
|
||||
if (cfg === AutoOpenPeekViewWhen.FailureVisible && (!testUri || !editors.some(e => e.getModel()?.uri.toString() === testUri))) {
|
||||
return;
|
||||
if (cfg === AutoOpenPeekViewWhen.FailureVisible) {
|
||||
const editorUris = new Set(editors.map(e => e.getModel()?.uri.toString()));
|
||||
if (!Iterable.some(resultItemParents(evt.result, evt.item), i => i.item.uri && editorUris.has(i.item.uri.toString()))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const controllers = editors.map(TestingOutputPeekController.get);
|
||||
|
@ -912,20 +914,12 @@ export class TestCaseElement implements ITreeElement {
|
|||
private readonly results: ITestResult,
|
||||
public readonly test: TestResultItem,
|
||||
) {
|
||||
for (const parent of this.parents()) {
|
||||
this.description = this.description
|
||||
? parent.item.label + flatTestItemDelimiter + this.description
|
||||
: parent.item.label;
|
||||
}
|
||||
}
|
||||
|
||||
private *parents() {
|
||||
for (
|
||||
let parent = this.test.parent && this.results.getStateById(this.test.parent);
|
||||
parent;
|
||||
parent = parent.parent && this.results.getStateById(parent.parent)
|
||||
) {
|
||||
yield parent;
|
||||
for (const parent of resultItemParents(results, test)) {
|
||||
if (parent !== test) {
|
||||
this.description = this.description
|
||||
? parent.item.label + flatTestItemDelimiter + this.description
|
||||
: parent.item.label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,19 +69,21 @@ export interface ITestResult {
|
|||
toJSON(): ISerializedTestResults | undefined;
|
||||
}
|
||||
|
||||
export const getPathForTestInResult = (test: TestResultItem, results: ITestResult): TestIdPath => {
|
||||
const path = [test];
|
||||
while (true) {
|
||||
const parentId = path[0].parent;
|
||||
const parent = parentId && results.getStateById(parentId);
|
||||
if (!parent) {
|
||||
break;
|
||||
}
|
||||
export const resultItemParents = function* (results: ITestResult, item: TestResultItem) {
|
||||
let i: TestResultItem | undefined = item;
|
||||
while (i) {
|
||||
yield i;
|
||||
i = i.parent ? results.getStateById(i.parent) : undefined;
|
||||
}
|
||||
};
|
||||
|
||||
path.unshift(parent);
|
||||
export const getPathForTestInResult = (test: TestResultItem, results: ITestResult): TestIdPath => {
|
||||
const path: TestIdPath = [];
|
||||
for (const node of resultItemParents(results, test)) {
|
||||
path.unshift(node.item.extId);
|
||||
}
|
||||
|
||||
return path.map(t => t.item.extId);
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,10 +69,10 @@ export interface IMainThreadTestCollection extends AbstractIncrementalTestCollec
|
|||
* Iterates through the item and its parents to the root.
|
||||
*/
|
||||
export const getCollectionItemParents = function* (collection: IMainThreadTestCollection, item: InternalTestItem) {
|
||||
let p: InternalTestItem | undefined = item;
|
||||
while (p) {
|
||||
yield p;
|
||||
p = p.parent ? collection.getNodeById(p.parent) : undefined;
|
||||
let i: InternalTestItem | undefined = item;
|
||||
while (i) {
|
||||
yield i;
|
||||
i = i.parent ? collection.getNodeById(i.parent) : undefined;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Lazy } from 'vs/base/common/lazy';
|
|||
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ITestTaskState, TestResultItem } from 'vs/workbench/contrib/testing/common/testCollection';
|
||||
import { HydratedTestResult, LiveOutputController, LiveTestResult, makeEmptyCounts, TestResultItemChange, TestResultItemChangeReason } from 'vs/workbench/contrib/testing/common/testResult';
|
||||
import { getPathForTestInResult, HydratedTestResult, LiveOutputController, LiveTestResult, makeEmptyCounts, resultItemParents, TestResultItemChange, TestResultItemChangeReason } from 'vs/workbench/contrib/testing/common/testResult';
|
||||
import { TestResultService } from 'vs/workbench/contrib/testing/common/testResultService';
|
||||
import { InMemoryResultStorage, ITestResultStorage } from 'vs/workbench/contrib/testing/common/testResultStorage';
|
||||
import { Convert, ReExportedTestRunState as TestRunState, TestItemImpl, TestResultState, testStubs, testStubsChain } from 'vs/workbench/contrib/testing/common/testStubs';
|
||||
|
@ -291,4 +291,24 @@ suite('Workbench - Test Results Service', () => {
|
|||
assert.deepStrictEqual(results.results, [r, hydrated1, hydrated2]);
|
||||
});
|
||||
});
|
||||
|
||||
test('resultItemParents', () => {
|
||||
assert.deepStrictEqual([...resultItemParents(r, r.getStateById('id-aa')!)], [
|
||||
r.getStateById('id-aa'),
|
||||
r.getStateById('id-a'),
|
||||
r.getStateById('id-root'),
|
||||
]);
|
||||
|
||||
assert.deepStrictEqual([...resultItemParents(r, r.getStateById('id-root')!)], [
|
||||
r.getStateById('id-root'),
|
||||
]);
|
||||
});
|
||||
|
||||
test('getPathForTestInResult', () => {
|
||||
assert.deepStrictEqual([...getPathForTestInResult(r.getStateById('id-aa')!, r)], [
|
||||
'id-root',
|
||||
'id-a',
|
||||
'id-aa',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue