From a784149b36bbb7122580b4819396787834d2b799 Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 25 Jul 2016 17:43:28 -0700 Subject: [PATCH] all tests are now marked with proper tag also, update build.psm1 to be more flexible --- build.psm1 | 17 +++++++++++++++-- test/powershell/Host/Base-Directory.Tests.ps1 | 2 +- test/powershell/Host/Read-Host.Tests.ps1 | 2 +- .../Scripting.Classes.Exceptions.Tests.ps1 | 2 +- .../Language/CompletionTestSupport.psm1 | 2 +- .../PackageManagement/Get-Package.Tests.ps1 | 2 +- .../Get-PackageProvider.Tests.ps1 | 2 +- test/powershell/enginecore/Parser.Test.ps1 | 4 ++-- 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/build.psm1 b/build.psm1 index 101fb8b0072..de009003476 100644 --- a/build.psm1 +++ b/build.psm1 @@ -467,11 +467,24 @@ function Get-PSOutput { function Start-PSPester { [CmdletBinding()]param( - [string]$Flags = "-ExcludeTag 'Slow' -Tag 'CI' -EnableExit -OutputFile pester-tests.xml -OutputFormat NUnitXml", + [string]$OutputFormat = "NUnitXml", + [string]$OutputFile = "pester-tests.xml", + [switch]$DisableExit, + [string[]]$ExcludeTag = "Slow", + [string[]]$Tag = "CI", [string]$Path = "$PSScriptRoot/test/powershell" ) + $tagString = "-outputFormat ${OutputFormat} -outputFile ${outputFile} " + if ( ! $DisableExit ) { $tagString += " -EnableExit" } + if ( $ExcludeTag ) { $tagString += " -ExcludeTag @('" + (${ExcludeTag} -join "','") + "')" } + if ( $Tag ) { $tagString += " -Tag @('" + (${Tag} -join "','") + "')" } - & (Get-PSOutput) -noprofile -c "Import-Module '$PSHOME/Modules/Pester'; Invoke-Pester $Flags $Path" + $powershell = get-psoutput + $psdir = [io.path]::GetDirectoryName($powershell) + $moduleDir = [io.path]::Combine($psdir,"Modules","Pester") + + Write-Verbose "Import-Module '$moduleDir'; Invoke-Pester $tagString $Path" + & (Get-PSOutput) -noprofile -c "Import-Module '$moduleDir'; Invoke-Pester $tagString $Path" if ($LASTEXITCODE -ne 0) { throw "$LASTEXITCODE Pester tests failed" } diff --git a/test/powershell/Host/Base-Directory.Tests.ps1 b/test/powershell/Host/Base-Directory.Tests.ps1 index df3b6521735..11811fdb358 100644 --- a/test/powershell/Host/Base-Directory.Tests.ps1 +++ b/test/powershell/Host/Base-Directory.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Configuration file locations" -tags "CI" { +Describe "Configuration file locations" -tags "CI","Slow" { BeforeAll { $powershell = Join-Path -Path $PsHome -ChildPath "powershell" diff --git a/test/powershell/Host/Read-Host.Tests.ps1 b/test/powershell/Host/Read-Host.Tests.ps1 index 55b262f8519..ca31ed388d4 100644 --- a/test/powershell/Host/Read-Host.Tests.ps1 +++ b/test/powershell/Host/Read-Host.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Read-Host" -Tags "CI" { +Describe "Read-Host" -Tags "Slow","Feature" { Context "[Console]::ReadKey() implementation on non-Windows" { BeforeAll { $powershell = Join-Path -Path $PsHome -ChildPath "powershell" diff --git a/test/powershell/Language/Classes/Scripting.Classes.Exceptions.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.Exceptions.Tests.ps1 index ca772f553e3..d79f74a6415 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.Exceptions.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.Exceptions.Tests.ps1 @@ -1,4 +1,4 @@ -Describe 'Exceptions flow for classes' -Tags "DRT" { +Describe 'Exceptions flow for classes' -Tags "CI" { $canaryHashtable = @{} diff --git a/test/powershell/Language/CompletionTestSupport.psm1 b/test/powershell/Language/CompletionTestSupport.psm1 index aeaa12da5ad..bbda7ac5890 100644 --- a/test/powershell/Language/CompletionTestSupport.psm1 +++ b/test/powershell/Language/CompletionTestSupport.psm1 @@ -98,7 +98,7 @@ function Test-Completions { foreach ($test in $TestCases) { - Describe $test.Description { + Describe $test.Description -Tags "CI" { $hash = $Test.TestInput $results = Get-Completions @hash diff --git a/test/powershell/Modules/PackageManagement/Get-Package.Tests.ps1 b/test/powershell/Modules/PackageManagement/Get-Package.Tests.ps1 index 650330b0440..371338a5935 100644 --- a/test/powershell/Modules/PackageManagement/Get-Package.Tests.ps1 +++ b/test/powershell/Modules/PackageManagement/Get-Package.Tests.ps1 @@ -18,7 +18,7 @@ $source = "http://www.nuget.org/api/v2/" # Actual Tests: -Describe "Get-package" -Tags @('BVT', 'DRT'){ +Describe "Get-package" -Tags "Feature" { # make sure that packagemanagement is loaded It "EXPECTED: Get-package accepts array of strings for -providername parameter" -Skip { $x = (get-package -providername Programs,Msi) diff --git a/test/powershell/Modules/PackageManagement/Get-PackageProvider.Tests.ps1 b/test/powershell/Modules/PackageManagement/Get-PackageProvider.Tests.ps1 index 7a1f79558b5..275d04dc730 100644 --- a/test/powershell/Modules/PackageManagement/Get-PackageProvider.Tests.ps1 +++ b/test/powershell/Modules/PackageManagement/Get-PackageProvider.Tests.ps1 @@ -72,7 +72,7 @@ Describe "get-packageprovider" -Tags "CI" { } -Describe "Get-PackageProvider with list" Tags "CI" { +Describe "Get-PackageProvider with list" -Tags "CI" { It "lists package providers installed" { $x = (Get-PackageProvider).Count -gt 1 | should be $true diff --git a/test/powershell/enginecore/Parser.Test.ps1 b/test/powershell/enginecore/Parser.Test.ps1 index df22e5f143e..24d30f4a560 100644 --- a/test/powershell/enginecore/Parser.Test.ps1 +++ b/test/powershell/enginecore/Parser.Test.ps1 @@ -1,4 +1,4 @@ -Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)" { +Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)" -Tags "CI" { BeforeAll { $functionDefinitionFile = Join-Path -Path $TestDrive -ChildPath "functionDefinition.ps1" $functionDefinition = @' @@ -825,4 +825,4 @@ Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)" $_.FullyQualifiedErrorId | should be "ParseException" } } -} \ No newline at end of file +}