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