summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2019-06-19 19:18:13 +1000
committerDamien Zammit <damien@zamaudio.com>2019-06-19 19:18:13 +1000
commit94972e163c6571acbb76b9dc78ba207b61280da0 (patch)
tree34288e03be53e1cc92276813d2b2a159f3d3d50c
parentfd82b126bdde64f487ad6baa82cd31177f04e18f (diff)
tests: Make more robust to different environments
-rw-r--r--tests.sh32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests.sh b/tests.sh
index bdec6fd..27d9d56 100644
--- a/tests.sh
+++ b/tests.sh
@@ -1,19 +1,37 @@
#!/do/not/execute
-DIFF=diff
+DIFF=/usr/bin/diff
+GREP=/usr/bin/grep
PTFTOOL=../../ptftool
run_test() {
echo "$NAME"
if [ ! -e $FILE ]; then
- echo "Can't find binary"
+ echo "Cannot find test file"
echo ""
- exit 2
+ exit 1
+ fi
+ if [ ! -e $DIFF ]; then
+ echo "Cannot find diff"
+ echo ""
+ exit 1
+ fi
+ if [ ! -e $GREP ]; then
+ echo "Cannot find grep"
+ echo ""
+ exit 1
+ fi
+ if [ ! -e $PTFTOOL ]; then
+ echo "Cannot find ptftool"
+ echo ""
+ exit 1
fi
- $PTFTOOL $FILE 2> /dev/null > .tmp1
- echo "$EXPECT" > .tmp2
- DIFFED=$($DIFF -U0 .tmp2 .tmp1 | grep -v -E '^\+\+\+ |^--- ')
- rm -f .tmp1 .tmp2
+ TMP1=$(mktemp)
+ TMP2=$(mktemp)
+ $PTFTOOL $FILE 2> /dev/null > $TMP1
+ echo "$EXPECT" > $TMP2
+ DIFFED=$($DIFF -U0 $TMP2 $TMP1 | $GREP -v -E '^\+\+\+ |^--- ')
+ rm -f $TMP1 $TMP2
if [ -z "$DIFFED" ]; then
echo "[ OK ]"
echo ""