Add scratch file handles.
[pspp-builds.git] / tests / command / file-handle.sh
1 #!/bin/sh
2
3 # This program's primary purpose is to  test the FILE HANDLE command
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 file"
52 cat > $TEMPDIR/wiggle.txt << EOF
53 1
54 2
55 5
56 109
57 EOF
58 if [ $? -ne 0 ] ; then no_result ; fi
59
60
61
62 activity="create program"
63 cat > $TESTFILE << EOF
64 FILE HANDLE myhandle /NAME='$TEMPDIR/wiggle.txt'.
65 DATA LIST LIST FILE=myhandle /x *.
66 LIST.
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 activity="run program"
71 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="compare output"
76 diff  -b  $TEMPDIR/pspp.list - << EOF 
77 1.1 DATA LIST.  Reading free-form data from myhandle.
78 +--------+------+
79 |Variable|Format|
80 #========#======#
81 |x       |F8.0  |
82 +--------+------+
83
84        x
85 --------
86     1.00 
87     2.00 
88     5.00 
89   109.00 
90
91 EOF
92 if [ $? -ne 0 ] ; then fail ; fi
93
94
95 pass;