Updated the developers' manual to reflect the new situation
[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      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 DATA LIST LIST /brakeFluid * y * .
64 BEGIN DATA.
65 1 3
66 2 3
67 3 3
68 4 3
69 END DATA.
70
71 LIST.
72
73 RENAME VARIABLES (brakeFluid=applecarts).
74
75 LIST.
76
77 SAVE /OUTFILE='$TEMPDIR/rename.sav'.
78 EOF
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81
82 activity="run program"
83 $SUPERVISOR $PSPP --testing-mode $TESTFILE
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="check sysfile"
87 grep -i Brake $TEMPDIR/rename.sav
88 if [ $? -eq 0 ] ; then fail ; fi
89
90 activity="compare output"
91 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
92 diff  -b $TEMPDIR/pspp.list - <<EOF
93 1.1 DATA LIST.  Reading free-form data from INLINE.
94 +----------+------+
95 | Variable |Format|
96 #==========#======#
97 |brakeFluid|F8.0  |
98 |y         |F8.0  |
99 +----------+------+
100 brakeFluid        y
101 ---------- --------
102       1.00     3.00 
103       2.00     3.00 
104       3.00     3.00 
105       4.00     3.00 
106 applecarts        y
107 ---------- --------
108       1.00     3.00 
109       2.00     3.00 
110       3.00     3.00 
111       4.00     3.00 
112 EOF
113 if [ $? -ne 0 ] ; then fail ; fi
114
115 pass