nice changes to enable an shunit test to be called without requiring an
authorChris Koeritz <fred@gruntose.com>
Thu, 10 May 2012 22:43:02 +0000 (18:43 -0400)
committerChris Koeritz <fred@gruntose.com>
Thu, 10 May 2012 22:43:02 +0000 (18:43 -0400)
absolute path on the script name.

scripts/shunit/example_shunit_test.sh

index f499bf95b5cad4e9f99840b17feac703a2838121..c3dc8de5cb6abd72f9883b6becd840e1f42ed30f 100755 (executable)
@@ -5,27 +5,30 @@
 # Author: Chris Koeritz
 
 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
-cd $WORKDIR
-
-# this variable needs to be set somewhere.  feisty meow scripts will set it.
-#SHUNIT_DIR=/home/fred/shunit
+#cd $WORKDIR
+if [[ ! "$0" =~ ^/.* ]]; then
+  # re-run the script with the absolute path if it didn't start that way; otherwise
+  # shunit is not happy with finding the script.
+  exec "$WORKDIR/$(basename $0)" $*
+fi
 
 oneTimeSetUp()
 {
-  echo into set up.
+  echo "into oneTimeSetUp."
 }
 
 testOneThing()
 {
-  echo got to test case.
+  echo "got to test case.  sleeping for a bit..."
   zero=0
   assertEquals "zero should be equal to 0" 0 $zero
   sleep 23
+  echo "woke up.  passed tautological test."
 }
 
 oneTimeTearDown()
 {
-  echo into tear down.
+  echo "into oneTimeTearDown."
 }
 
 # load and run shUnit2