Fix tests/command/sample.sh test on Mingw.
[pspp-builds.git] / tests / command / sample.sh
index 6dfe00c9817066fe2c68e65e978fbc207d1dfa8f..fc856a4adfbfc2f0ccab2743d482d5cb30582157 100755 (executable)
@@ -5,16 +5,26 @@
 TEMPDIR=/tmp/pspp-tst-$$
 TESTFILE=$TEMPDIR/`basename $0`.sps
 
-here=`pwd`;
+# ensure that top_builddir  are absolute
+if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
+if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
+top_builddir=`cd $top_builddir; pwd`
+PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
 
 # ensure that top_srcdir is absolute
-cd $top_srcdir; top_srcdir=`pwd`
+top_srcdir=`cd $top_srcdir; pwd`
 
-export STAT_CONFIG_PATH=$top_srcdir/config
+STAT_CONFIG_PATH=$top_srcdir/config
+export STAT_CONFIG_PATH
 
 
 cleanup()
 {
+     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
+       echo "NOT cleaning $TEMPDIR" 
+       return ; 
+     fi
+     cd /
      rm -rf $TEMPDIR
 }
 
@@ -71,11 +81,11 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="run program"
-$SUPERVISOR $here/../src/pspp -o raw-ascii --testing-mode $TEMPDIR/sample.stat 
+$SUPERVISOR $PSPP --testing-mode $TEMPDIR/sample.stat 
 if [ $? -ne 0 ] ; then no_result ; fi
 
 activity="create head"
-grep -v '^*$' $TEMPDIR/pspp.list | head -2 > $TEMPDIR/head
+grep -v '^\r]*$' $TEMPDIR/pspp.list | head -2 > $TEMPDIR/head
 if [ $? -ne 0 ] ; then no_result ; fi
 
 activity="extract data"
@@ -84,7 +94,8 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="compare head"
-diff -B -b $TEMPDIR/head - << EOF
+perl -pi -e 's/^\s*$//g' $TEMPDIR/head
+diff -b $TEMPDIR/head - << EOF
  A
 --
 EOF