# 2 arguments, test that a file in the link location is removed and replaed with a link
case1() {
touch b
- lnf a b
- [[ -L b ]]
+ lnf -T a b
+ [[ -L b ]]
}
# 2 arguments, test that directory in link location is removed and replaced with a link
case2() {
mkdir b
- lnf a b
- [[ -L b ]]
+ lnf -T a b
+ [[ -L b ]]
}
# single argument, test that an existing non-empty directory is removed and replaced by a link
mkdir a
touch a/b
lnf ../a
- [[ -L a ]]
+ [[ -L a ]]
}
# 4 arguments, 2 of the link locations already contain files.
touch a/b
touch a/c
lnf b c d a
- [[ -L a/b && -L a/c && -L a/d ]]
+ [[ -L a/b && -L a/c && -L a/d ]]
}
+# 2 arguments, test that link is made correctly
+case5() {
+ mkdir b
+ lnf a b
+ [[ -L b/a ]]
+}
+
+
+
cleanup() {
rm -rf *
}
docases() {
- case1
- cleanup
- case2
- cleanup
- case3
- cleanup
- case4
- cleanup
+ for x in {1..5}; do
+ case$x
+ cleanup
+ done
}
-source ${0%/*}/../lnf-function
+PATH="$(readlink -f ${0%/*}/..):$PATH"
+
# might want to undo this if things go wrong
# set -x
set -E;
trap 'echo "${BASH_COMMAND:+BASH_COMMAND=\"$BASH_COMMAND\" }
${FUNCNAME:+FUNCNAME=\"$FUNCNAME\" }${LINENO:+LINENO=\"$LINENO\" }\$?=$?"' ERR
-cd $(mktemp -d)
+tempdir=$(mktemp -d)
+cd $tempdir
docases
# test again, using rm -rf in place of trash-put.
-# assumes that rm is in /bin and trash-put is in /usr/bin
-PATH="${PATH//:\/usr\/bin}"
-PATH="${PATH//\/usr\/bin:}"
+trash-put() { rm -rf -- "$@"; }
+export -f trash-put
docases
+rm -rf $tempdir
echo tests concluded