Skip to content

Commit 88973bf

Browse files
authored
Merge pull request PowerShell#1439 from PowerShell/FixMaster
Changed Find-Package test to 'SLOW' to fix master
2 parents c2364b6 + cd9ddb1 commit 88973bf

4 files changed

Lines changed: 97 additions & 18 deletions

File tree

‎appveyor.yml‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ test_script:
3434
$env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Publish))
3535
Write-Host -Foreground Green 'Run CoreCLR tests'
3636
$testResultsFile = "$pwd\TestsResults.xml"
37-
& ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Invoke-Pester test/powershell -OutputFormat NUnitXml -OutputFile $testResultsFile"
37+
& ("$env:CoreOutput\powershell.exe") -noprofile -noninteractive -c "Invoke-Pester test/powershell -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFile"
38+
3839
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
3940
#
4041
# FullCLR
4142
$env:FullOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -FullCLR))
4243
Write-Host -Foreground Green 'Run FullCLR tests'
4344
$testResultsFileFullCLR = "$pwd\TestsResults.FullCLR.xml"
44-
Start-DevPowerShell -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Invoke-Pester test/fullCLR -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR"
45+
Start-DevPowerShell -NoNewWindow -ArgumentList '-noprofile', '-noninteractive' -Command "Invoke-Pester test/fullCLR -ExcludeTag 'Slow' -OutputFormat NUnitXml -OutputFile $testResultsFileFullCLR"
4546
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFileFullCLR))
4647
#
4748
# Fail the build, if tests failed
@@ -57,12 +58,6 @@ test_script:
5758
{
5859
throw "$($x.'test-results'.failures) tests in test/fullCLR failed"
5960
}
60-
#
61-
# Portable module test
62-
Write-Host -Foreground Green 'Test use of cross-platform binary module'
63-
Import-Module ./docs/cmdlet-example/bin/Debug/netstandard1.3/SendGreeting.dll
64-
Send-Greeting -Name World
65-
6661
6762
on_finish:
6863
- ps: |

‎docs/cmdlet-example/SendGreeting.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Describe "Send-Greeting cmdlet" -Tag 'Slow' {
1+
Describe "Send-Greeting cmdlet" -Tag 'Slow','CI' {
22
It "Should be able build the cmdlet" {
33
Remove-Item -Recurse -Force bin -ErrorAction SilentlyContinue
44
dotnet restore --verbosity Error | Should BeNullOrEmpty

‎test/powershell/Modules/PackageManagement/Nuget.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Describe "Event Test" -Tags @('BVT', 'DRT') {
281281
}
282282
}
283283

284-
Describe "Find-Package" -Tags @('BVT', 'DRT'){
284+
Describe "Find-Package" -Tags @('CI','SLOW'){
285285
it "EXPECTED: Find a package with a location created via new-psdrive" -Skip:(-not $IsWindows) {
286286
$Error.Clear()
287287
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
Lines changed: 92 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,93 @@
1-
try {
2-
$enlistmentRoot = git rev-parse --show-toplevel
3-
4-
$docLocation = [io.path]::Combine($enlistmentRoot, "docs","cmdlet-example")
5-
Push-Location $docLocation
6-
./SendGreeting.Tests.ps1
7-
} finally {
8-
Pop-Location
1+
# Looking at pester internal to get tag filter and ExcludeTagFilter
2+
# This seems like the most stable way to do this
3+
# other options like testing for tags seems more likely to break
4+
5+
InModuleScope Pester {
6+
Describe 'Getting Tag Filters' -Tag CI {
7+
$global:__PesterTags = $pester.TagFilter
8+
$global:__PesterExcludeTags = $pester.ExcludeTagFilter
9+
}
10+
}
11+
Describe 'SDK Send Greeting Sample Tests' -Tag CI {
12+
13+
try {
14+
$enlistmentRoot = git rev-parse --show-toplevel
15+
$docLocation = Join-Path -Path $enlistmentRoot -ChildPath '\docs\cmdlet-example'
16+
$testResultPath = Join-Path $TestDrive 'sendgreetingresults.xml'
17+
$sampleCopy = Join-Path $TestDrive 'sendgreeting'
18+
$fullSampleCopyPath = Join-Path $sampleCopy 'cmdlet-example'
19+
$powershell = (Get-Process -id $PID).MainModule.FileName
20+
if(!(Test-Path $sampleCopy))
21+
{
22+
New-Item -ItemType Directory -Path $sampleCopy
23+
}
24+
25+
Copy-Item -Recurse -Path $docLocation -Destination $sampleCopy -Force
26+
Get-ChildItem -Recurse $sampleCopy | %{ Write-Verbose "sc: $($_.FullName)"}
27+
28+
$pesterCommand = "Invoke-Pester $sampleCopy -PassThru"
29+
if($global:__PesterTags)
30+
{
31+
$pesterCommand += " -Tag $(@($global:__PesterTags) -join ',')"
32+
}
33+
34+
if($global:__PesterExcludeTags)
35+
{
36+
$pesterCommand += " -ExcludeTag $(@($global:__PesterExcludeTags) -join ',')"
37+
}
38+
39+
$importPesterCommand = 'Import-module Pester'
40+
if($isCore)
41+
{
42+
$importPesterCommand = "Import-Module $(Join-Path -path $PSHOME -child '/Modules/Pester')"
43+
}
44+
45+
$command = @"
46+
Push-Location -Path $fullSampleCopyPath
47+
$importPesterCommand
48+
$pesterCommand | Export-Clixml -Path $testResultPath
49+
"@
50+
51+
Write-Verbose -Message "command: '$command'"
52+
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
53+
$encodedCommand = [Convert]::ToBase64String($bytes)
54+
&$powershell -encodedCommand $encodedCommand
55+
56+
it "Should have test results file" {
57+
$testResultPath | should exist
58+
$script:results = Import-Clixml $testResultPath
59+
}
60+
61+
it "Should have test results" {
62+
$script:results | should not be BeNullOrEmpty
63+
$script:results.TotalCount | should not BeNullOrEmpty
64+
$script:results.TestResult.Count | should not BeNullOrEmpty
65+
}
66+
67+
it "Should have no failures" {
68+
$script:results.FailedCount | should be 0
69+
}
70+
71+
foreach($testResult in $script:results.TestResult){
72+
Context "Test $($testResult.Name)" {
73+
it "should have no failure message" {
74+
$testResult.FailureMessage | should BeNullOrEmpty
75+
}
76+
it "should have no stack trace" {
77+
$testResult.StackTrace | should BeNullOrEmpty
78+
}
79+
it "should have no error record" {
80+
$testResult.ErrorRecord | should BeNullOrEmpty
81+
}
82+
it "should have not failed" {
83+
Write-Verbose "Result: $($testResult.Result)"
84+
$testResult.Result | should not be Failed
85+
}
86+
}
87+
}
88+
89+
} finally {
90+
Pop-Location
91+
}
92+
993
}

0 commit comments

Comments
 (0)