Skip to content

Commit

Permalink
Update macOS 11 to 12 in GitHub Actions CI
Browse files Browse the repository at this point in the history
Since macOS 12 no longer provides `/usr/bin/python`, but provides
`/usr/bin/python3`, add code to handle this case to testing scripts.
  • Loading branch information
mbrukman committed Aug 2, 2024
1 parent f31bfb2 commit 10501df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-22.04', 'macos-11' ]
os: [ 'ubuntu-22.04', 'macos-12' ]
python: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
name: Python ${{ matrix.python }} (${{ matrix.os }})
steps:
Expand Down
10 changes: 8 additions & 2 deletions csv2txf_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ fi

declare -i num_failures=0

# macOS 12+ doesn't provide /usr/bin/python, but provides /usr/bin/python3
PYTHON=""
if ! [[ -f "/usr/bin/python" ]] && [[ -f "/usr/bin/python3" ]]; then
PYTHON="python3"
fi

# Args:
# $0: file with expected stdout
# $*: command-line flags for csv2txf.py for this run
Expand All @@ -32,15 +38,15 @@ function test_csv2txf() {

if [ $regen -ne 0 ]; then
echo "Updating ${expected_out} ..."
./csv2txf.py "$@" -o "${expected_out}"
${PYTHON} ./csv2txf.py "$@" -o "${expected_out}"
return
fi

echo "Testing ${expected_out} ..."
local base="$(basename ${expected_out})"
local out="$(mktemp /tmp/csv2txf.${base}.out.XXXXXX)"
local err="$(mktemp /tmp/csv2txf.${base}.err.XXXXXX)"
./csv2txf.py "$@" -o "${out}" 2> "${err}"
${PYTHON} ./csv2txf.py "$@" -o "${out}" 2> "${err}"

diff -u "${expected_out}" "${out}" || {
cat "${err}"
Expand Down
9 changes: 8 additions & 1 deletion run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@

declare -i success=0

# macOS 12+ doesn't provide /usr/bin/python, but provides /usr/bin/python3
PYTHON=""
if ! [[ -f "/usr/bin/python" ]] && [[ -f "/usr/bin/python3" ]]; then
PYTHON="python3"
fi

for test in *_test.* ; do
test_out="$(mktemp "/tmp/csv2txf.${test}.XXXXXX")"
echo -n "Testing ${test} ... "
if [[ ${test} =~ _test.py ]] && [ -n "${PYTHON:-}" ]; then
echo -n "Testing ${test} (with ${PYTHON}) ... "
"${PYTHON}" "./${test}" > "${test_out}" 2>&1
${PYTHON} "./${test}" > "${test_out}" 2>&1
else
echo -n "Testing ${test} ... "
"./${test}" > "${test_out}" 2>&1
Expand Down

0 comments on commit 10501df

Please sign in to comment.