-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-all.ps1
More file actions
86 lines (71 loc) · 2.26 KB
/
Copy pathrun-all.ps1
File metadata and controls
86 lines (71 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#Requires -Version 5.1
<#
.SYNOPSIS
Run all MuPDF.NET.Examples projects and report PASS/FAIL/SKIP vs Expected/ baselines.
.PARAMETER UpdateExpected
Refresh Expected/ baselines from the current NuGet packages.
#>
param(
[switch] $UpdateExpected,
[string] $Configuration = 'Release'
)
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $root
# Do not use $IsWindows — it is a read-only automatic variable in PowerShell 6+.
$useCmdHost = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform(
[System.Runtime.InteropServices.OSPlatform]::Windows)
dotnet build -c $Configuration
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$projects = @(Get-ChildItem -Recurse -Filter *.csproj |
Where-Object { $_.Directory.Name -match '^\d{2}-' } |
Sort-Object FullName)
$fail = 0
$skip = 0
$pass = 0
foreach ($p in $projects) {
$name = $p.Directory.Name
$argList = @(
'run', '--project', $p.FullName,
'-c', $Configuration, '--no-build'
)
if ($UpdateExpected) {
$argList += '--'
$argList += '--update-expected'
}
$tmpName = "mupdf-examples-" + [guid]::NewGuid().ToString('N') + ".log"
$tmp = if ($env:TEMP) { Join-Path $env:TEMP $tmpName } else { Join-Path ([IO.Path]::GetTempPath()) $tmpName }
if ($useCmdHost) {
# cmd so native AVs / stderr do not abort the PowerShell driver on Windows.
$joined = ($argList | ForEach-Object {
if ($_ -match '\s') { '"' + $_ + '"' } else { $_ }
}) -join ' '
cmd /c "dotnet $joined > `"$tmp`" 2>&1"
}
else {
& dotnet @argList *> $tmp
}
$out = Get-Content -Raw -ErrorAction SilentlyContinue $tmp
Remove-Item $tmp -Force -ErrorAction SilentlyContinue
if ($out -match 'SKIP —') {
Write-Host "SKIP $name"
$skip++
continue
}
$ok = if ($UpdateExpected) {
$out -match 'Baselines updated'
} else {
$out -match 'PASS —'
}
if ($ok) {
Write-Host "PASS $name"
$pass++
}
else {
Write-Host "FAIL $name"
if ($out) { Write-Host $out }
$fail++
}
}
Write-Host ""
Write-Host "PASS: $pass SKIP: $skip FAIL: $fail / $($projects.Count) projects"
exit $(if ($fail -eq 0) { 0 } else { 1 })