4820ab660fea114384da1ede0e2bc812ab678703
[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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TESTFILE << EOF_foobar
51 title 'Test BEGIN DATA ... END DATA'.
52
53 data list /A B 1-2.
54 list.
55 begin data.
56 12
57 34
58 56
59 78
60 90
61 end data.
62
63 data list /A B 1-2.
64 begin data.
65 09
66 87
67 65
68 43
69 21
70 end data.
71 list.
72 EOF_foobar
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75
76 activity="run program"
77 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="compare data"
81 diff -b -B $TEMPDIR/pspp.list - << foobar
82 1.1 DATA LIST.  Reading 1 record from the command file.
83 +--------+------+-------+------+
84 |Variable|Record|Columns|Format|
85 #========#======#=======#======#
86 |A       |     1|  1-  1|F1.0  |
87 |B       |     1|  2-  2|F1.0  |
88 +--------+------+-------+------+
89
90 A B
91 - -
92 1 2 
93 3 4 
94 5 6 
95 7 8 
96 9 0 
97
98 2.1 DATA LIST.  Reading 1 record from the command file.
99 +--------+------+-------+------+
100 |Variable|Record|Columns|Format|
101 #========#======#=======#======#
102 |A       |     1|  1-  1|F1.0  |
103 |B       |     1|  2-  2|F1.0  |
104 +--------+------+-------+------+
105
106 A B
107 - -
108 0 9 
109 8 7 
110 6 5 
111 4 3 
112 2 1 
113 foobar
114 if [ $? -ne 0 ] ; then fail ; fi
115
116
117 pass;