From a9b8e984495c4a80450ce399acfe38af50912817 Mon Sep 17 00:00:00 2001 From: jeffbi Date: Sat, 8 Jul 2017 15:18:48 -0700 Subject: [PATCH] Remove unneeded test hooks and tests due to behavior change in .NET Core (#4200) --- .../engine/Utils.cs | 5 --- .../namespaces/FileSystemProvider.cs | 18 --------- .../Get-ChildItem.Tests.ps1 | 40 ------------------- 3 files changed, 63 deletions(-) diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 5888155542..f8d7c03f1b 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1589,11 +1589,6 @@ namespace System.Management.Automation.Internal // Simulate 'System.Diagnostics.Stopwatch.IsHighResolution is false' to test Get-Uptime throw internal static bool StopwatchIsNotHighResolution; - // Used in the FileSystemProvider to simulate deleting a file during enumeration in Get-ChildItem - internal static bool GciEnumerationActionDelete = false; - // Used in the FileSystemProvider to simulate renaming a file during enumeration in Get-ChildItem - internal static bool GciEnumerationActionRename = false; - /// This member is used for internal test purposes. public static void SetTestHook(string property, bool value) { diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 08a7bdb7a0..123936bead 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -1689,24 +1689,6 @@ namespace Microsoft.PowerShell.Commands return; } - // Internal test code, run only if one of the - // 'GciEnumerationAction' test hooks are set. - if (InternalTestHooks.GciEnumerationActionDelete) - { - if (string.Equals(filesystemInfo.Name, "c283d143-2116-4809-bf11-4f7d61613f92", StringComparison.InvariantCulture)) - { - File.Delete(filesystemInfo.FullName); - } - } - else if (InternalTestHooks.GciEnumerationActionRename) - { - if (string.Equals(filesystemInfo.Name, "B1B691A9-B7B1-4584-AED7-5259511BEEC4", StringComparison.InvariantCulture)) - { - var newFullName = Path.Combine(directory.FullName, "77efd2bb-92aa-4ad3-979a-18936a4bd565"); - File.Move(filesystemInfo.FullName, newFullName); - } - } - try { bool attributeFilter = true; diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 index c634bf6a17..85815393cb 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 @@ -66,46 +66,6 @@ Describe "Get-ChildItem" -Tags "CI" { $file.Count | Should be 1 $file.Name | Should be $item_F } - # Test is pending on Unix platforms because of a behavior change in the latest .NET Core. - # See https://github.com/dotnet/corefx/issues/20456 for more information. - It "Should continue enumerating a directory when a contained item is deleted" -Pending:(!$IsWindows) { - $Error.Clear() - [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("GciEnumerationActionDelete", $true) - $result = Get-ChildItem -Path $TestDrive -ErrorAction SilentlyContinue - [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("GciEnumerationActionDelete", $false) - if ($IsWindows) - { - $Error.Count | Should BeExactly 0 - $result.Count | Should BeExactly 5 - } - else - { - $Error.Count | Should BeExactly 1 - $Error[0].FullyQualifiedErrorId | Should BeExactly "DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand" - $Error[0].Exception | Should BeOfType System.Io.FileNotFoundException - $result.Count | Should BeExactly 4 - } - } - # Test is pending on Unix platforms because of a behavior change in the latest .NET Core. - # See https://github.com/dotnet/corefx/issues/20456 for more information. - It "Should continue enumerating a directory when a contained item is renamed" -Pending:(!$IsWindows) { - $Error.Clear() - [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("GciEnumerationActionRename", $true) - $result = Get-ChildItem -Path $TestDrive -ErrorAction SilentlyContinue - [System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("GciEnumerationActionRename", $false) - if ($IsWindows) - { - $Error.Count | Should BeExactly 0 - $result.Count | Should BeExactly 4 - } - else - { - $Error.Count | Should BeExactly 1 - $Error[0].FullyQualifiedErrorId | Should BeExactly "DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand" - $Error[0].Exception | Should BeOfType System.Io.FileNotFoundException - $result.Count | Should BeExactly 3 - } - } } Context 'Env: Provider' {