tests: Convert test for VALUELABEL expression function to Autotest.
[pspp-builds.git] / tests / expressions / variables.sh
index d67a9c4cd52e3b68b5869f332f6efec413148185..5d0984908786903891f438a1501ba3939ebf6d5f 100755 (executable)
@@ -4,17 +4,26 @@
 
 TEMPDIR=/tmp/pspp-tst-$$
 
-here=`pwd`;
-
-# ensure that top_srcdir is absolute
-cd $top_srcdir; top_srcdir=`pwd`
+# ensure that top_srcdir and top_builddir  are absolute
+if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
+if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
+top_srcdir=`cd $top_srcdir; pwd`
+top_builddir=`cd $top_builddir; pwd`
+PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
 
 STAT_CONFIG_PATH=$top_srcdir/config
 export STAT_CONFIG_PATH
 
+LANG=C
+export LANG
 
 cleanup()
 {
+     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
+       echo "NOT cleaning $TEMPDIR" 
+       return ; 
+     fi
+     cd /
      rm -rf $TEMPDIR
 }
 
@@ -92,26 +101,23 @@ EOF
 if [ $? -ne 0 ] ; then no_result ; fi
 
 activity="run program"
-$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/variables.stat > $TEMPDIR/variables.err 2> $TEMPDIR/variables.out
+$SUPERVISOR $PSPP -o pspp.csv $TEMPDIR/variables.stat > $TEMPDIR/variables.err 2> $TEMPDIR/variables.out
 if [ $? -ne 0 ] ; then fail ; fi
 
 activity="compare results"
-diff -b -B $TEMPDIR/pspp.list - <<EOF
-1.1 DATA LIST.  Reading 1 record from the command file.
-+--------+------+-------+------+
-|Variable|Record|Columns|Format|
-#========#======#=======#======#
-|N1      |     1|  1-  1|F1.0  |
-|N2      |     1|  2-  2|F1.0  |
-|N3      |     1|  3-  3|F1.0  |
-|N4      |     1|  4-  4|F1.0  |
-|N5      |     1|  5-  5|F1.0  |
-+--------+------+-------+------+
-
-N1 N2 N3 N4 N5 P1 P2 P3 P4 P5 MC VC S1 S2 S3 S4 S5 M1 M2 M3 M4 M5 V1 V2 V3 V4 V5
--- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- 1  2  3  4  5  .  2  .  .  .  4  1  0  0  0  0  0  1  0  1  1  1  1  2  3  4  5 
- 6  7  8  9  .  6  7  8  9  .  1  4  0  0  0  0  1  0  0  0  0  1  6  7  8  9  . 
+diff -c $TEMPDIR/pspp.csv - <<EOF
+Table: Reading 1 record from INLINE.
+Variable,Record,Columns,Format
+N1,1,1-  1,F1.0
+N2,1,2-  2,F1.0
+N3,1,3-  3,F1.0
+N4,1,4-  4,F1.0
+N5,1,5-  5,F1.0
+
+Table: Data List
+N1,N2,N3,N4,N5,P1,P2,P3,P4,P5,MC,VC,S1,S2,S3,S4,S5,M1,M2,M3,M4,M5,V1,V2,V3,V4,V5
+1,2,3,4,5,.,2,.,.,.,4,1,0,0,0,0,0,1,0,1,1,1,1,2,3,4,5
+6,7,8,9,.,6,7,8,9,.,1,4,0,0,0,0,1,0,0,0,0,1,6,7,8,9,.
 EOF
 
 if [ $? -ne 0 ] ; then no_result ; fi