-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Make Resolve-Path -Relative return useful path when $PWD and -Path is on different drive #5740
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
Changes from 1 commit
6cc21cb
8ee29ba
2529663
e30fbf5
ca6f977
095ccd5
d7d18d9
ee4faa0
9d6c156
dd76ce8
4c5d450
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,23 @@ | ||
| Describe "Resolve-Path returns proper path" -Tag "CI" { | ||
| BeforeAll { | ||
| $driveName = "RvpaTest" | ||
| $root = Join-Path $TestDrive "fakeroot" | ||
| $file = Join-Path $root "file.txt" | ||
| $null = New-Item -Path $root -ItemType Directory -Force | ||
| $null = New-Item -Path $file -ItemType File -Force | ||
| $null = New-PSDrive -Name $driveName -PSProvider FileSystem -Root $root | ||
|
|
||
| $testRoot = Join-Path $TestDrive "" | ||
| $fakeRoot = Join-Path "$driveName`:" "" | ||
|
|
||
| $relCases = @( | ||
| @{ wd = $fakeRoot; target = $testRoot; expected = $testRoot } | ||
| @{ wd = $testRoot; target = Join-Path $fakeRoot "file.txt"; expected = Join-Path "." "fakeroot" "file.txt" } | ||
| ) | ||
| } | ||
| AfterAll { | ||
| Remove-PSDrive -Name $driveName -PSProvider FileSystem | ||
| } | ||
| It "Resolve-Path returns resolved paths" { | ||
| Resolve-Path $TESTDRIVE | Should be "$TESTDRIVE" | ||
| } | ||
|
|
@@ -23,28 +42,11 @@ Describe "Resolve-Path returns proper path" -Tag "CI" { | |
| $result = Resolve-Path -LiteralPath "TestDrive:\\\\\" | ||
| ($result.Path.TrimEnd('/\')) | Should Be "TestDrive:" | ||
| } | ||
| It "Resolve-Path -Relative should return correct path on different drive" { | ||
| $base = Join-Path $TestDrive "ResolvePath.relative" | ||
| $root = Join-Path $base "fakeroot" | ||
| $file = Join-Path $root "file.txt" | ||
| $expectedFilePath = Join-Path "." "fakeroot" "file.txt" | ||
| $driveName = "RvpaTest" | ||
| $null = New-Item -Path $base -ItemType Directory -Force | ||
| $null = New-Item -Path $root -ItemType Directory -Force | ||
| $null = New-Item -Path $file -ItemType File -Force | ||
| $null = New-PSDrive -Name $driveName -PSProvider FileSystem -Root $root | ||
| $driveRoot = Join-Path "$driveName`:" "" | ||
| $driveFile = Join-Path "$driveName`:" "file.txt" | ||
| try { | ||
| Push-Location -Path $driveRoot | ||
| Resolve-Path -Path $base -Relative | Should BeExactly $base | ||
| } | ||
| finally { | ||
| Pop-Location | ||
| } | ||
| It "Resolve-Path -Relative should return correct path on different drive" -TestCases $relCases { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a item for test name in It "Resolve-Path -Relative should return correct path on different drive - " -TestCases $relCases |
||
| param($wd, $target, $expected) | ||
| try { | ||
| Push-Location -Path $base | ||
| Resolve-Path -Path $driveFile -Relative | Should BeExactly $expectedFilePath | ||
| Push-Location -Path $wd | ||
| Resolve-Path -Path $target -Relative | Should BeExactly $expected | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use new syntax |
||
| } | ||
| finally { | ||
| Pop-Location | ||
|
|
||
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.
-PSProvider FileSystemis unnecessary