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
11 changes: 3 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion docs/cmdlet-example/SendGreeting.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
100 changes: 92 additions & 8 deletions test/powershell/SDK/CmdletExample.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,93 @@
try {
$enlistmentRoot = git rev-parse --show-toplevel

$docLocation = [io.path]::Combine($enlistmentRoot, "docs","cmdlet-example")
Push-Location $docLocation
./SendGreeting.Tests.ps1
} finally {
Pop-Location
# 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
}

@JamesWTruher James Truher (JamesWTruher) Jul 20, 2016 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test?

It "Should have no failures" {
$script:results.FailedCount | Should be 0
}
``` #Closed


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
}

}