3 # This program tests the FILE LABEL and DOCUMENT, and ADD DOCUMENT commands
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
8 # ensure that top_builddir are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
25 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
26 echo "NOT cleaning $TEMPDIR"
61 activity="create program"
62 cat > $TESTFILE << EOF
64 /* Set up a dummy active file in memory.
74 /* Add value labels for some further testing of value labels.
75 value labels x y 1 'first label' 2 'second label' 3 'third label'.
76 add value labels x 1 'first label mark two'.
78 /* Add a file label and a few documents.
79 file label This is a test file label.
80 document First line of a document
81 Second line of a document
82 The last line should end with a period: .
85 /* Display the documents.
89 ADD DOCUMENT 'Line one' 'Line two'.
91 /* Save the active file then get it and display the documents again.
92 save /OUTFILE='foo.save'.
97 /* There is an interesting interaction that occurs if the 'execute'
98 /* command below. What happens is that an error message is output
99 /* at the next 'save' command that 'foo.save' is already open for
100 /* input. This is because the 'get' hasn't been executed yet and
101 /* therefore PSPP would be reading from and writing to the same
102 /* file at once, which is obviously a Bad Thing. But 'execute'
103 /* here clears up that potential problem.
106 /* Add another (shorter) document and try again.
107 document There should be another document now.
111 save /OUTFILE='foo.save'.
112 get /FILE='foo.save'.
119 if [ $? -ne 0 ] ; then no_result ; fi
121 activity="run program"
122 $SUPERVISOR $PSPP --testing-mode $TESTFILE
123 if [ $? -ne 0 ] ; then no_result ; fi
125 # We need to filter out the dates/times
126 activity="date filter"
127 grep -v '[Ee]ntered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
128 if [ $? -ne 0 ] ; then no_result ; fi
131 activity="compare results"
132 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.filtered
133 diff -b $TEMPDIR/pspp.filtered - <<EOF
134 1.1 DATA LIST. Reading 1 record from INLINE.
135 +--------+------+-------+------+
136 |Variable|Record|Columns|Format|
137 #========#======#=======#======#
140 +--------+------+-------+------+
141 Documents in the active file:
142 document First line of a document
143 Second line of a document
144 The last line should end with a period: .
146 This is a test file label
147 Documents in the active file:
148 document First line of a document
149 Second line of a document
150 The last line should end with a period: .
154 This is a test file label
155 Documents in the active file:
156 document First line of a document
157 Second line of a document
158 The last line should end with a period: .
161 document There should be another document now.
162 Documents in the active file:
163 document First line of a document
164 Second line of a document
165 The last line should end with a period: .
168 document There should be another document now.
170 This is a test file label
172 if [ $? -ne 0 ] ; then fail ; fi