diff --git a/appveyor.yml b/appveyor.yml index c33a35031e..a63c3cd455 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,14 +34,15 @@ test_script: $env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Publish)) Write-Host -Foreground Green 'Run CoreCLR tests' $testResultsFile = "$pwd\TestsResults.xml" - & ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Invoke-Pester test/powershell -OutputFormat NUnitXml -OutputFile $testResultsFile" + & ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Invoke-Pester test/powershell -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFile" + (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile)) # # FullCLR $env:FullOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -FullCLR)) Write-Host -Foreground Green 'Run FullCLR tests' $testResultsFileFullCLR = "$pwd\TestsResults.FullCLR.xml" - Start-DevPowerShell -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Invoke-Pester test/fullCLR -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR" + Start-DevPowerShell -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Invoke-Pester test/fullCLR -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR" (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFileFullCLR)) # # Fail the build, if tests failed @@ -57,12 +58,6 @@ test_script: { throw "$($x.'test-results'.failures) tests in test/fullCLR failed" } - # - # Portable module test - Write-Host -Foreground Green 'Test use of cross-platform binary module' - Import-Module ./docs/cmdlet-example/bin/Debug/netstandard1.3/SendGreeting.dll - Send-Greeting -Name World - on_finish: - ps: | diff --git a/docs/cmdlet-example/SendGreeting.Tests.ps1 b/docs/cmdlet-example/SendGreeting.Tests.ps1 index c4390fbe29..039be41eb9 100644 --- a/docs/cmdlet-example/SendGreeting.Tests.ps1 +++ b/docs/cmdlet-example/SendGreeting.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Send-Greeting cmdlet" -Tag 'Slow' { +Describe "Send-Greeting cmdlet" -Tag 'Slow','CI' { It "Should be able build the cmdlet" { Remove-Item -Recurse -Force bin -ErrorAction SilentlyContinue dotnet restore --verbosity Error | Should BeNullOrEmpty diff --git a/test/powershell/Modules/PackageManagement/Nuget.Tests.ps1 b/test/powershell/Modules/PackageManagement/Nuget.Tests.ps1 index 7c3712a1d8..54dd7df371 100644 --- a/test/powershell/Modules/PackageManagement/Nuget.Tests.ps1 +++ b/test/powershell/Modules/PackageManagement/Nuget.Tests.ps1 @@ -281,7 +281,7 @@ Describe "Event Test" -Tags @('BVT', 'DRT') { } } -Describe "Find-Package" -Tags @('BVT', 'DRT'){ +Describe "Find-Package" -Tags @('CI','SLOW'){ it "EXPECTED: Find a package with a location created via new-psdrive" -Skip:(-not $IsWindows) { $Error.Clear() New-PSDrive -Name xx -PSProvider FileSystem -Root $TestDrive -warningaction:silentlycontinue -ea silentlycontinue > $null; find-package -name "fooobarrr" -provider nuget -source xx:\ -warningaction:silentlycontinue -ea silentlycontinue diff --git a/test/powershell/SDK/CmdletExample.Tests.ps1 b/test/powershell/SDK/CmdletExample.Tests.ps1 index 517d7a51a7..4b41f314be 100644 --- a/test/powershell/SDK/CmdletExample.Tests.ps1 +++ b/test/powershell/SDK/CmdletExample.Tests.ps1 @@ -1,9 +1,93 @@ -try { - $enlistmentRoot = git rev-parse --show-toplevel +# Looking at pester internal to get tag filter and ExcludeTagFilter +# This seems like the most stable way to do this +# other options like testing for tags seems more likely to break + +InModuleScope Pester { + Describe 'Getting Tag Filters' -Tag CI { + $global:__PesterTags = $pester.TagFilter + $global:__PesterExcludeTags = $pester.ExcludeTagFilter + } +} +Describe 'SDK Send Greeting Sample Tests' -Tag CI { + + try { + $enlistmentRoot = git rev-parse --show-toplevel + $docLocation = Join-Path -Path $enlistmentRoot -ChildPath '\docs\cmdlet-example' + $testResultPath = Join-Path $TestDrive 'sendgreetingresults.xml' + $sampleCopy = Join-Path $TestDrive 'sendgreeting' + $fullSampleCopyPath = Join-Path $sampleCopy 'cmdlet-example' + $powershell = (Get-Process -id $PID).MainModule.FileName + if(!(Test-Path $sampleCopy)) + { + New-Item -ItemType Directory -Path $sampleCopy + } + + Copy-Item -Recurse -Path $docLocation -Destination $sampleCopy -Force + Get-ChildItem -Recurse $sampleCopy | %{ Write-Verbose "sc: $($_.FullName)"} + + $pesterCommand = "Invoke-Pester $sampleCopy -PassThru" + if($global:__PesterTags) + { + $pesterCommand += " -Tag $(@($global:__PesterTags) -join ',')" + } + + if($global:__PesterExcludeTags) + { + $pesterCommand += " -ExcludeTag $(@($global:__PesterExcludeTags) -join ',')" + } + + $importPesterCommand = 'Import-module Pester' + if($isCore) + { + $importPesterCommand = "Import-Module $(Join-Path -path $PSHOME -child '/Modules/Pester')" + } + + $command = @" +Push-Location -Path $fullSampleCopyPath +$importPesterCommand +$pesterCommand | Export-Clixml -Path $testResultPath +"@ + + Write-Verbose -Message "command: '$command'" + $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) + $encodedCommand = [Convert]::ToBase64String($bytes) + &$powershell -encodedCommand $encodedCommand + + it "Should have test results file" { + $testResultPath | should exist + $script:results = Import-Clixml $testResultPath + } + + it "Should have test results" { + $script:results | should not be BeNullOrEmpty + $script:results.TotalCount | should not BeNullOrEmpty + $script:results.TestResult.Count | should not BeNullOrEmpty + } + + it "Should have no failures" { + $script:results.FailedCount | should be 0 + } + + foreach($testResult in $script:results.TestResult){ + Context "Test $($testResult.Name)" { + it "should have no failure message" { + $testResult.FailureMessage | should BeNullOrEmpty + } + it "should have no stack trace" { + $testResult.StackTrace | should BeNullOrEmpty + } + it "should have no error record" { + $testResult.ErrorRecord | should BeNullOrEmpty + } + it "should have not failed" { + Write-Verbose "Result: $($testResult.Result)" + $testResult.Result | should not be Failed + } + } + } + + } finally { + Pop-Location + } - $docLocation = [io.path]::Combine($enlistmentRoot, "docs","cmdlet-example") - Push-Location $docLocation - ./SendGreeting.Tests.ps1 -} finally { - Pop-Location }