From 139b399223666811a6bddf202792ebb050c474d6 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 13 Oct 2016 11:22:45 -0700 Subject: [PATCH] Fix test failures due to changes in .NET Core and the exclusion of 'Certificate' provider in UNIX PS --- .../Parser/RedirectionOperator.Tests.ps1 | 8 +++++++ .../Get-PSDrive.Tests.ps1 | 21 ++++++++++--------- .../alias.tests.ps1 | 4 ++-- .../clixml.tests.ps1 | 4 ++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 b/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 index 82a79fb7b6..ef420af1d2 100644 --- a/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 +++ b/test/powershell/Language/Parser/RedirectionOperator.Tests.ps1 @@ -47,6 +47,14 @@ Describe "Redirection operator now supports encoding changes" -Tags "CI" { $availableEncodings = (get-command out-file).Parameters["Encoding"].Attributes.ValidValues foreach($encoding in $availableEncodings) { + if ($encoding -eq "default") { + # [System.Text.Encoding]::Default is exposed by 'System.Private.CoreLib.dll' at + # runtime via reflection. However,it isn't exposed in the reference contract of + # 'System.Text.Encoding', and therefore we cannot use 'Encoding.Default' in our + # code. So we need to skip this encoding in the test. + continue + } + # some of the encodings accepted by out-file aren't real, # and out-file has its own translation, so we'll # not do that logic here, but simply ignore those encodings diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-PSDrive.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-PSDrive.Tests.ps1 index 75c9d2ac0a..ceec9a084b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-PSDrive.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-PSDrive.Tests.ps1 @@ -23,17 +23,18 @@ Describe "Get-PSDrive" -Tags "CI" { } It "Should return drive info"{ - (Get-PSDrive Env).Name | Should Be Env - (Get-PSDrive Cert).Root | Should Be \ + (Get-PSDrive Env).Name | Should Be Env + (Get-PSDrive Alias).Name | Should Be Alias - if ($IsWindows) - { - (Get-PSDrive C).Provider.Name | Should Be FileSystem - } - else - { - (Get-PSDrive /).Provider.Name | Should Be FileSystem - } + if ($IsWindows) + { + (Get-PSDrive Cert).Root | Should Be \ + (Get-PSDrive C).Provider.Name | Should Be FileSystem + } + else + { + (Get-PSDrive /).Provider.Name | Should Be FileSystem + } } It "Should be able to access a drive using the PSProvider switch" { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/alias.tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/alias.tests.ps1 index 4317e8d211..75d8272726 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/alias.tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/alias.tests.ps1 @@ -29,7 +29,7 @@ $testCases += [TestData]::new("PS1", $ps1File, [NullString]::Value) $testCases += [TestData]::new("Empty string", "", "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ExportAliasCommand") $testCases += [TestData]::new("Null", [NullString]::Value, "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportAliasCommand") - $testCases += [TestData]::new("Non filesystem provider", 'cert:\alias.ps1', "ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ExportAliasCommand") + $testCases += [TestData]::new("Non filesystem provider", 'env:\alias.ps1', "ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ExportAliasCommand") } $testCases | % { @@ -116,7 +116,7 @@ $testCases = @() $testCases += [TestData]::new("Empty string", "", "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ImportAliasCommand") $testCases += [TestData]::new("Null", [NullString]::Value, "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ImportAliasCommand") - $testCases += [TestData]::new("Non filesystem provider", 'cert:\alias.ps1', "NotSupported,Microsoft.PowerShell.Commands.ImportAliasCommand") + $testCases += [TestData]::new("Non filesystem provider", 'env:\alias.ps1', "NotSupported,Microsoft.PowerShell.Commands.ImportAliasCommand") } $testCases | % { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 index 15477eae9b..fd8fce29f6 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/clixml.tests.ps1 @@ -44,7 +44,7 @@ $testData = @() $testData += [TestData]::new("with path as Null", [NullString]::Value, $gps, "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportClixmlCommand") $testData += [TestData]::new("with path as Empty string", "", $gps, "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ExportClixmlCommand") - $testData += [TestData]::new("with path as non filesystem provider", "cert:\", $gps, "ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ExportClixmlCommand") + $testData += [TestData]::new("with path as non filesystem provider", "env:\", $gps, "ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ExportClixmlCommand") } AfterEach { @@ -132,7 +132,7 @@ $testData = @() $testData += [TestData]::new("with path as Null", [NullString]::Value, $null, "ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ImportClixmlCommand") $testData += [TestData]::new("with path as Empty string", "", $null, "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ImportClixmlCommand") - $testData += [TestData]::new("with path as non filesystem provider", "cert:\", $null, "ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ImportClixmlCommand") + $testData += [TestData]::new("with path as non filesystem provider", "env:\", $null, "ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ImportClixmlCommand") } $testData | % {