-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeaStackCtest.ps1
More file actions
85 lines (72 loc) · 2.57 KB
/
SeaStackCtest.ps1
File metadata and controls
85 lines (72 loc) · 2.57 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
<#
Invoke ctest with optional UX tweaks for SEA-Stack PowerShell runners.
- Default (no -CtestQuiet, no -CtestVerbose): stream output live but drop parallel
"Start N:" lines so completed test lines (Passed/Failed, timings) remain.
- -CtestQuiet: passes ctest -Q (Start filtering not used; quiet mode changes output).
- -CtestVerbose: passes ctest -V; no Start filtering (full debug-style stream).
Names avoid -Verbose/-Quiet so this advanced function does not clash with common parameters.
Exit code is the ctest process exit code.
#>
function Invoke-SeaStackCtest {
param(
[Parameter(Mandatory)][string[]]$CtestArguments,
[Parameter(Mandatory)][string]$WorkingDirectory,
[switch]$CtestQuiet,
[switch]$CtestVerbose,
[switch]$SuppressStartLines
)
$argList = [System.Collections.Generic.List[string]]::new()
foreach ($a in $CtestArguments) {
$argList.Add($a)
}
if ($CtestVerbose) {
$argList.Add('-V')
} elseif ($CtestQuiet) {
$argList.Add('-Q')
}
$argv = $argList.ToArray()
$useStartFilter = $SuppressStartLines -and -not $CtestQuiet -and -not $CtestVerbose
if (-not $useStartFilter) {
Push-Location -LiteralPath $WorkingDirectory
try {
& ctest @argv
return $LASTEXITCODE
} finally {
Pop-Location
}
}
$ctestExe = (Get-Command ctest -ErrorAction Stop).Source
# Build a single argument string for CreateProcess (quote args that need it).
$argString = ($argv | ForEach-Object {
$t = "$_"
if ($t -match '[\s"]') {
'"' + ($t -replace '"', '\"') + '"'
} else {
$t
}
}) -join ' '
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = $ctestExe
$psi.Arguments = $argString
$psi.WorkingDirectory = $WorkingDirectory
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.CreateNoWindow = $true
$proc = New-Object System.Diagnostics.Process
$proc.StartInfo = $psi
[void]$proc.Start()
# CMake parallel runs: " Start 12: test_name" — hide these only.
$startLineRx = '^\s+Start\s+\d+:'
while ($null -ne ($line = $proc.StandardOutput.ReadLine())) {
if ($line -notmatch $startLineRx) {
Write-Host $line
}
}
$errTail = $proc.StandardError.ReadToEnd()
if ($errTail) {
Write-Host $errTail
}
[void]$proc.WaitForExit()
return $proc.ExitCode
}