commit f340ccba8aa2733327fe3d480c74865ad7c6e665
parent d1e247d2f374bae52087a149930ee64a00ff63f2
Author: Kyle Milz <kyle@0x30.net>
Date: Sat, 13 Aug 2016 13:11:38 -0600
src: cobine PATH modifying tests into one
Diffstat:
2 files changed, 58 insertions(+), 15 deletions(-)
diff --git a/t/inst_nopath.t b/t/inst_nopath.t
@@ -1,15 +0,0 @@
-#!/bin/sh
-#
-# Test that not having PATH set errors out.
-#
-echo 1..3
-. test/utils.sh
-
-# Save locations to tools because after unset PATH they are not available.
-grep=`which grep`
-
-unset PATH
-$TEST_TOOLS/gcc -c nomatter.c
-
-[ $? -eq 1 ] && echo ok 2
-$grep -q "Error: PATH is not set" citrun.log && echo ok 3
diff --git a/t/inst_path.t b/t/inst_path.t
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# Test that:
+# - not having PATH set errors
+# - not having CITRUN_SHARE in PATH when using transparent compile mode errors
+#
+echo 1..6
+
+#
+# This test is a little special. It unsets PATH and sets it to the empty string,
+# so we must save the locations of standard utilities we use to verify things
+# ahead of time.
+#
+grep=`which grep`
+rm=`which rm`
+diff=`which diff`
+sed=`which sed`
+cat=`which cat`
+
+tmpdir=`mktemp -d /tmp/citrun.XXXXXXXXXX`
+trap "$rm -rf $tmpdir" EXIT
+echo "ok 1 - tmp dir created"
+
+export TEST_TOOLS="`pwd`/src";
+cd $tmpdir
+
+# Save locations to tools because after unset PATH they are not available.
+grep=`which grep`
+
+unset PATH
+$TEST_TOOLS/gcc -c nomatter.c
+[ $? -eq 1 ] && echo ok 2
+
+export PATH=""
+$TEST_TOOLS/gcc -c nomatter.c 2> /dev/null
+[ $? -eq 1 ] && echo ok 3
+
+$cat <<EOF > citrun.log.good
+citrun-inst 0.0 ()
+Tool called as ''.
+Resource directory is ''
+Changing ''.
+PATH is not set.
+citrun-inst 0.0 ()
+Tool called as ''.
+Resource directory is ''
+Changing ''.
+PATH=''
+'' not in PATH.
+EOF
+
+$sed -e "s,^.*: ,," \
+ -e "s,'.*',''," \
+ -e "s,(.*),()," \
+ < citrun.log > citrun.log.proc \
+ && echo "ok 4 - processed citrun.log"
+
+$diff -u citrun.log.good citrun.log.proc && echo ok 5