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