Fixed a buglet in the ERASE command, added a test for it, and some documentation.
[pspp-builds.git] / tests / command / erase.sh
1 #!/bin/sh
2
3 # This program tests the ERASE command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create file"
49 cat > $TEMPDIR/foobar <<EOF
50 xyzzy
51 EOF
52 if [ $? -ne 0 ] ; then no_result ; fi
53
54 activity="check for file 1"
55 if [ ! -f $TEMPDIR/foobar ] ; then no_result ; fi 
56
57
58 activity="create program 1"
59 cat > $TEMPDIR/foo.sps <<EOF
60 set safer on
61
62 erase FILE='foobar'.
63
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 # foobar must still exist
68 activity="check for file 2"
69 if [ ! -f $TEMPDIR/foobar ] ; then fail ; fi 
70
71 # This command must fail
72 activity="run prog 1"
73 $here/../src/pspp $TEMPDIR/foo.sps > /dev/null
74 if [ $? -eq 0 ] ; then fail ; fi
75
76
77 activity="create program 2"
78 cat > $TEMPDIR/foo.sps <<EOF
79
80 erase FILE='foobar'.
81
82 EOF
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85
86 activity="run prog 1"
87 $here/../src/pspp $TEMPDIR/foo.sps
88 if [ $? -ne 0 ] ; then fail ; fi
89
90 # foobar should now be gone
91 if [ -f $TEMPDIR/foobar ] ; then fail ; fi 
92
93
94
95
96
97
98 if [ $? -ne 0 ] ; then fail ; fi
99
100
101
102 pass;