Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / autorecod.sh
1 #!/bin/sh
2
3 # This program tests the autorecode command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17
18 cleanup()
19 {
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 /* Tries AUTORECODE on some random but similar strings of characters.
54 data list /X 1-5(a) Y 7.
55 begin data.
56 lasdj 1 1                                                           3
57 asdfk 0 3 <---- These are the numbers that should be produced for a 4
58 asdfj 2 4                                                           2
59 asdfj 1 4                                                           3
60 asdfk 2 3                                                           2
61 asdfj 9 4                                                           1
62 lajks 9 2                                                           1
63 asdfk 0 3 These are the numbers that should be produced for b ----> 4
64 asdfk 1 3                                                           3
65 end data.
66
67 autorecode x y into A B/descend.
68
69 list.
70 /* Just to make sure it works on second & subsequent executions,
71 /* try it again.
72 compute Z=trunc(y/2).
73 autorecode z into W.
74 list.
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="run program"
79 $SUPERVISOR $here/../src/pspp    -o raw-ascii $TESTFILE
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="test output"
83 diff -b -B $TEMPDIR/pspp.list - <<EOF
84 1.1 DATA LIST.  Reading 1 record from the command file.
85 +--------+------+-------+------+
86 |Variable|Record|Columns|Format|
87 #========#======#=======#======#
88 |X       |     1|  1-  5|A5    |
89 |Y       |     1|  7-  7|F1.0  |
90 +--------+------+-------+------+
91
92     X Y        A        B
93 ----- - -------- --------
94 lasdj 1     1.00     3.00 
95 asdfk 0     3.00     4.00 
96 asdfj 2     4.00     2.00 
97 asdfj 1     4.00     3.00 
98 asdfk 2     3.00     2.00 
99 asdfj 9     4.00     1.00 
100 lajks 9     2.00     1.00 
101 asdfk 0     3.00     4.00 
102 asdfk 1     3.00     3.00 
103
104     X Y        A        B        Z        W
105 ----- - -------- -------- -------- --------
106 lasdj 1     1.00     3.00      .00     1.00 
107 asdfk 0     3.00     4.00      .00     1.00 
108 asdfj 2     4.00     2.00     1.00     2.00 
109 asdfj 1     4.00     3.00      .00     1.00 
110 asdfk 2     3.00     2.00     1.00     2.00 
111 asdfj 9     4.00     1.00     4.00     3.00 
112 lajks 9     2.00     1.00     4.00     3.00 
113 asdfk 0     3.00     4.00      .00     1.00 
114 asdfk 1     3.00     3.00      .00     1.00 
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118 pass
119
120
121