3 # This program tests the FILE LABEL and 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 This is the second very long line of a document in an attempt to overflow the input buffer with a really long line
78 Note that the last line should end with a period: .
80 /* Display the documents.
82 display file label. /* undocumented feature of PSPP
84 /* Save the active file then get it and display the documents again.
85 save /OUTFILE='foo.save'.
88 display file label. /* undocumented feature of PSPP
90 /* There is an interesting interaction that occurs if the 'execute'
91 /* command below. What happens is that an error message is output
92 /* at the next 'save' command that 'foo.save' is already open for
93 /* input. This is because the 'get' hasn't been executed yet and
94 /* therefore PSPP would be reading from and writing to the same
95 /* file at once, which is obviously a Bad Thing. But 'execute'
96 /* here clears up that potential problem.
99 /* Add another (shorter) document and try again.
100 document There should be another document now.
104 save /OUTFILE='foo.save'.
105 get /FILE='foo.save'.
107 display file label. /* undocumented feature of PSPP
112 if [ $? -ne 0 ] ; then no_result ; fi
114 activity="run program"
115 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
116 if [ $? -ne 0 ] ; then no_result ; fi
118 # We need to filter out the dates/times
119 activity="date filter"
120 grep -v 'Document entered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
121 if [ $? -ne 0 ] ; then no_result ; fi
124 activity="compare results"
125 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.filtered
126 diff -b $TEMPDIR/pspp.filtered - <<EOF
127 1.1 DATA LIST. Reading 1 record from INLINE.
128 +--------+------+-------+------+
129 |Variable|Record|Columns|Format|
130 #========#======#=======#======#
133 +--------+------+-------+------+
134 Documents in the active file:
135 First line of a document
136 This is the second very long line of a document in an attempt to overflow the
137 Note that the last line should end with a period: .
139 This is a test file label
140 Documents in the active file:
141 First line of a document
142 This is the second very long line of a document in an attempt to overflow the
143 Note that the last line should end with a period: .
145 This is a test file label
146 Documents in the active file:
147 First line of a document
148 This is the second very long line of a document in an attempt to overflow the
149 Note that the last line should end with a period: .
150 There should be another document now.
151 Documents in the active file:
152 First line of a document
153 This is the second very long line of a document in an attempt to overflow the
154 Note that the last line should end with a period: .
155 There should be another document now.
157 This is a test file label
159 if [ $? -ne 0 ] ; then fail ; fi