-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Remove unnecessary path split in FileSystemProvider.CreateDirectory
#24615
base: master
Are you sure you want to change the base?
Conversation
@@ -1172,6 +1172,11 @@ Describe "Extended FileSystem Item/Content Cmdlet Provider Tests" -Tags "Feature | |||
$result.Name | Should -BeExactly $testDir | |||
} | |||
|
|||
It "Verify Provider Root Directory + Force" { | |||
$result = New-Item -Path . -ItemType Directory -Force |
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 test is passed without the fix.
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.
Hm not sure why would it fail for me then
> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Debian GNU/Linux 12 (bookworm)
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> Invoke-Pester ./test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1 -Name "Extended FileSystem Item/Content Cmdlet Provider Tests"
Starting discovery in 1 files.
Discovery found 154 tests in 59ms.
Running tests.
What if: Performing the operation "Create Directory" on target "Destination: /tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047/testDir".
[-] Extended FileSystem Item/Content Cmdlet Provider Tests.Valdiate New-Item parameters.Verify Provider Root Directory + Force 14ms (13ms|1ms)
Expected strings to be the same, but they were different.
Expected length: 41
Actual length: 48
Strings differ at index 1.
Expected: '/tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047'
But was: '/home/tadas/0abd470a-0b42-49b3-8f36-4bb90f4b5047'
-^
at $result.FullName.TrimEnd('/\') | Should -BeExactly "$TestDrive", /home/tadas/Dev/PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1:1177
at <ScriptBlock>, /home/tadas/Dev/PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1:1177
What if: Performing the operation "Move File" on target "Item: /tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047/testFile.txt Destination: /tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047/movedFile.txt".
What if: Performing the operation "Rename File" on target "Item: /tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047/testFile.txt Destination: /tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047/NewName.txt".
What if: Performing the operation "Remove File" on target "/tmp/0abd470a-0b42-49b3-8f36-4bb90f4b5047/testFile.txt".
What if: Performing the operation "Set Content" on target "Path: TestDrive:/testFile.txt".
Tests completed in 723ms
Tests Passed: 40, Failed: 1, Skipped: 0, Inconclusive: 0, NotRun: 113
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 clear, I run the command in regular session (not in Pester) and it works well. So, it is a question what scenario you are trying to fix.
PR Summary
Remove unnecessary path split in
FileSystemProvider.CreateDirectory
because those parts are not used anywhere and ultimately end up being combined again for theDirectory.CreateDirectory
call.PR Context
Fixes pester/Pester#2258 :
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).