Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ Describe "Set-Location" -Tags "CI" {
$(Get-Location).Path | Should -BeExactly $testPath.FullName
}

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) {
if (-Not (Test-Path "HKCU:\$($folder.Name)")) {
$testFolder = $folder.Name
$foundFolder = $true
break
}
}
$foundFolder | Should -BeTrue
Set-Location HKCU:\
Copy link
Member

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.

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Jun 28, 2018

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. closed.

{ Set-Location ([System.IO.Path]::DirectorySeparatorChar + $testFolder) -ErrorAction Stop } |
Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand"
}

Context 'Set-Location with no arguments' {

It 'Should go to $env:HOME when Set-Location run with no arguments from FileSystem provider' {
Expand Down