Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / import-export.sh
1 #!/bin/sh
2
3 # This program tests the IMPORT and EXPORT commands
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      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create program"
51 cat > $TESTFILE <<EOF
52 DATA LIST LIST /X * Y *.
53 BEGIN DATA.
54 1 2
55 3 4
56 5 6
57 END DATA.
58
59 EXPORT /OUTFILE='wiz.por'.
60
61 LIST.
62
63 IMPORT /FILE='wiz.por'.
64
65 LIST.
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
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 activity="compare output"
75 diff -b -B $TEMPDIR/pspp.list - << EOF
76 1.1 DATA LIST.  Reading free-form data from the command file.
77 +--------+------+
78 |Variable|Format|
79 #========#======#
80 |X       |F8.0  |
81 |Y       |F8.0  |
82 +--------+------+
83
84        X        Y
85 -------- --------
86     1.00     2.00 
87     3.00     4.00 
88     5.00     6.00 
89
90        X        Y
91 -------- --------
92     1.00     2.00 
93     3.00     4.00 
94     5.00     6.00 
95
96 EOF
97 if [ $? -ne 0 ] ; then fail ; fi
98
99 pass;