Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[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 diff -b -B $TEMPDIR/pspp.list - << foobar
84 1.1 DATA LIST.  Reading 1 record from the command file.
85 +--------+------+-------+------+
86 |Variable|Record|Columns|Format|
87 #========#======#=======#======#
88 |A       |     1|  1-  1|F1.0  |
89 |B       |     1|  2-  2|F1.0  |
90 +--------+------+-------+------+
91
92 A B
93 - -
94 1 2 
95 3 4 
96 5 6 
97 7 8 
98 9 0 
99
100 2.1 DATA LIST.  Reading 1 record from the command file.
101 +--------+------+-------+------+
102 |Variable|Record|Columns|Format|
103 #========#======#=======#======#
104 |A       |     1|  1-  1|F1.0  |
105 |B       |     1|  2-  2|F1.0  |
106 +--------+------+-------+------+
107
108 A B
109 - -
110 0 9 
111 8 7 
112 6 5 
113 4 3 
114 2 1 
115 foobar
116 if [ $? -ne 0 ] ; then fail ; fi
117
118
119 pass;