* [gentoo-commits] proj/pax-utils:master commit in: tests/
@ 2015-03-29 20:07 Mike Frysinger
0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2015-03-29 20:07 UTC (permalink / raw
To: gentoo-commits
commit: d40c49ba860483959dea26c38df0fa5a326c2aca
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 14 05:53:30 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Mar 14 05:53:30 2015 +0000
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=d40c49ba
tests: clean up a bit
The functions.sh messes with PATH, so mangle it after we load it.
Pull out pass/fail so tests can use it directly.
Clean up the style of testit to be more bashy and safe (quotes).
tests/lib.sh | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/tests/lib.sh b/tests/lib.sh
index 20f67bd..93943a1 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -4,33 +4,41 @@ top_srcdir=`cd "${srcdir}/../.." && pwd`
builddir=${srcdir}
top_builddir=${top_srcdir}
+[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh
+
PATH=${top_builddir}:${PATH}
unset ROOT # who knows!
-[ -e /etc/init.d/functions.sh ] && source /etc/init.d/functions.sh
-
ret=0
+pass() {
+ echo "${GOOD}PASS${NORMAL}: $*"
+}
+
+fail() {
+ ret=1
+ echo "${BAD}FAIL${NORMAL}: $*" >&2
+}
+
testit() {
local tret=0 err
case $# in
- 1)
- if [ -s $1 ] ; then
- tret=1
- err=$(<$1)
- fi
- ;;
- 2)
- if ! err=`diff -u $1 $2` ; then
- tret=1
- fi
+ 1)
+ if [[ -s $1 ]] ; then
+ tret=1
+ err=$(<"$1")
+ fi
+ ;;
+ 2)
+ if ! err=$(diff -u "$1" "$2") ; then
+ tret=1
+ fi
esac
- if [ ${tret} -eq 0 ] ; then
- echo ${GOOD}PASS${NORMAL}: $1
+ if [[ ${tret} -eq 0 ]] ; then
+ pass "$1"
else
- ret=1
- echo ${BAD}FAIL${NORMAL}: $1
+ fail "$1"
echo "${err}"
fi
- rm -f $1
+ rm -f "$1"
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-29 20:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 20:07 [gentoo-commits] proj/pax-utils:master commit in: tests/ Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox