From 42e6214a42569a687f417b02ffde310652c97eca Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Sat, 13 Jan 2024 18:49:38 -0800 Subject: [PATCH] feat: lake: GNU/BSD OS detection in test scripts (#3180) fixes #3179 --- src/lake/tests/buildArgs/test.sh | 3 ++- src/lake/tests/clone/test.sh | 3 ++- src/lake/tests/depTree/test.sh | 3 ++- src/lake/tests/init/test.sh | 5 +++-- src/lake/tests/lock/test.sh | 3 ++- src/lake/tests/manifest/test.sh | 3 ++- src/lake/tests/serve/test.sh | 3 ++- src/lake/tests/toolchain/test.sh | 3 ++- tests/ir/lirc | 2 +- 9 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/lake/tests/buildArgs/test.sh b/src/lake/tests/buildArgs/test.sh index b04130382a80..3aa7b866e602 100755 --- a/src/lake/tests/buildArgs/test.sh +++ b/src/lake/tests/buildArgs/test.sh @@ -3,7 +3,8 @@ set -exo pipefail LAKE=${LAKE:-../../.lake/build/bin/lake} -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then sed_i() { sed -i '' "$@"; } else sed_i() { sed -i "$@"; } diff --git a/src/lake/tests/clone/test.sh b/src/lake/tests/clone/test.sh index 31c670c2c096..5e8b155c66ae 100755 --- a/src/lake/tests/clone/test.sh +++ b/src/lake/tests/clone/test.sh @@ -3,7 +3,8 @@ set -exo pipefail LAKE=${LAKE:-../../../.lake/build/bin/lake} -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then sed_i() { sed -i '' "$@"; } else sed_i() { sed -i "$@"; } diff --git a/src/lake/tests/depTree/test.sh b/src/lake/tests/depTree/test.sh index cffeb3761eb3..50de3c1bd4a4 100755 --- a/src/lake/tests/depTree/test.sh +++ b/src/lake/tests/depTree/test.sh @@ -3,7 +3,8 @@ set -exo pipefail LAKE=${LAKE:-$PWD/../../.lake/build/bin/lake} -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then sed_i() { sed -i '' "$@"; } else sed_i() { sed -i "$@"; } diff --git a/src/lake/tests/init/test.sh b/src/lake/tests/init/test.sh index 3892558823bb..b9d747de7af8 100755 --- a/src/lake/tests/init/test.sh +++ b/src/lake/tests/init/test.sh @@ -3,7 +3,8 @@ set -euxo pipefail ./clean.sh -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then sed_i() { sed -i '' "$@"; } else sed_i() { sed -i "$@"; } @@ -79,7 +80,7 @@ $LAKE -d 123-hello exe 123-hello # Test creating packages with components that contain `.`s # https://github.com/leanprover/lean4/issues/2999 - + # this fails on windows for unrelated reasons if [ "$OSTYPE" != "msys" ]; then $LAKE new «A.B».«C.D» diff --git a/src/lake/tests/lock/test.sh b/src/lake/tests/lock/test.sh index 47d77cf9c303..26ea21753a90 100755 --- a/src/lake/tests/lock/test.sh +++ b/src/lake/tests/lock/test.sh @@ -6,7 +6,8 @@ exit 0 LAKE=${LAKE:-../../.lake/build/bin/lake} -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then TAIL=gtail else TAIL=tail diff --git a/src/lake/tests/manifest/test.sh b/src/lake/tests/manifest/test.sh index be81297be044..01ab8ed90a18 100755 --- a/src/lake/tests/manifest/test.sh +++ b/src/lake/tests/manifest/test.sh @@ -3,7 +3,8 @@ set -exo pipefail LAKE=${LAKE:-../../.lake/build/bin/lake} -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then sed_i() { sed -i '' "$@"; } else sed_i() { sed -i "$@"; } diff --git a/src/lake/tests/serve/test.sh b/src/lake/tests/serve/test.sh index 0801d3603c47..1a017cc6d975 100755 --- a/src/lake/tests/serve/test.sh +++ b/src/lake/tests/serve/test.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then TAIL=gtail else TAIL=tail diff --git a/src/lake/tests/toolchain/test.sh b/src/lake/tests/toolchain/test.sh index c6a95c59faf3..509c7c6c79f6 100755 --- a/src/lake/tests/toolchain/test.sh +++ b/src/lake/tests/toolchain/test.sh @@ -11,7 +11,8 @@ if ! command -v elan > /dev/null; then exit 0 fi -if [ "`uname`" = Darwin ]; then +unamestr=`uname` +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then sed_i() { sed -i '' "$@"; } else sed_i() { sed -i "$@"; } diff --git a/tests/ir/lirc b/tests/ir/lirc index 885499b7e464..4fedfbbecd5c 100755 --- a/tests/ir/lirc +++ b/tests/ir/lirc @@ -1,7 +1,7 @@ #!/usr/bin/env bash unamestr=`uname` -if [[ "$unamestr" == 'Darwin' ]]; then +if [ "$unamestr" = Darwin ] || [ "$unamestr" = FreeBSD ]; then # OSX if command -v greadlink >/dev/null 2>&1; then # macOS readlink doesn't support -f option