|
8 | 8 | [Parameter(Mandatory=$true)]
|
9 | 9 | [ValidateNotNullOrEmpty()]
|
10 | 10 | [string]
|
11 |
| - $project, |
12 |
| - [int]$timeoutDuration, |
13 |
| - [string]$configuration |
| 11 | + $Project, |
| 12 | + [int] |
| 13 | + $TimeoutDuration, |
| 14 | + [string] |
| 15 | + $Configuration, |
| 16 | + [switch] |
| 17 | + $AppVeyor = $false |
14 | 18 | )
|
15 | 19 |
|
16 | 20 | $rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
|
17 | 21 | Push-Location $rootDirectory
|
18 | 22 |
|
19 |
| -$dll = "src\$project\bin\$configuration\$project.dll" |
| 23 | +$dll = "src\$Project\bin\$Configuration\$Project.dll" |
20 | 24 |
|
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() |
25 | 39 |
|
26 |
| -$args = $dll, "-noshadow", "-xml", $xml, "-parallel", "all" |
27 |
| -[object[]] $output = "$consoleRunner " + ($args -join " ") |
| 40 | + $args = $dll, "-noshadow", "-xml", $xml, "-parallel", "all" |
28 | 41 |
|
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 |
38 | 62 | }
|
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