ff07349577a0a19a83d8fc25809ebb9883f6c25e
[pspp-builds.git] / tests / bugs / examine-missing2.sh
1 #!/bin/sh
2
3 # This program tests for a bug in which examine didn't
4 # count missing values.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_srcdir and top_builddir  are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14
15 PSPP=$top_builddir/src/ui/terminal/pspp
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
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 /x * y *.
64 BEGIN DATA.
65 1   1 
66 2   1
67 3   1
68 4   1
69 5   2
70 6   2
71 .   2
72 END DATA
73
74 EXAMINE /x by y.
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78
79 activity="run program"
80 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83 activity="compare results"
84 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
85 diff -b  $TEMPDIR/pspp.list - <<EOF
86 1.1 DATA LIST.  Reading free-form data from INLINE.
87 +--------+------+
88 |Variable|Format|
89 #========#======#
90 |x       |F8.0  |
91 |y       |F8.0  |
92 +--------+------+
93 2.1 EXAMINE.  Case Processing Summary
94 #=#=============================#
95 # #            Cases            #
96 # #---------+---------+---------#
97 # #  Valid  | Missing |  Total  #
98 # #-+-------+-+-------+-+-------#
99 # #N|Percent|N|Percent|N|Percent#
100 #=#=#=======#=#=======#=#=======#
101 #x#6|    86%|1|    14%|7|   100%#
102 #=#=#=======#=#=======#=#=======#
103 2.2 EXAMINE.  Case Processing Summary
104 #==========#=============================#
105 #          #            Cases            #
106 #          #---------+---------+---------#
107 #          #  Valid  | Missing |  Total  #
108 #          #-+-------+-+-------+-+-------#
109 #      y   #N|Percent|N|Percent|N|Percent#
110 #==========#=#=======#=#=======#=#=======#
111 #x     1.00#4|   100%|0|     0%|4|   100%#
112 #      2.00#2|    67%|1|    33%|3|   100%#
113 #==========#=#=======#=#=======#=#=======#
114 EOF
115 if [ $? -ne 0 ] ; then fail ; fi
116
117 pass;