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