(main): When testing mode is enabled, use a built-in output driver
[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 # 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
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      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 activity="create program"
58 cat > $TESTFILE <<EOF
59 DATA LIST LIST /w * x * y * .
60 BEGIN DATA
61 4 5 6
62 1 2 3
63 END DATA.
64
65 COMPUTE j=0.
66 LOOP #k = 1 to 10.
67 COMPUTE j=#k + j.
68 END LOOP.
69
70 MATCH FILES FILE=* /DROP=w.
71 LIST.
72 FINISH.
73
74 EOF
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 $SUPERVISOR $PSPP --testing-mode $TESTFILE
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80
81 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
82 diff -b  -w $TEMPDIR/pspp.list - << EOF
83 1.1 DATA LIST.  Reading free-form data from INLINE.
84 +--------+------+
85 |Variable|Format|
86 #========#======#
87 |w       |F8.0  |
88 |x       |F8.0  |
89 |y       |F8.0  |
90 +--------+------+
91        x        y        j
92 -------- -------- --------
93     5.00     6.00    55.00 
94     2.00     3.00    55.00 
95 EOF
96 if [ $? -ne 0 ] ; then fail ; fi
97
98 pass;