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