aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2021-04-03 17:29:40 -0400
committerLukas Fleischer <lfleischer@calcurse.org>2021-04-03 17:55:46 -0400
commitb36e603997e5534b9173d4e0de856309d7d56b3d (patch)
treef9d2f7323663bae9a3e7ac7c5d93957fe4f9567c /test
parentf1e84bd18bc6f9e0ce52b9f1dd08590e97d438a7 (diff)
downloadcalcurse-b36e603997e5534b9173d4e0de856309d7d56b3d.tar.gz
calcurse-b36e603997e5534b9173d4e0de856309d7d56b3d.zip
Do not use readlink(1) in tests
Avoid using readlink(1) which is not POSIX-compatible; moreover, `readlink -f` is not available on Mac OS by default. Instead, always convert $CALCURSE to an absolute path (that may or may not be canonical, i.e., be a symlink or contain ../ as component) in test-init.sh by prepending the current working directory if the original path is relative. While not fully equivalent to `readlink -f`, this should be good enough for use in our tests. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/io-005.sh1
-rwxr-xr-xtest/io-006.sh1
-rw-r--r--test/test-init.sh5
3 files changed, 5 insertions, 2 deletions
diff --git a/test/io-005.sh b/test/io-005.sh
index c5ebcc7..6b03908 100755
--- a/test/io-005.sh
+++ b/test/io-005.sh
@@ -3,7 +3,6 @@
. "${TEST_INIT:-./test-init.sh}"
home=$(mktemp -d)
-CALCURSE=$(readlink -f "$CALCURSE")
(unset -v XDG_DATA_HOME XDG_CONFIG_HOME; HOME="$home" "$CALCURSE" -a)
[ -f "$home/.local/share/calcurse/apts" ] && [ -f "$home/.config/calcurse/conf" ] && failed=0 || failed=1
diff --git a/test/io-006.sh b/test/io-006.sh
index 4184d9f..babcfcd 100755
--- a/test/io-006.sh
+++ b/test/io-006.sh
@@ -3,7 +3,6 @@
. "${TEST_INIT:-./test-init.sh}"
dir=$(mktemp -d)
-CALCURSE=$(readlink -f "$CALCURSE")
cd "$dir"
(unset -v HOME XDG_DATA_HOME XDG_CONFIG_HOME; "$CALCURSE" -a)
[ -f "$dir/.calcurse/apts" ] && [ -f "$dir/.calcurse/conf" ] && failed=0 || failed=1
diff --git a/test/test-init.sh b/test/test-init.sh
index c95c884..92ad779 100644
--- a/test/test-init.sh
+++ b/test/test-init.sh
@@ -2,3 +2,8 @@
CALCURSE=${CALCURSE:-../src/calcurse}
DATA_DIR=${DATA_DIR:-data/}
+
+case "$CALCURSE" in
+ /*) ;;
+ *) CALCURSE="${PWD}/${CALCURSE}" ;;
+esac