Added a test for the FILTER command
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 18 Dec 2003 02:12:11 +0000 (02:12 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 18 Dec 2003 02:12:11 +0000 (02:12 +0000)
tests/Makefile.am
tests/command/filter.sh [new file with mode: 0755]
tests/command/sys-info.sh [new file with mode: 0755]
tests/filter.stat [deleted file]

index 201a194657b0b5e772a1552cc9578105183b1fbd..b4a92fd2f2d03f40c2a99db66889a8fdaab969e7 100644 (file)
@@ -9,6 +9,7 @@ TESTS = command/aggregate.sh \
        command/compute.sh \
        command/descriptives.sh \
        command/file-label.sh \
+       command/filter.sh \
        command/flip.sh \
        command/lag.sh \
        command/list.sh \
@@ -29,15 +30,7 @@ noinst_DATA = sort.data
 sort.data: gengarbage$(EXTEXT)
        ./gengarbage | head -1000 > $@
 
-EXTRA_DIST = \
-crosstabs.stat data-fmts.stat  \
-data-list.data do-if.stat do-repeat.stat       \
-expr.stat filter.stat gengarbage.c             \
-inpt-pgm.stat list.data mtch-file.stat  \
-means.stat mdfy-vars.stat pcs-if.stat recode.stat \
-repeating.stat reread.data reread.stat  \
-sys-info.stat t-test.stat temporary.stat       \
-time-date.stat vector.stat weighting.data weighting.stat $(TESTS)
+EXTRA_DIST = $(TESTS)
 
 DISTCLEANFILES = *.save sort.data pspp.* foo* msgs *.actual
 
diff --git a/tests/command/filter.sh b/tests/command/filter.sh
new file mode 100755 (executable)
index 0000000..180b59f
--- /dev/null
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+# This program tests ....
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TEMPDIR/filter.stat << EOF
+data list notable /x 1-2.
+begin data.
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+end data.
+compute filter_$ = mod(x,2).
+
+filter by filter_$.
+list.
+filter off.
+list.
+compute filter_$ = 1 - filter_$.
+filter by filter_$.
+list.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/filter.stat
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="check results"
+diff -B -b $TEMPDIR/pspp.list - << EOF
+ X FILTER_$
+-- --------
+ 1     1.00 
+ 3     1.00 
+ 5     1.00 
+ 7     1.00 
+ 9     1.00 
+
+ X FILTER_$
+-- --------
+ 1     1.00 
+ 2      .00 
+ 3     1.00 
+ 4      .00 
+ 5     1.00 
+ 6      .00 
+ 7     1.00 
+ 8      .00 
+ 9     1.00 
+10      .00 
+
+ X FILTER_$
+-- --------
+ 2     1.00 
+ 4     1.00 
+ 6     1.00 
+ 8     1.00 
+10     1.00 
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;
diff --git a/tests/command/sys-info.sh b/tests/command/sys-info.sh
new file mode 100755 (executable)
index 0000000..35a64c8
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+# This program tests the SYSFILE INFO command
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program 1"
+cat > $TEMPDIR/save.stat << EOF
+data list /x 1-2.
+begin data.
+3
+34
+2
+98
+end data.
+save 'foo.save'.
+display $JDATE.
+finish.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+cp $TEMPDIR/pspp.list /tmp/bar
+
+activity="run program 1"
+$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/save.stat
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="create program 2"
+cat > $TEMPDIR/read.stat << EOF
+sysfile info file='foo.save'.
+
+finish.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program 2"
+$here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/read.stat
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="compare output"
+diff -B -b $TEMPDIR/pspp.list - << EOF
+1.1 SYSFILE INFO.  
+File:      $TEMPDIR/foo.save
+Label:     No label.
+Created:   18 Dec 03 09:05:20 by GNU pspp 0.3.1 - i686-pc-cygwin        
+Endian:    Little.
+Variables: 1
+Cases:     4
+Type:      System File.
+Weight:    Not weighted.
+Mode:      Compression on.
++--------+-------------+---+
+|Variable|Description  |Pos|
+|        |             |iti|
+|        |             |on |
+#========#=============#===#
+|X       |Format: F2.0 |  1|
++--------+-------------+---+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;
diff --git a/tests/filter.stat b/tests/filter.stat
deleted file mode 100644 (file)
index 3761e38..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-title 'Test FILTER'.
-
-data list /x 1-2.
-begin data.
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-end data.
-compute filter_$ = mod(x,2).
-filter by filter_$.
-list.
-compute filter_$ = 1 - filter_$.
-list.
-