-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add test to verify filesystem provider isn't used when accessing root path in psdrive #7173
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
Add test to verify filesystem provider isn't used when accessing root path in psdrive #7173
Conversation
Now I try |
BrucePay
left a comment
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.
LGTM
| It "Should not use filesystem root folder if not in filesystem provider" -Skip:(!$IsWindows) { | ||
| # find filesystem root folder that doesn't exist in HKCU: | ||
| $foundFolder = $false | ||
| foreach ($folder in (Get-ChildItem "${env:SystemDrive}\" -Directory)) { |
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.
The parens around Get-ChildItem are unnecessary.
| # find filesystem root folder that doesn't exist in HKCU: | ||
| $foundFolder = $false | ||
| foreach ($folder in (Get-ChildItem "${env:SystemDrive}\" -Directory)) { | ||
| if (!(Test-Path "HKCU:\$($folder.Name)")) { |
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 think the convention is to use -not instead of ! simply because it's more visible.
| } | ||
| } | ||
| $foundFolder | Should -BeTrue | ||
| Set-Location HKCU:\ |
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.
Use Push-Location HKCU:\ in try and Pop-Location in finally to reset the current working directory.
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.
This is for Set-Location tests, though. There's a BeforeAll and AfterAll that sets the location back to where it was.
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.
Ok. closed.
|
@adityapatwardhan this needs your review approval. It looks ready for merge. |
|
@adityapatwardhan can you re-review? |
PR Summary
This was an issue introduced by 7459b54.
When in a PSDrive, and you set-location to a root qualified path, it should be based on the current psdrive and not the filesystem. Exception is on non-Windows, all paths start with
/so it's always treated as filesystem.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests