From d2fb93dee165c803416278ad3e4b869cd57e4182 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Thu, 5 Feb 2026 16:07:29 +0000 Subject: use $LASTEXITCODE instead of try/catch in PowerShell test --- .github/workflows/test-validators.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to '.github') diff --git a/.github/workflows/test-validators.yml b/.github/workflows/test-validators.yml index d3324ba..dae7308 100644 --- a/.github/workflows/test-validators.yml +++ b/.github/workflows/test-validators.yml @@ -4,17 +4,17 @@ on: push: branches: [main] paths: - - 'validators/**' - - 'gitinfo.schema.json' - - 'examples/**' - - '.github/workflows/test-validators.yml' + - "validators/**" + - "gitinfo.schema.json" + - "examples/**" + - ".github/workflows/test-validators.yml" pull_request: branches: [main] paths: - - 'validators/**' - - 'gitinfo.schema.json' - - 'examples/**' - - '.github/workflows/test-validators.yml' + - "validators/**" + - "gitinfo.schema.json" + - "examples/**" + - ".github/workflows/test-validators.yml" workflow_dispatch: jobs: @@ -69,13 +69,13 @@ jobs: shell: pwsh run: | '{"invalid_field": "should fail"}' | Set-Content /tmp/invalid.gitinfo - try { - ./validators/powershell/Validate-GitInfo.ps1 -Path /tmp/invalid.gitinfo - Write-Error "Expected validation to fail but it passed" + ./validators/powershell/Validate-GitInfo.ps1 -Path /tmp/invalid.gitinfo + if ($LASTEXITCODE -eq 0) { + Write-Host "Expected validation to fail but it passed" exit 1 - } catch { - Write-Host "Correctly detected invalid file" } + Write-Host "Correctly detected invalid file" + exit 0 test-bash: name: Test Bash Validator -- cgit v1.2.3