Skip to content

Commit 9d422d2

Browse files
Evan-spconnor4312
andauthored
Distinguish testing decoration labels (microsoft#155433)
* Distinguish testing decoration labels * fixup! tweak to avoid prototype issues Co-authored-by: Connor Peet <[email protected]>
1 parent 7163116 commit 9d422d2

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/vs/workbench/contrib/testing/browser/testingDecorations.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,39 @@ class MultiRunTestDecoration extends RunTestDecoration implements ITestDecoratio
815815
allActions.push(new Action('testing.gutter.debugAll', localize('debug all test', 'Debug All Tests'), undefined, undefined, () => this.defaultDebug()));
816816
}
817817

818+
const testItems = this.tests.map(testItem => ({
819+
currentLabel: testItem.test.item.label,
820+
testItem,
821+
parent: testItem.test.parent,
822+
}));
823+
824+
const getLabelConflicts = (tests: typeof testItems) => {
825+
const labelCount = new Map<string, number>();
826+
for (const test of tests) {
827+
labelCount.set(test.currentLabel, (labelCount.get(test.currentLabel) || 0) + 1);
828+
}
829+
830+
return tests.filter(e => labelCount.get(e.currentLabel)! > 1);
831+
};
832+
833+
let conflicts, hasParent = true;
834+
while ((conflicts = getLabelConflicts(testItems)).length && hasParent) {
835+
for (const conflict of conflicts) {
836+
if (conflict.parent) {
837+
const parent = this.testService.collection.getNodeById(conflict.parent);
838+
conflict.currentLabel = parent?.item.label + ' > ' + conflict.currentLabel;
839+
conflict.parent = parent?.parent ? parent.parent : null;
840+
} else {
841+
hasParent = false;
842+
}
843+
}
844+
}
845+
818846
const disposable = new DisposableStore();
819-
const testSubmenus = this.tests.map(({ test, resultItem }) => {
820-
const actions = this.getTestContextMenuActions(test, resultItem);
847+
const testSubmenus = testItems.map(({ currentLabel, testItem }) => {
848+
const actions = this.getTestContextMenuActions(testItem.test, testItem.resultItem);
821849
disposable.add(actions);
822-
return new SubmenuAction(test.item.extId, stripIcons(test.item.label), actions.object);
850+
return new SubmenuAction(testItem.test.item.extId, stripIcons(currentLabel), actions.object);
823851
});
824852

825853
return { object: Separator.join(allActions, testSubmenus), dispose: () => disposable.dispose() };

0 commit comments

Comments
 (0)