4c6ee92d3edf4c53e754d58ca4bbf0c79f1505f3
[pspp-builds.git] / tests / command / beg-data.sh
1 #!/bin/sh
2
3 # This program tests the BEGIN DATA / END DATA commands
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
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_foobar
53 title 'Test BEGIN DATA ... END DATA'.
54
55 data list /A B 1-2.
56 list.
57 begin data.
58 12
59 34
60 56
61 78
62 90
63 end data.
64
65 data list /A B 1-2.
66 begin data.
67 09
68 87
69 65
70 43
71 21
72 end data.
73 list.
74 EOF_foobar
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77
78 activity="run program"
79 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="compare data"
83 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
84 diff -b $TEMPDIR/pspp.list - << foobar |perl -e 's/^\s*$//g'
85 1.1 DATA LIST.  Reading 1 record from the command file.
86 +--------+------+-------+------+
87 |Variable|Record|Columns|Format|
88 #========#======#=======#======#
89 |A       |     1|  1-  1|F1.0  |
90 |B       |     1|  2-  2|F1.0  |
91 +--------+------+-------+------+
92
93 A B
94 - -
95 1 2 
96 3 4 
97 5 6 
98 7 8 
99 9 0 
100
101 2.1 DATA LIST.  Reading 1 record from the command file.
102 +--------+------+-------+------+
103 |Variable|Record|Columns|Format|
104 #========#======#=======#======#
105 |A       |     1|  1-  1|F1.0  |
106 |B       |     1|  2-  2|F1.0  |
107 +--------+------+-------+------+
108
109 A B
110 - -
111 0 9 
112 8 7 
113 6 5 
114 4 3 
115 2 1 
116 foobar
117 if [ $? -ne 0 ] ; then fail ; fi
118
119
120 pass;