Remove unneeded test hooks and tests due to behavior change in .NET Core (#4200)

This commit is contained in:
jeffbi 2017-07-08 15:18:48 -07:00 committed by Dongbo Wang
parent 23c639149d
commit a9b8e98449
3 changed files with 0 additions and 63 deletions

View File

@ -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;
/// <summary>This member is used for internal test purposes.</summary>
public static void SetTestHook(string property, bool value)
{

View File

@ -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;

View File

@ -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' {