bc75db497339bcd3cf5d497766ee7259a065def9
[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 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
82 diff  -b $TEMPDIR/pspp.list - <<EOF
83 Variable Value Label
84 X            1
85 X Y
86 - -
87 1 2 
88 1 6 
89 1 7 
90 1 9 
91 1 5 
92 1 4 
93 Variable Value Label
94 X            2
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;