New implementation of long variable names. Each variable has a
[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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TESTFILE <<EOF
51 DATA LIST LIST /brakeFluid * y * .
52 BEGIN DATA.
53 1 3
54 2 3
55 3 3
56 4 3
57 END DATA.
58
59 LIST.
60
61 RENAME VARIABLES (brakeFluid=applecarts).
62
63 LIST.
64
65 SAVE /OUTFILE='$TEMPDIR/rename.sav'.
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69
70 activity="run program"
71 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 activity="check sysfile"
75 grep -i Brake $TEMPDIR/rename.sav
76 if [ $? -eq 0 ] ; then fail ; fi
77
78 activity="compare output"
79 diff -B -b $TEMPDIR/pspp.list - <<EOF
80 1.1 DATA LIST.  Reading free-form data from the command file.
81 +----------+------+
82 | Variable |Format|
83 #==========#======#
84 |brakeFluid|F8.0  |
85 |y         |F8.0  |
86 +----------+------+
87
88 brakeFluid        y
89 ---------- --------
90       1.00     3.00 
91       2.00     3.00 
92       3.00     3.00 
93       4.00     3.00 
94
95 applecarts        y
96 ---------- --------
97       1.00     3.00 
98       2.00     3.00 
99       3.00     3.00 
100       4.00     3.00 
101
102 EOF
103 if [ $? -ne 0 ] ; then fail ; fi
104
105 pass