Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[pspp-builds.git] / tests / command / split-file.sh
1 #!/bin/sh
2
3 # This program tests the split file 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 program"
52 cat > $TEMPDIR/split.stat <<EOF
53 title 'Test SPLIT FILE utility'.
54
55 data list notable /X 1 Y 2.
56 begin data.
57 12
58 16
59 17
60 19
61 15
62 14
63 27
64 20
65 26
66 25
67 28
68 29
69 24
70 end data.
71 split file by x.
72 list.
73 EOF
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76 activity="run program"
77 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/split.stat
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="compare results"
81 diff -B -b $TEMPDIR/pspp.list - <<EOF
82 Variable Value Label
83 X            1
84
85 X Y
86 - -
87 1 2 
88 1 6 
89 1 7 
90 1 9 
91 1 5 
92 1 4 
93
94 Variable Value Label
95 X            2
96
97 X Y
98 - -
99 2 7 
100 2 0 
101 2 6 
102 2 5 
103 2 8 
104 2 9 
105 2 4
106 EOF
107 if [ $? -ne 0 ] ; then fail ; fi
108
109 pass;