Skip to content

Commit

Permalink
testing: fix test document filter not working with parent dirs on win…
Browse files Browse the repository at this point in the history
…dows

For #128824
  • Loading branch information
connor4312 committed Jul 29, 2021
1 parent 57cbf30 commit 24ae09b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/vs/workbench/contrib/testing/browser/testingExplorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ const enum FilterResult {
Include,
}

const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri: URI | string, fromNode?: string) => {
testUri = testUri.toString();
const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri: URI, fromNode?: string) => {
const fsPath = testUri.fsPath;

const queue: Iterable<string>[] = [fromNode ? [fromNode] : collection.rootIds];
while (queue.length) {
Expand All @@ -753,7 +753,7 @@ const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri:
continue;
}

if (extpath.isEqualOrParent(testUri, node.item.uri.toString())) {
if (extpath.isEqualOrParent(fsPath, node.item.uri.fsPath)) {
return true;
}
}
Expand All @@ -765,7 +765,7 @@ const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri:
class TestsFilter implements ITreeFilter<TestExplorerTreeElement> {
private lastText?: string;
private filters: [include: boolean, value: string][] | undefined;
private documentUri: string | undefined;
private documentUri: URI | undefined;

constructor(
private readonly collection: IMainThreadTestCollection,
Expand Down Expand Up @@ -826,7 +826,7 @@ class TestsFilter implements ITreeFilter<TestExplorerTreeElement> {
}

public filterToDocumentUri(uri: URI | undefined) {
this.documentUri = uri?.toString();
this.documentUri = uri;
}

private testState(element: TestItemTreeElement): FilterResult {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/testing/common/testService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ export const getAllTestsInHierarchy = async (collection: IMainThreadTestCollecti
* in strictly descending order.
*/
export const testsInFile = async function* (collection: IMainThreadTestCollection, uri: URI): AsyncIterable<IncrementalTestCollectionItem> {
const demandUriStr = uri.toString();
const demandFsPath = uri.fsPath;
for (const test of collection.all) {
if (!test.item.uri) {
continue;
}

const itemUriStr = test.item.uri.toString();
if (itemUriStr === demandUriStr) {
const itemFsPath = test.item.uri.fsPath;
if (itemFsPath === demandFsPath) {
yield test;
}

if (extpath.isEqualOrParent(demandUriStr, itemUriStr) && test.expand === TestItemExpandState.Expandable) {
if (extpath.isEqualOrParent(demandFsPath, itemFsPath) && test.expand === TestItemExpandState.Expandable) {
await collection.expand(test.item.extId, 1);
}
}
Expand Down

0 comments on commit 24ae09b

Please sign in to comment.