From 8fdd68fbaa52cad3147e24381035941628bbdb79 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 29 Sep 2017 14:35:13 -0700 Subject: [PATCH] [feature] (#4954) remove unnecessary error messages from output --- .../Export-Alias.Tests.ps1 | 8 ++++---- .../Import-Alias.Tests.ps1 | 6 +++--- test/powershell/engine/Help/HelpSystem.Tests.ps1 | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Export-Alias.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Export-Alias.Tests.ps1 index 0c3ca50c66..657c8e2d04 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Export-Alias.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Export-Alias.Tests.ps1 @@ -5,8 +5,8 @@ Describe "Export-Alias DRT Unit Tests" -Tags "CI" { $testAliases = "TestAliases" $fulltestpath = Join-Path -Path $testAliasDirectory -ChildPath $testAliases - remove-item alias:abcd* -force - remove-item alias:ijkl* -force + remove-item alias:abcd* -force -ErrorAction SilentlyContinue + remove-item alias:ijkl* -force -ErrorAction SilentlyContinue set-alias abcd01 efgh01 set-alias abcd02 efgh02 set-alias abcd03 efgh03 @@ -18,8 +18,8 @@ Describe "Export-Alias DRT Unit Tests" -Tags "CI" { } AfterAll { - remove-item alias:abcd* -force - remove-item alias:ijkl* -force + remove-item alias:abcd* -force -ErrorAction SilentlyContinue + remove-item alias:ijkl* -force -ErrorAction SilentlyContinue } BeforeEach { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Import-Alias.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Import-Alias.Tests.ps1 index 90329d1935..719f576a36 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Import-Alias.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Import-Alias.Tests.ps1 @@ -5,8 +5,8 @@ Describe "Import-Alias DRT Unit Tests" -Tags "CI" { BeforeEach { New-Item -Path $testAliasDirectory -ItemType Directory -Force - remove-item alias:abcd* -force - remove-item alias:ijkl* -force + remove-item alias:abcd* -force -ErrorAction SilentlyContinue + remove-item alias:ijkl* -force -ErrorAction SilentlyContinue set-alias abcd01 efgh01 set-alias abcd02 efgh02 set-alias abcd03 efgh03 @@ -18,7 +18,7 @@ Describe "Import-Alias DRT Unit Tests" -Tags "CI" { } AfterEach { - Remove-Item -Path $testAliasDirectory -Recurse -Force + Remove-Item -Path $testAliasDirectory -Recurse -Force -ErrorAction SilentlyContinue } It "Import-Alias Resolve To Multiple will throw PSInvalidOperationException" { diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index ee3082a744..e7770e0ff5 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -219,7 +219,7 @@ Describe "Get-Help should find help info within help files" -Tags @('CI', 'Requi { $null = New-Item -ItemType Directory -Path $helpFolderPath -ErrorAction SilentlyContinue } - + try { $null = New-Item -ItemType File -Path $helpFilePath -Value "about_test" -ErrorAction SilentlyContinue @@ -234,11 +234,11 @@ Describe "Get-Help should find help info within help files" -Tags @('CI', 'Requi } Describe "Get-Help should find pattern help files" -Tags "CI" { - - # There is a bug specific to Travis CI that hangs the test if "get-help" is used to search pattern string. This doesn't repro locally. + + # There is a bug specific to Travis CI that hangs the test if "get-help" is used to search pattern string. This doesn't repro locally. # This occurs even if Unix system just returns "Directory.GetFiles(path, pattern);" as the windows' code does. # Since there's currently no way to get the vm from Travis CI and the test PASSES locally on both Ubuntu and MacOS, excluding pattern test under Unix system. - + BeforeAll { $helpFile1 = "about_testCase1.help.txt" $helpFile2 = "about_testCase.2.help.txt" @@ -249,7 +249,7 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { $null = New-Item -ItemType Directory -Path $helpFolderPath -ErrorAction SilentlyContinue -Force # Create at least one help file matches "about*" pattern $null = New-Item -ItemType File -Path $helpFilePath1 -Value "about_test1" -ErrorAction SilentlyContinue - $null = New-Item -ItemType File -Path $helpFilePath2 -Value "about_test2" -ErrorAction SilentlyContinue + $null = New-Item -ItemType File -Path $helpFilePath2 -Value "about_test2" -ErrorAction SilentlyContinue } # Remove the test files @@ -277,9 +277,9 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { Describe "Get-Help should find pattern alias" -Tags "CI" { # Remove test alias AfterAll { - Remove-Item alias:\testAlias1 + Remove-Item alias:\testAlias1 -ErrorAction SilentlyContinue } - + It "Get-Help should find alias as command" { (Get-Help where).Name | Should BeExactly "Where-Object" }