47f2fa883d0f8410b0bdb1f62db1ade732dba917
[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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TEMPDIR/split.stat <<EOF
51 title 'Test SPLIT FILE utility'.
52
53 data list notable /X 1 Y 2.
54 begin data.
55 12
56 16
57 17
58 19
59 15
60 14
61 27
62 20
63 26
64 25
65 28
66 29
67 24
68 end data.
69 split file by x.
70 list.
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 activity="run program"
75 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/split.stat
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="compare results"
79 diff -B -b $TEMPDIR/pspp.list - <<EOF
80 Variable Value Label
81 X            1
82
83 X Y
84 - -
85 1 2 
86 1 6 
87 1 7 
88 1 9 
89 1 5 
90 1 4 
91
92 Variable Value Label
93 X            2
94
95 X Y
96 - -
97 2 7 
98 2 0 
99 2 6 
100 2 5 
101 2 8 
102 2 9 
103 2 4
104 EOF
105 if [ $? -ne 0 ] ; then fail ; fi
106
107 pass;