Skip to content

Commit d2fb93d

Browse files
committed
use $LASTEXITCODE instead of try/catch in PowerShell test
1 parent 01af650 commit d2fb93d

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

.github/workflows/test-validators.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- 'validators/**'
8-
- 'gitinfo.schema.json'
9-
- 'examples/**'
10-
- '.github/workflows/test-validators.yml'
7+
- "validators/**"
8+
- "gitinfo.schema.json"
9+
- "examples/**"
10+
- ".github/workflows/test-validators.yml"
1111
pull_request:
1212
branches: [main]
1313
paths:
14-
- 'validators/**'
15-
- 'gitinfo.schema.json'
16-
- 'examples/**'
17-
- '.github/workflows/test-validators.yml'
14+
- "validators/**"
15+
- "gitinfo.schema.json"
16+
- "examples/**"
17+
- ".github/workflows/test-validators.yml"
1818
workflow_dispatch:
1919

2020
jobs:
@@ -69,13 +69,13 @@ jobs:
6969
shell: pwsh
7070
run: |
7171
'{"invalid_field": "should fail"}' | Set-Content /tmp/invalid.gitinfo
72-
try {
73-
./validators/powershell/Validate-GitInfo.ps1 -Path /tmp/invalid.gitinfo
74-
Write-Error "Expected validation to fail but it passed"
72+
./validators/powershell/Validate-GitInfo.ps1 -Path /tmp/invalid.gitinfo
73+
if ($LASTEXITCODE -eq 0) {
74+
Write-Host "Expected validation to fail but it passed"
7575
exit 1
76-
} catch {
77-
Write-Host "Correctly detected invalid file"
7876
}
77+
Write-Host "Correctly detected invalid file"
78+
exit 0
7979
8080
test-bash:
8181
name: Test Bash Validator

0 commit comments

Comments
 (0)