Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2063,9 +2063,9 @@ function script:Write-Log
[ValidateNotNullOrEmpty()]
[string] $message,

[switch] $error
[switch] $isError
)
if ($error)
if ($isError)
{
Write-Host -Foreground Red $message
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ ZoneId=$FileType

function Test-RemoteSignedExecutionPolicy {

param($testScript, $expected, $error)
param ($testScript, $expected, $errorId)

$TestTypePrefix = "Test 'RemoteSigned' execution policy."

Expand Down Expand Up @@ -806,91 +806,91 @@ ZoneId=$FileType
$actualError = $result."exception"

$actualResult | Should -Be $expected
$actualError | Should -Be $error
$actualError | Should -Be $errorId
}
}
$message = "Hello"
$error = "System.Management.Automation.PSSecurityException"
$errorId = "System.Management.Automation.PSSecurityException"
$testData = @(
@{
testScript = $LocalUnsignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $LocalSignatureCorruptedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $LocalSignedScript
expected = "Hello"
error = $null
errorId = $null
}
@{
testScript = $MyComputerUnsignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $MyComputerSignatureCorruptedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $myComputerSignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $TrustedUnsignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $TrustedSignatureCorruptedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $TrustedSignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $IntranetUnsignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $IntranetSignatureCorruptedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $IntranetSignedScript
expected = $message
error = $null
errorId = $null
}
@{
testScript = $InternetUnsignedScript
expected = $null
error = $error
errorId = $errorId
}
@{
testScript = $InternetSignatureCorruptedScript
expected = $null
error = $error
errorId = $errorId
}
@{
testScript = $UntrustedUnsignedScript
expected = $null
error = $error
errorId = $errorId
}
@{
testScript = $UntrustedSignatureCorruptedScript
expected = $null
error = $error
errorId = $errorId
}
)

Expand All @@ -915,132 +915,132 @@ ZoneId=$FileType

$TestTypePrefix = "Test 'AllSigned' execution policy."

$error = "UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand"
$errorId = "UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand"
$testData = @(
@{
module = "Microsoft.PowerShell.Archive"
error = $null
errorId = $null
}
)

if (Test-CanWriteToPsHome) {
$testData += @(
@{
module = $PSHomeUntrustedModule
error = $error
errorId = $errorId
}
@{
module = $PSHomeUnsignedModule
error = $error
errorId = $errorId
}
)
}

It "$TestTypePrefix Importing <module> Module should throw '<error>'" -TestCases $testData {
param([string]$module, [string]$error)
param ([string]$module, [string]$errorId)
$testScript = {Import-Module -Name $module -Force}
if($error)
if ($errorId)
{
$testScript | Should -Throw -ErrorId $error
$testScript | Should -Throw -ErrorId $errorId
}
else
{
{& $testScript} | Should -Not -Throw
}
}

$error = "UnauthorizedAccess"
$errorId = "UnauthorizedAccess"
$pendingTestData = @(
# The following files are not signed correctly when generated, so we will skip for now
# filed https://github.com/PowerShell/PowerShell/issues/5559
@{
testScript = $MyComputerSignedScript
error = $null
errorId = $null
}
@{
testScript = $UntrustedSignedScript
error = $null
errorId = $null
}
@{
testScript = $TrustedSignedScript
error = $null
errorId = $null
}
@{
testScript = $LocalSignedScript
error = $null
errorId = $null
}
@{
testScript = $IntranetSignedScript
error = $null
errorId = $null
}
@{
testScript = $InternetSignedScript
error = $null
errorId = $null
}
)
It "$TestTypePrefix Running <testScript> Script should throw '<error>'" -TestCases $pendingTestData -Pending {}

$testData = @(
@{
testScript = $InternetSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $InternetUnsignedScript
error = $error
errorId = $errorId
}
@{
testScript = $IntranetSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $IntranetSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $IntranetUnsignedScript
error = $error
errorId = $errorId
}
@{
testScript = $LocalSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $LocalUnsignedScript
error = $error
errorId = $errorId
}
@{
testScript = $TrustedSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $TrustedUnsignedScript
error = $error
errorId = $errorId
}
@{
testScript = $UntrustedSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $UntrustedUnsignedScript
error = $error
errorId = $errorId
}
@{
testScript = $MyComputerSignatureCorruptedScript
error = $error
errorId = $errorId
}
@{
testScript = $MyComputerUnsignedScript
error = $error
errorId = $errorId
}

)
It "$TestTypePrefix Running <testScript> Script should throw '<error>'" -TestCases $testData {
param([string]$testScript, [string]$error)
param ([string]$testScript, [string]$errorId)
$testScript | Should -Exist
if($error)
if ($errorId)
{
{& $testScript} | Should -Throw -ErrorId $error
{& $testScript} | Should -Throw -ErrorId $errorId
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ Describe "Test-Json" -Tags "CI" {
}

It "Test-Json write an error on invalid (<name>) Json against a valid schema" -TestCases @(
@{ name = "type"; json = $invalidTypeInJson; error = "InvalidJsonAgainstSchema,Microsoft.PowerShell.Commands.TestJsonCommand" }
@{ name = "node"; json = $invalidNodeInJson; error = "InvalidJson,Microsoft.PowerShell.Commands.TestJsonCommand" }
@{ name = "type"; json = $invalidTypeInJson; errorId = "InvalidJsonAgainstSchema,Microsoft.PowerShell.Commands.TestJsonCommand" }
@{ name = "node"; json = $invalidNodeInJson; errorId = "InvalidJson,Microsoft.PowerShell.Commands.TestJsonCommand" }
) {
param($json, $error)
param ($json, $errorId)

$errorVar = $null
Test-Json -Json $json -Schema $validSchemaJson -ErrorVariable errorVar -ErrorAction SilentlyContinue

$errorVar.FullyQualifiedErrorId | Should -BeExactly $error
$errorVar.FullyQualifiedErrorId | Should -BeExactly $errorId
}

It "Test-Json return all errors when check invalid Json against a valid schema" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Describe "Alias tests" -Tags "CI" {
[string] $testFile
[string] $expectedError

TestData($name, $file, $error)
TestData($name, $file, $errorId)
{
$this.testName = $name
$this.testFile = $file
$this.expectedError = $error
$this.expectedError = $errorId
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Describe "CliXml test" -Tags "CI" {
[string] $expectedError
[string] $testFile

TestData($name, $file, $inputObj, $error)
TestData($name, $file, $inputObj, $errorId)
{
$this.testName = $name
$this.inputObject = $inputObj
$this.expectedError = $error
$this.expectedError = $errorId
$this.testFile = $file
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/engine/Api/TypeInference.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Describe "Type inference Tests" -tags "CI" {
}

It "Infers type from using statement" {
$res = [AstTypeInference]::InferTypeOf( { $pid = 1; $using:pid }.Ast.EndBlock.Statements[1].PipelineElements[0].Expression)
$res = [AstTypeInference]::InferTypeOf( { $int = 1; $using:int }.Ast.EndBlock.Statements[1].PipelineElements[0].Expression)
$res.Count | Should -Be 1
$res.Name | Should -Be System.Int32
}
Expand Down