-
Notifications
You must be signed in to change notification settings - Fork 310
Fix relative uplevels of Symlinked Workspace (Issue #798) #1244
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
base: master
Are you sure you want to change the base?
Fix relative uplevels of Symlinked Workspace (Issue #798) #1244
Conversation
- Add feature flag - Minor refactor: consolidate settings usage - Update documentation - Adjust tests to pass
Pull Request Test Coverage Report for Build 15374238988Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I've left a few comments with minor changes and formatting fixes. Let me know what you think.
@@ -372,6 +372,12 @@ | |||
"type": "boolean", | |||
"default": null, | |||
"scope": "resource" | |||
}, | |||
"jest.trimSymlinks": { | |||
"markdownDescription": "Enable to show test relative to workspace in case of symlinked workspace (or any directory above it). Use if your tests look like in [this image](https://private-user-images.githubusercontent.com/84509513/438940965-b7532345-0332-4265-a108-cac1703de39f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDU5NTQ4MzcsIm5iZiI6MTc0NTk1NDUzNywicGF0aCI6Ii84NDUwOTUxMy80Mzg5NDA5NjUtYjc1MzIzNDUtMDMzMi00MjY1LWExMDgtY2FjMTcwM2RlMzlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA0MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNDI5VDE5MjIxN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwZjEzMWIzZmFkOTBiODllMTU3NjYzMzBhOWIwMGI3MWMwMjI4YzBiYjhlZTA2NzYzOTM4N2NmNGMzMDkxNjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.bWHlErbUnTuXEP2_LPGUbJu509UdNl22Ee73q2f1FXU)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to access this image link. Can you add this image file to the ./images folder and reference it from there.
// In case the workspace root (or one of its ancestors) is a symlink, the relative path is going to resolve | ||
// up-levels (../) until the first common ancestor with the link, resulting in many nodes we can hide from the user. | ||
// In order to hide them, we get the workspaceRoot's "realpath" and use it instead. | ||
uri = vscode.Uri.file(realpathSync(uri!.fsPath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be safe, maybe let's wrap it inside a try/catch block and fall back to the original uri...
TL;DR
Solves the issue reported in #798
Examples of the fix can be found in my comment
Some explanation
While the issue might initially seem rooted in Jest—which reports test results based on the tests’ real paths—it actually makes sense from Jest’s own perspective. Therefore, I implemented the logic in this extension to handle cases where a workspace (or one of its parent directories) is linked, and to hide such links from the Tests Explorer view.
Tests made: