CI: Also run on macos-latest

Make the `test/run` script compatible to the ancient Bash version on macos.

```
test/run: line 56: conditional binary operator expected
```

Also, run `set -e` only for Bash >= 4. Otherwise the shell silently exits with
a failure when a command (expectedly) fails.

fix bogus test failure with Bash 3.2 on macos
This commit is contained in:
Claudio Bley 2022-02-18 13:16:53 +01:00
parent d6d7cd76b7
commit 1a0c82201f
2 changed files with 9 additions and 3 deletions

View file

@ -16,10 +16,12 @@ on:
jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0']
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2

View file

@ -1,6 +1,10 @@
#! /usr/bin/env bash
set -eEuCo pipefail
set -EuCo pipefail
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
set -e
fi
declare RED=$'\033[31m'
declare GREEN=$'\033[32m'
@ -53,7 +57,7 @@ function XFAIL() {
echo "$RED" "FAIL$RESET - $* (unexpected success, ${BASH_SOURCE[1]}:${BASH_LINENO[0]})" >&2
else
ret=$?
if [[ -v expected && $expected -ne $ret ]]; then
if [[ -n "$expected" && $expected -ne $ret ]]; then
((++ERRORS))
echo "$RED" "FAIL$RESET - $* (expected: $expected got $ret, ${BASH_SOURCE[1]}:${BASH_LINENO[0]})" >&2