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