Skip to content

Commit 6428710

Browse files
committed
CI: Check assertion output more rigorously
Extend steps that run assertion failures to check not only the expected exit code, but also that the output appears to include a legible assertion message. This is intended to catch cases where the ERROR STOP character output is garbled, a defect we've now separately seen from two compilers. New CHECK_ASSERT variable factors this logic and applies it where appropriate. Force bash as the default shell, because otherwise containers default to /bin/sh
1 parent 71c30d9 commit 6428710

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ jobs:
77
build:
88
name: ${{ matrix.compiler }}-${{ matrix.version }} (${{ matrix.os }})
99
runs-on: ${{ matrix.os }}
10+
defaults:
11+
run:
12+
shell: bash
1013
strategy:
1114
fail-fast: false
1215
matrix:
@@ -89,6 +92,7 @@ jobs:
8992
FC: ${{ matrix.compiler }}
9093
FFLAGS: ${{ matrix.extra_flags }}
9194
FPM_FLAGS: --profile release --verbose
95+
CHECK_ASSERT: --flag -DASSERTIONS 2>&1 | tee output ; test ${PIPESTATUS[0]} = $ERROR_STOP_CODE && grep -q "Assertion failure" output
9296

9397
steps:
9498
- name: Checkout code
@@ -178,14 +182,12 @@ jobs:
178182
fpm run --example invoke-via-macro ${FPM_FLAGS} --flag "$FFLAGS"
179183
180184
- name: Build and Test (Assertions ON)
181-
env:
182-
FPM_FLAGS: ${{ env.FPM_FLAGS }} --flag -DASSERTIONS
183185
run: |
184186
set -x
185-
fpm test ${FPM_FLAGS} --flag "$FFLAGS"
186-
( set +e ; fpm run --example false-assertion ${FPM_FLAGS} --flag "$FFLAGS" ; test $? = $ERROR_STOP_CODE )
187-
( set +e ; fpm run --example simple-assertions ${FPM_FLAGS} --flag "$FFLAGS" ; test $? = $ERROR_STOP_CODE )
188-
( set +e ; fpm run --example invoke-via-macro ${FPM_FLAGS} --flag "$FFLAGS" ; test $? = $ERROR_STOP_CODE )
187+
fpm test ${FPM_FLAGS} --flag "$FFLAGS" --flag -DASSERTIONS
188+
( set +e ; eval fpm run --example false-assertion ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
189+
( set +e ; eval fpm run --example simple-assertions ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
190+
( set +e ; eval fpm run --example invoke-via-macro ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
189191
190192
- name: Test Assertions w/ Parallel Callbacks
191193
if: ${{ matrix.compiler != 'lfortran' }} # issue #68
@@ -195,5 +197,5 @@ jobs:
195197
set -x
196198
fpm run --example false-assertion ${FPM_FLAGS} --flag "$FFLAGS"
197199
fpm run --example invoke-via-macro ${FPM_FLAGS} --flag "$FFLAGS"
198-
( set +e ; fpm run --example false-assertion ${FPM_FLAGS} --flag "$FFLAGS -DASSERTIONS" ; test $? = $ERROR_STOP_CODE )
199-
( set +e ; fpm run --example invoke-via-macro ${FPM_FLAGS} --flag "$FFLAGS -DASSERTIONS" ; test $? = $ERROR_STOP_CODE )
200+
( set +e ; eval fpm run --example false-assertion ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
201+
( set +e ; eval fpm run --example invoke-via-macro ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )

0 commit comments

Comments
 (0)