Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / flip.sh
1 #!/bin/sh
2
3 # This program tests the flip command
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 flip.stat"
51 cat > $TEMPDIR/flip.stat <<EOF
52 data list /N 1 (a) A B C D 2-9.
53 list.
54 begin data.
55 v 1 2 3 4 5
56 w 6 7 8 910
57 x1112131415
58 y1617181920
59 z2122232425
60 end data.
61 flip newnames=n.
62 list.
63 flip.
64 list.
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/flip.stat
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="compare output"
74 diff  -b -B $TEMPDIR/pspp.list - << EOF
75 1.1 DATA LIST.  Reading 1 record from the command file.
76 +--------+------+-------+------+
77 |Variable|Record|Columns|Format|
78 #========#======#=======#======#
79 |N       |     1|  1-  1|A1    |
80 |A       |     1|  2-  3|F2.0  |
81 |B       |     1|  4-  5|F2.0  |
82 |C       |     1|  6-  7|F2.0  |
83 |D       |     1|  8-  9|F2.0  |
84 +--------+------+-------+------+
85
86 N  A  B  C  D
87 - -- -- -- --
88 v  1  2  3  4 
89 w  6  7  8  9 
90 x 11 12 13 14 
91 y 16 17 18 19 
92 z 21 22 23 24 
93
94 CASE_LBL        V        W        X        Y        Z
95 -------- -------- -------- -------- -------- --------
96 A            1.00     6.00    11.00    16.00    21.00 
97 B            2.00     7.00    12.00    17.00    22.00 
98 C            3.00     8.00    13.00    18.00    23.00 
99 D            4.00     9.00    14.00    19.00    24.00 
100
101 CASE_LBL        A        B        C        D
102 -------- -------- -------- -------- --------
103 V            1.00     2.00     3.00     4.00 
104 W            6.00     7.00     8.00     9.00 
105 X           11.00    12.00    13.00    14.00 
106 Y           16.00    17.00    18.00    19.00 
107 Z           21.00    22.00    23.00    24.00 
108 EOF
109 if [ $? -ne 0 ] ; then fail ; fi
110
111
112 pass;