-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enhance Remove-Item to work with OneDrive #14902
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 all commits
731ab10
2596388
8c81afe
ec6ddd2
f339140
cd7f760
382d5a6
41df0b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -563,7 +563,7 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" | |
| $omegaFile1 = Join-Path $omegaDir "OmegaFile1" | ||
| $omegaFile2 = Join-Path $omegaDir "OmegaFile2" | ||
| $betaDir = Join-Path $alphaDir "sub-Beta" | ||
| $betaLink = Join-Path $alphaDir "link-Beta" | ||
| $betaLink = Join-Path $alphaDir "link-Beta" # Don't change! The name is hard-coded in PowerShell for OneDrive tests. | ||
| $betaFile1 = Join-Path $betaDir "BetaFile1.txt" | ||
| $betaFile2 = Join-Path $betaDir "BetaFile2.txt" | ||
| $betaFile3 = Join-Path $betaDir "BetaFile3.txt" | ||
|
|
@@ -616,6 +616,31 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" | |
| $ci = Get-ChildItem $alphaLink -Recurse -Name | ||
| $ci.Count | Should -BeExactly 7 # returns 10 - unexpectly recurce in link-alpha\link-Beta. See https://github.com/PowerShell/PowerShell/issues/11614 | ||
| } | ||
| It "Get-ChildItem will recurse into emulated OneDrive directory" -Skip:(-not $IsWindows) { | ||
iSazonov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # The test depends on the files created in previous test: | ||
| #New-Item -ItemType SymbolicLink -Path $alphaLink -Value $alphaDir | ||
| #New-Item -ItemType SymbolicLink -Path $betaLink -Value $betaDir | ||
|
Comment on lines
+621
to
+622
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. Can we remove these?
Collaborator
Author
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. I keep the file style.
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. The file style is to keep commented out lines of code?
Collaborator
Author
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. Full text is: The same style is in previous test, and two tests above too.
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. It seems like that should be in a
Collaborator
Author
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. As I pointed "It's not very good that the tests depend on each other, but this has already been." I would not want to redo all these tests now. It is better to do in separate PR. See also #14902 (comment) I opened #15178 for tracking. |
||
|
|
||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestOn', $true) | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestRecurseOn', $false) | ||
|
Comment on lines
+624
to
+625
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. This is also the kind of thing that would be better in a |
||
| try | ||
| { | ||
| # '$betaDir' is a symlink - we don't follow symlinks | ||
| # This emulates PowerShell 6.2 and below behavior. | ||
| $ci = Get-ChildItem -Path $alphaDir -Recurse | ||
| $ci.Count | Should -BeExactly 7 | ||
|
|
||
| # Now we follow the symlink like on OneDrive. | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestRecurseOn', $true) | ||
| $ci = Get-ChildItem -Path $alphaDir -Recurse | ||
| $ci.Count | Should -BeExactly 10 | ||
| } | ||
| finally | ||
| { | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestRecurseOn', $false) | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestOn', $false) | ||
| } | ||
| } | ||
| It "Get-ChildItem will recurse into symlinks given -FollowSymlink, avoiding link loops" { | ||
| New-Item -ItemType Directory -Path $gammaDir | ||
| New-Item -ItemType SymbolicLink -Path $uponeLink -Value $betaDir | ||
|
|
@@ -737,6 +762,42 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" | |
| $childB.Count | Should -BeExactly $childA.Count | ||
| $childB.Name | Should -BeExactly $childA.Name | ||
| } | ||
| It "Remove-Item will recurse into emulated OneDrive directory" -Skip:(-not $IsWindows) { | ||
| $alphaDir = Join-Path $TestDrive "sub-alpha2" | ||
| $alphaLink = Join-Path $TestDrive "link-alpha2" | ||
| $alphaFile1 = Join-Path $alphaDir "AlphaFile1.txt" | ||
| $betaDir = Join-Path $alphaDir "sub-Beta" | ||
| $betaLink = Join-Path $alphaDir "link-Beta" | ||
| $betaFile1 = Join-Path $betaDir "BetaFile1.txt" | ||
|
|
||
| New-Item -ItemType Directory -Path $alphaDir > $null | ||
| New-Item -ItemType File -Path $alphaFile1 > $null | ||
| New-Item -ItemType Directory -Path $betaDir > $null | ||
| New-Item -ItemType File -Path $betaFile1 > $null | ||
|
|
||
| New-Item -ItemType SymbolicLink -Path $alphaLink -Value $alphaDir > $null | ||
| New-Item -ItemType SymbolicLink -Path $betaLink -Value $betaDir > $null | ||
|
|
||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestOn', $true) | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestRecurseOn', $false) | ||
| try | ||
| { | ||
| # With the test hook turned on we don't remove '$betaDir' symlink. | ||
| # This emulates PowerShell 7.1 and below behavior. | ||
| { Remove-Item -Path $betaLink -Recurse -ErrorAction Stop } | Should -Throw -ErrorId "DeleteSymbolicLinkFailed,Microsoft.PowerShell.Commands.RemoveItemCommand" | ||
|
|
||
| # Now we emulate OneDrive and follow the symlink like on OneDrive. | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestRecurseOn', $true) | ||
| Remove-Item -Path $betaLink -Recurse | ||
| Test-Path -Path $betaLink | Should -BeFalse | ||
| } | ||
| finally | ||
| { | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestRecurseOn', $false) | ||
| [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('OneDriveTestOn', $false) | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.