a55a3246e04a626611e10f363ba69b3c0ea8d2b3
[pspp-builds.git] / 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 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      cd /
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53 activity="create program"
54 cat > $TESTFILE <<EOF
55 DATA LIST LIST /w * x * y * .
56 BEGIN DATA
57 4 5 6
58 1 2 3
59 END DATA.
60
61 COMPUTE j=0.
62 LOOP #k = 1 to 10.
63 COMPUTE j=#k + j.
64 END LOOP.
65
66 MATCH FILES FILE=* /DROP=w.
67 LIST.
68 FINISH.
69
70 EOF
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76
77 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
78 diff -b  -w $TEMPDIR/pspp.list - << EOF
79 1.1 DATA LIST.  Reading free-form data from INLINE.
80 +--------+------+
81 |Variable|Format|
82 #========#======#
83 |w       |F8.0  |
84 |x       |F8.0  |
85 |y       |F8.0  |
86 +--------+------+
87        x        y        j
88 -------- -------- --------
89     5.00     6.00    55.00 
90     2.00     3.00    55.00 
91 EOF
92 if [ $? -ne 0 ] ; then fail ; fi
93
94 pass;