Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 9823e82

Browse files
authored
Merge pull request #448 from github/build/fix-appveyor-test-reporting
Fix test reporting on AppVeyor
2 parents 53d7ad2 + 9824d79 commit 9823e82

File tree

3 files changed

+91
-61
lines changed

3 files changed

+91
-61
lines changed

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ build_script:
2121
- cmd: msbuild "GitHubVS.sln" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Release /p:DeployExtension=false /verbosity:minimal /p:VisualStudioVersion=14.0
2222
test_script:
2323
- ps: >-
24-
scripts\Run-Nunit.ps1 TrackingCollectionTests 180 Release
24+
scripts\Run-Nunit.ps1 TrackingCollectionTests 180 Release -AppVeyor
2525
26-
scripts\Run-Xunit.ps1 UnitTests 180 Release
26+
scripts\Run-Xunit.ps1 UnitTests 180 Release -AppVeyor

scripts/Run-NUnit.ps1

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,55 @@ Param(
88
[Parameter(Mandatory=$true)]
99
[ValidateNotNullOrEmpty()]
1010
[string]
11-
$project,
12-
[int]$timeoutDuration,
13-
[string]$configuration
11+
$Project,
12+
[int]
13+
$TimeoutDuration,
14+
[string]
15+
$Configuration,
16+
[switch]
17+
$AppVeyor = $false
1418
)
1519

