LOOP: Convert tests to Autotest framework.
[pspp] / tests / bugs / match-files-scratch.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused MATCH FILES to crash
4 # when used with scratch variables.
5
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.pspp
9
10 # ensure that top_builddir  are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
15
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
18
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 DATA LIST LIST /w * x * y * .
64 BEGIN DATA
65 4 5 6
66 1 2 3
67 END DATA.
68
69 COMPUTE j=0.
70 LOOP #k = 1 to 10.
71 COMPUTE j=#k + j.
72 END LOOP.
73
74 MATCH FILES FILE=* /DROP=w.
75 LIST.
76 FINISH.
77
78 EOF
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84
85 diff -c $TEMPDIR/pspp.csv - << EOF
86 Table: Reading free-form data from INLINE.
87 Variable,Format
88 w,F8.0
89 x,F8.0
90 y,F8.0
91
92 Table: Data List
93 x,y,j
94 5.00,6.00,55.00
95 2.00,3.00,55.00
96 EOF
97 if [ $? -ne 0 ] ; then fail ; fi
98
99 pass;