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
57 activity="create program"
58 cat > $TESTFILE << EOF
60 /* Set up a dummy active file in memory.
70 /* Add value labels for some further testing of value labels.
71 value labels x y 1 'first label' 2 'second label' 3 'third label'.
72 add value labels x 1 'first label mark two'.
74 /* Add a file label and a few documents.
75 file label This is a test file label.
76 document First line of a document
77 Second line of a document
78 The last line should end with a period: .
81 /* Display the documents.
85 ADD DOCUMENT 'Line one' 'Line two'.
87 /* Save the active file then get it and display the documents again.
88 save /OUTFILE='foo.save'.
93 /* There is an interesting interaction that occurs if the 'execute'
94 /* command below. What happens is that an error message is output
95 /* at the next 'save' command that 'foo.save' is already open for
96 /* input. This is because the 'get' hasn't been executed yet and
97 /* therefore PSPP would be reading from and writing to the same
98 /* file at once, which is obviously a Bad Thing. But 'execute'
99 /* here clears up that potential problem.
102 /* Add another (shorter) document and try again.
103 document There should be another document now.
107 save /OUTFILE='foo.save'.
108 get /FILE='foo.save'.
115 if [ $? -ne 0 ] ; then no_result ; fi
117 activity="run program"
118 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
119 if [ $? -ne 0 ] ; then no_result ; fi
121 # We need to filter out the dates/times
122 activity="date filter"
123 grep -v '[Ee]ntered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
124 if [ $? -ne 0 ] ; then no_result ; fi
127 activity="compare results"
128 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.filtered
129 diff -b $TEMPDIR/pspp.filtered - <<EOF
130 1.1 DATA LIST. Reading 1 record from INLINE.
131 +--------+------+-------+------+
132 |Variable|Record|Columns|Format|
133 #========#======#=======#======#
136 +--------+------+-------+------+
137 Documents in the active file:
138 document First line of a document
139 Second line of a document
140 The last line should end with a period: .
142 This is a test file label
143 Documents in the active file:
144 document First line of a document
145 Second line of a document
146 The last line should end with a period: .
150 This is a test file label
151 Documents in the active file:
152 document First line of a document
153 Second line of a document
154 The last line should end with a period: .
157 document There should be another document now.
158 Documents in the active file:
159 document First line of a document
160 Second line of a document
161 The last line should end with a period: .
164 document There should be another document now.
166 This is a test file label
168 if [ $? -ne 0 ] ; then fail ; fi