Skip to content

Commit

Permalink
Better error handling in PS1
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks committed Jan 10, 2024
1 parent 5e8e07a commit 07da36a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/secnetperf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ if ($isWindows) {
Copy-Item -ToSession $Session ./scripts -Destination /home/secnetperf/_work/scripts -Recurse
}

$encounterFailures = $false

try {

mkdir .\artifacts\logs | Out-Null
Expand Down Expand Up @@ -199,17 +201,20 @@ for ($try = 0; $try -lt 3; $try++) {

try {
$rawOutput = Invoke-Expression $command
$rawOutput
} catch {
Write-Host "::error::Failed to run test: $($commands[$i])"
Write-Host "::error::$_"
$encounterFailures = $true
continue
}

if ($rawOutput.Contains("Error")) {
$rawOutput.Substring(7) # Skip over the 'Error: ' prefix
Write-Host "::error::$rawOutput"
$encounterFailures = $true
continue
}
$rawOutput

if ($testIds[$i].Contains("rps")) {
$latency_percentiles = '(?<=\d{1,3}(?:\.\d{1,2})?th: )\d+'
Expand Down Expand Up @@ -302,8 +307,14 @@ $FileName = "json-test-results-$plat-$os-$arch-$tls.json"
$json | ConvertTo-Json | Set-Content -Path $FileName

} catch {
Write-Error "Failed to run some tests..."
Write-Error "Exception occurred while running tests..."
Write-Error $_
exit 1
} finally {
# TODO: Do any further book keeping here.
}

if ($encounterFailures) {
Write-Error "Errors occurred while running tests."
exit 1
}

0 comments on commit 07da36a

Please sign in to comment.