1620
$rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
1721
Push-Location $rootDirectory
18-
$dll = "src\$project\bin\$configuration\$project.dll"
19-
20-
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.Runners.2.6.4\tools
21-
$consoleRunner = Join-Path $nunitDirectory nunit-console-x86.exe
22-
$xml = Join-Path $rootDirectory "nunit-$project.xml"
23-
$outputPath = [System.IO.Path]::GetTempFileName()
24-
25-
$args = "-noshadow", "-xml:$xml", "-framework:net-4.5", "-exclude:Timings", $dll
26-
[object[]] $output = "$consoleRunner " + ($args -join " ")
27-
28-
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
29-
Wait-Process -InputObject $process -Timeout $timeoutDuration -ErrorAction SilentlyContinue
30-
if ($process.HasExited) {
31-
$output += Get-Content $outputPath
32-
$exitCode = $process.ExitCode
22+
$dll = "src\$Project\bin\$Configuration\$Project.dll"
23+
24+
if ($AppVeyor) {
25+
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.Runners.2.6.4\tools
26+
$consoleRunner = Join-Path $nunitDirectory nunit-console-x86.exe
27+
$args = "-noshadow", "-framework:net-4.5", "-exclude:Timings", $dll
28+
[object[]] $output = "$consoleRunner " + ($args -join " ")
29+
& $consoleRunner ($args | %{ "`"$_`"" })
30+
if($LastExitCode -ne 0) {
31+
$host.SetShouldExit($LastExitCode)
32+
}
3333
} else {
34-
$output += "Tests timed out. Backtrace:"
35-
$output += Get-DotNetStack $process.Id
36-
$exitCode = 9999
34+
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.Runners.2.6.4\tools
35+
$consoleRunner = Join-Path $nunitDirectory nunit-console-x86.exe
36+
37+
$xml = Join-Path $rootDirectory "nunit-$Project.xml"
38+
$outputPath = [System.IO.Path]::GetTempFileName()
39+
40+
$args = "-noshadow", "-xml:$xml", "-framework:net-4.5", "-exclude:Timings", $dll
41+
[object[]] $output = "$consoleRunner " + ($args -join " ")
42+
43+
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
44+
Wait-Process -InputObject $process -Timeout $TimeoutDuration -ErrorAction SilentlyContinue
45+
if ($process.HasExited) {
46+
$output += Get-Content $outputPath
47+
$exitCode = $process.ExitCode
48+
} else {
49+
$output += "Tests timed out. Backtrace:"
50+
$output += Get-DotNetStack $process.Id
51+
$exitCode = 9999
52+
}
53+
54+
Stop-Process -InputObject $process
55+
Remove-Item $outputPath
56+
Pop-Location
57+
58+
$result = New-Object System.Object
59+
$result | Add-Member -Type NoteProperty -Name Output -Value $output
60+
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
61+
$result
3762
}
38-
39-
Stop-Process -InputObject $process
40-
Remove-Item $outputPath
41-
Pop-Location
42-
43-
$result = New-Object System.Object
44-
$result | Add-Member -Type NoteProperty -Name Output -Value $output
45-
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
46-
$result
47-

scripts/Run-XUnit.ps1

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,55 @@ Param(
88
[Parameter(Mandatory=$true)]
99
[ValidateNotNullOrEmpty()]
1010
[string]
11-
$project,
12-
[int]$timeoutDuration,
13-
[string]$configuration
11+
$Project,
12+
[int]
13+
$TimeoutDuration,
14+
[string]
15+
$Configuration,
16+
[switch]
17+
$AppVeyor = $false
1418
)
1519

1620
$rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
1721
Push-Location $rootDirectory
1822

19-
$dll = "src\$project\bin\$configuration\$project.dll"
23+
$dll = "src\$Project\bin\$Configuration\$Project.dll"
2024

21-
$xunitDirectory = Join-Path $rootDirectory packages\xunit.runner.console.2.1.0\tools
22-
$consoleRunner = Join-Path $xunitDirectory xunit.console.x86.exe
23-
$xml = Join-Path $rootDirectory "nunit-$project.xml"
24-
$outputPath = [System.IO.Path]::GetTempFileName()
25+
if ($AppVeyor) {
26+
$xunitDirectory = Join-Path $rootDirectory packages\xunit.runner.console.2.1.0\tools
27+
$consoleRunner = Join-Path $xunitDirectory xunit.console.x86.exe
28+
$args = $dll, "-noshadow", "-parallel", "all", "-appveyor"
29+
[object[]] $output = "$consoleRunner " + ($args -join " ")
30+
& $consoleRunner ($args | %{ "`"$_`"" })
31+
if($LastExitCode -ne 0) {
32+
$host.SetShouldExit($LastExitCode)
33+
}
34+
} else {
35+
$xunitDirectory = Join-Path $rootDirectory packages\xunit.runner.console.2.1.0\tools
36+
$consoleRunner = Join-Path $xunitDirectory xunit.console.x86.exe
37+
$xml = Join-Path $rootDirectory "nunit-$Project.xml"
38+
$outputPath = [System.IO.Path]::GetTempFileName()
2539

26-
$args = $dll, "-noshadow", "-xml", $xml, "-parallel", "all"
27-
[object[]] $output = "$consoleRunner " + ($args -join " ")
40+
$args = $dll, "-noshadow", "-xml", $xml, "-parallel", "all"
2841

29-
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
30-
Wait-Process -InputObject $process -Timeout $timeoutDuration -ErrorAction SilentlyContinue
31-
if ($process.HasExited) {
32-
$output += Get-Content $outputPath
33-
$exitCode = $process.ExitCode
34-
} else {
35-
$output += "Tests timed out. Backtrace:"
36-
$output += Get-DotNetStack $process.Id
37-
$exitCode = 9999
42+
[object[]] $output = "$consoleRunner " + ($args -join " ")
43+
44+
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
45+
Wait-Process -InputObject $process -Timeout $TimeoutDuration -ErrorAction SilentlyContinue
46+
if ($process.HasExited) {
47+
$output += Get-Content $outputPath
48+
$exitCode = $process.ExitCode
49+
} else {
50+
$output += "Tests timed out. Backtrace:"
51+
$output += Get-DotNetStack $process.Id
52+
$exitCode = 9999
53+
}
54+
Stop-Process -InputObject $process
55+
Remove-Item $outputPath
56+
Pop-Location
57+
58+
$result = New-Object System.Object
59+
$result | Add-Member -Type NoteProperty -Name Output -Value $output
60+
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
61+
$result
3862
}
39-
Stop-Process -InputObject $process
40-
Remove-Item $outputPath
41-
Pop-Location
42-
43-
$result = New-Object System.Object
44-
$result | Add-Member -Type NoteProperty -Name Output -Value $output
45-
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
46-
$result
47-

0 commit comments

Comments
 (0)