Skip to content

Commit

Permalink
Allow using python3 for timestamps on macOS and BSD (#362)
Browse files Browse the repository at this point in the history
Note that macOS 12.3 removed python2.
  • Loading branch information
tetromino authored Apr 1, 2022
1 parent 8e2ba6e commit b9ec2c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/unittest.bash
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,12 @@ if [ "$UNAME" = "linux" ] || [[ "$UNAME" =~ msys_nt* ]]; then
}
else
function timestamp() {
# OS X and FreeBSD do not have %N so python is the best we can do
python -c 'import time; print int(round(time.time() * 1000))'
# macOS and BSDs do not have %N, so Python is the best we can do.
# LC_ALL=C works around python 3.8 and 3.9 crash on macOS when the
# filesystem encoding is unspecified (e.g. when LANG=en_US).
local PYTHON=python
command -v python3 &> /dev/null && PYTHON=python3
LC_ALL=C "${PYTHON}" -c 'import time; print(int(round(time.time() * 1000)))'
}
fi

Expand Down

0 comments on commit b9ec2c2

Please sign in to comment.