[c#] Automatically find and run C# examples
* Comm examples are excluded, as Comm will be deleted soon. * The gRPC shared-type-assembly examples are excluded, as they require starting two processing in a specific order and console input.
This commit is contained in:
Родитель
403fb38450
Коммит
3831969d4b
18
appveyor.yml
18
appveyor.yml
|
@ -28,7 +28,7 @@
|
|||
# the Windows builds.
|
||||
- .travis.yml
|
||||
- tools/ci-scripts/linux/**
|
||||
|
||||
|
||||
environment:
|
||||
global:
|
||||
STACK_ROOT: "c:\\sr"
|
||||
|
@ -94,6 +94,7 @@
|
|||
BOND_ARCH: 64
|
||||
BOND_BOOST: 58
|
||||
BOND_CMAKE_FLAGS: "-DBOND_ENABLE_COMM=TRUE;-DBOND_ENABLE_GRPC=FALSE;-DBOND_SKIP_CORE_TESTS=TRUE;-DBOND_SKIP_GBC_TESTS=TRUE"
|
||||
|
||||
install:
|
||||
- ps: >-
|
||||
if (($env:BOND_BUILD -eq 'C++') -or ($env:BOND_BUILD -eq 'Python')) {
|
||||
|
@ -308,30 +309,19 @@
|
|||
}
|
||||
|
||||
if ($env:BOND_BUILD -eq "C#") {
|
||||
|
||||
nunit-console-x86 /framework:net-4.5 /labels "cs\test\core\bin\debug\net45\${env:BOND_OUTPUT}\Bond.UnitTest.dll" cs\test\internal\bin\debug\net45\Bond.InternalTest.dll
|
||||
if (-not $?) { throw "tests failed" }
|
||||
|
||||
nunit-console-x86 /framework:net-4.5 /labels "cs\test\core\bin\debug\net45-nonportable\${env:BOND_OUTPUT}\Bond.UnitTest.dll"
|
||||
if (-not $?) { throw "tests failed" }
|
||||
|
||||
& examples\cs\grpc\pingpong\bin\Debug\grpc-pingpong.exe
|
||||
if (-not $?) { throw "tests failed" }
|
||||
|
||||
& examples\cs\grpc\scalar\bin\Debug\grpc-scalar.exe
|
||||
if (-not $?) { throw "tests failed" }
|
||||
|
||||
# We need to investigate why these tests are failing in AppVeyor, but not locally.
|
||||
# nunit-console-x86 /framework:net-4.5 /labels "cs\test\comm\bin\debug\net45\${env:BOND_OUTPUT}\Bond.Comm.UnitTest.dll"
|
||||
# if (-not $?) { throw "tests failed" }
|
||||
|
||||
& cs\test\test-examples.ps1 -IgnorePatterns '*\comm\*','*\shared-types-assembly\*' -ErrorVariable exampleErrors
|
||||
if ($exampleErrors) { throw "One or more example failed. See above for details." }
|
||||
}
|
||||
|
||||
if ($env:BOND_BUILD -eq "C# .NET Core") {
|
||||
|
||||
& cs\dnc\build.ps1 -Test -Configuration $env:BOND_CONFIG -Verbosity minimal -MSBuildLogger "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
if (-not $?) { throw "tests failed" }
|
||||
|
||||
}
|
||||
|
||||
if (-not $?) { throw "build failed" }
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
Runs Bond C# examples for testing purposes. Writes an error record to
|
||||
the pipeline for each example that fails.
|
||||
|
||||
.PARAMETER ExamplesRoot
|
||||
|
||||
Path to the directory containing the built examples. Defaults to ..\..\examples\cs
|
||||
|
||||
.PARAMETER IgnorePatterns
|
||||
|
||||
A collection of -Like patterns specifying which examples to ignore.
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
PS c:\src\bond\cs\test> .\test-examples.ps1 -IgnorePatterns '*comm*'
|
||||
|
||||
This will run all the examples except those with "comm" in their paths.
|
||||
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[string]
|
||||
$ExamplesRoot = '',
|
||||
|
||||
[string[]]
|
||||
$IgnorePatterns = @()
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
function ShouldIgnore([string[]]$ignorePats, [string]$fullPath) {
|
||||
Write-Debug "Checking $fullPath against ignore patterns"
|
||||
ForEach ($pat in $ignorePats) {
|
||||
if ($fullPath -Like $pat) {
|
||||
Write-Debug "Ignoring ""$fullPath"". Matched pattern ""$pat"""
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($ExamplesRoot)) {
|
||||
$likelyExamplesDirectory = "$PSScriptRoot\..\..\examples\cs"
|
||||
if (Test-Path $likelyExamplesDirectory -PathType Container) {
|
||||
$ExamplesRoot = $likelyExamplesDirectory
|
||||
} else {
|
||||
throw "No ExamplesRoot was passed and the guessed ""$likelyExamplesDirectory"" didn't exist. Specify an ExamplesRoot."
|
||||
}
|
||||
}
|
||||
|
||||
$exampleExes = @()
|
||||
$exampleExes += dir -Recurse -Path $ExamplesRoot -Include '*.exe' -File |
|
||||
Where-Object { -not (ShouldIgnore $IgnorePatterns $PSItem.FullName) } |
|
||||
Where-Object -Property FullName -Like '*\bin\*'
|
||||
|
||||
Write-Debug "Found examples: $exampleExes"
|
||||
|
||||
try {
|
||||
$exampleExes | ForEach-Object {
|
||||
$exampleFullPath = $PSItem.FullName
|
||||
Write-Progress -Activity 'Running examples' -Status "Running ""$exampleFullPath"""
|
||||
Write-Debug "Running ""$exampleFullPath"""
|
||||
|
||||
$sw = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
& $exampleFullPath 2>&1 | Tee-Object -Variable output | Write-Debug
|
||||
if (-not $?) {
|
||||
Write-Error -Message "Example ""$exampleFullPath"" exited with $LASTEXITCODE. Output:`n$output" -TargetObject $PSItem
|
||||
}
|
||||
|
||||
Write-Debug """$exampleFullPath"" took $($sw.Elapsed)"
|
||||
}
|
||||
} finally {
|
||||
Write-Progress -Activity 'Running examples' -Completed
|
||||
}
|
Загрузка…
Ссылка в новой задаче