mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix tests to not write errors to console (#13010)
This commit is contained in:
@@ -24,14 +24,14 @@ Describe "Get-FileHash" -Tags "CI" {
|
||||
}
|
||||
|
||||
It "Should write non-terminating error if argument is a folder" {
|
||||
$result = $PSHOME, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable
|
||||
$result = $PSHOME, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable -ErrorAction SilentlyContinue
|
||||
$result.Count | Should -Be 1
|
||||
$errorVariable.FullyQualifiedErrorId | Should -BeExactly "UnauthorizedAccessError,Microsoft.PowerShell.Commands.GetFileHashCommand"
|
||||
}
|
||||
|
||||
It "Should write non-terminating error if a file is locked" -Skip:(-not $IsWindows) {
|
||||
$pagefilePath = (Get-CimInstance -ClassName Win32_PageFileusage).Name
|
||||
$result = $pagefilePath, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable
|
||||
$result = $pagefilePath, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable -ErrorAction SilentlyContinue
|
||||
$result.Count | Should -Be 1
|
||||
$errorVariable.FullyQualifiedErrorId | Should -BeExactly "FileReadError,Microsoft.PowerShell.Commands.GetFileHashCommand"
|
||||
}
|
||||
@@ -89,7 +89,7 @@ Describe "Get-FileHash" -Tags "CI" {
|
||||
$newPath = Get-FileHash -Path $testDocumentCopy | Rename-Item -NewName {$_.Hash} -PassThru
|
||||
$newPath.FullName | Should -Exist
|
||||
|
||||
Remove-Item -Path $testDocumentCopy -Force
|
||||
Remove-Item -Path $testDocumentCopy -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ Describe "Get-RunspaceDebug" -Tags "CI" {
|
||||
|
||||
Context "Check return types of RunspaceDebug" {
|
||||
|
||||
It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" {
|
||||
$rs = Get-RunspaceDebug
|
||||
$rs | Should -Not -BeNullOrEmpty
|
||||
$rs[0] | Should -BeOfType Microsoft.PowerShell.Commands.PSRunspaceDebug
|
||||
}
|
||||
It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" {
|
||||
$rs = Get-RunspaceDebug -ErrorAction SilentlyContinue
|
||||
$rs | Should -Not -BeNullOrEmpty
|
||||
$rs[0] | Should -BeOfType Microsoft.PowerShell.Commands.PSRunspaceDebug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user