2295a1215ee1082d6e0355d7701218b529c2162a
[pspp-builds.git] / tests / command / rename.sh
1 #!/bin/sh
2
3 # This program tests that the rename command works properly
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
52 DATA LIST LIST /brakeFluid * y * .
53 BEGIN DATA.
54 1 3
55 2 3
56 3 3
57 4 3
58 END DATA.
59
60 LIST.
61
62 RENAME VARIABLES (brakeFluid=applecarts).
63
64 LIST.
65
66 SAVE /OUTFILE='$TEMPDIR/rename.sav'.
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70
71 activity="run program"
72 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 activity="check sysfile"
76 grep -i Brake $TEMPDIR/rename.sav
77 if [ $? -eq 0 ] ; then fail ; fi
78
79 activity="compare output"
80 diff -B -b $TEMPDIR/pspp.list - <<EOF
81 1.1 DATA LIST.  Reading free-form data from the command file.
82 +----------+------+
83 | Variable |Format|
84 #==========#======#
85 |brakeFluid|F8.0  |
86 |y         |F8.0  |
87 +----------+------+
88
89 brakeFluid        y
90 ---------- --------
91       1.00     3.00 
92       2.00     3.00 
93       3.00     3.00 
94       4.00     3.00 
95
96 applecarts        y
97 ---------- --------
98       1.00     3.00 
99       2.00     3.00 
100       3.00     3.00 
101       4.00     3.00 
102
103 EOF
104 if [ $? -ne 0 ] ; then fail ; fi
105
106 pass