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