X-Git-Url: https://iankelling.org/git/?p=lnf;a=blobdiff_plain;f=test%2Ftest;h=b345f2463a5eb5213b98e9d466e7b15b21eff1d4;hp=afbb6306a3fed7172407340f09a3a964cd9fbc96;hb=5da4a11f4c6f6cd7f0dd79d2402acaa78eb66f03;hpb=cca94a4f6e8acc20eacb8219b5f910e89b312802 diff --git a/test/test b/test/test index afbb630..b345f24 100755 --- a/test/test +++ b/test/test @@ -1,4 +1,20 @@ #!/bin/bash +# Copyright (C) 2014 Ian Kelling + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + # some basic sanity / verification # I don't recommend actually running this unless you have a reason to, @@ -12,14 +28,14 @@ case1() { touch b lnf -T a b - [[ -L b ]] + [[ -L b ]] } # 2 arguments, test that directory in link location is removed and replaced with a link case2() { mkdir b lnf -T a b - [[ -L b ]] + [[ -L b ]] } # single argument, test that an existing non-empty directory is removed and replaced by a link @@ -27,7 +43,7 @@ case3() { mkdir a touch a/b lnf ../a - [[ -L a ]] + [[ -L a ]] } # 4 arguments, 2 of the link locations already contain files. @@ -37,14 +53,14 @@ case4() { 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 ]] + [[ -L b/a ]] } @@ -61,7 +77,8 @@ docases() { done } -source ${0%/*}/../lnf-function +PATH="$(readlink -f ${0%/*}/..):$PATH" + # might want to undo this if things go wrong # set -x @@ -69,12 +86,13 @@ source ${0%/*}/../lnf-function 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