Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-provider: adjust workspace location handling #972

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/test-provider/test-item-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,15 @@ export class WorkspaceRoot extends TestItemDataBase {
);
};
private addPath = (absoluteFileName: string): FolderData | undefined => {
const relativePath = path.relative(this.context.ext.workspace.uri.fsPath, absoluteFileName);
const fs = require('fs');

// On Windows, the workspace URI is not the real resolved path, however, the
// paths returned by the jest cli tool are resolved paths. Explicitly
// resolve the path to ensure that we get the proper relative path. Note
// that we must use `fs.realpath.native` as `fs.realpath` will only
// canonicalise the path, not resolve any path substitutions.
const workspace = fs.realpathSync.native(this.context.ext.workspace.uri.fsPath);
const relativePath = path.relative(workspace, absoluteFileName);
const folders = relativePath.split(path.sep).slice(0, -1);

return folders.reduce(this.addFolder, undefined);
Expand Down