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
55 activity="create program"
56 cat > $TESTFILE << EOF
58 /* Set up a dummy active file in memory.
68 /* Add value labels for some further testing of value labels.
69 value labels x y 1 'first label' 2 'second label' 3 'third label'.
70 add value labels x 1 'first label mark two'.
72 /* Add a file label and a few documents.
73 file label This is a test file label.
74 document First line of a document
75 This is the second very long line of a document in an attempt to overflow the input buffer with a really long line
76 Note that the last line should end with a period: .
78 /* Display the documents.
80 display file label. /* undocumented feature of PSPP
82 /* Save the active file then get it and display the documents again.
83 save /OUTFILE='foo.save'.
86 display file label. /* undocumented feature of PSPP
88 /* There is an interesting interaction that occurs if the 'execute'
89 /* command below. What happens is that an error message is output
90 /* at the next 'save' command that 'foo.save' is already open for
91 /* input. This is because the 'get' hasn't been executed yet and
92 /* therefore PSPP would be reading from and writing to the same
93 /* file at once, which is obviously a Bad Thing. But 'execute'
94 /* here clears up that potential problem.
97 /* Add another (shorter) document and try again.
98 document There should be another document now.
102 save /OUTFILE='foo.save'.
103 get /FILE='foo.save'.
105 display file label. /* undocumented feature of PSPP
110 if [ $? -ne 0 ] ; then no_result ; fi
112 activity="run program"
113 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
114 if [ $? -ne 0 ] ; then no_result ; fi
116 # We need to filter out the dates/times
117 activity="date filter"
118 grep -v 'Document entered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
119 if [ $? -ne 0 ] ; then no_result ; fi
122 activity="compare results"
123 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.filtered
124 diff -b $TEMPDIR/pspp.filtered - <<EOF
125 1.1 DATA LIST. Reading 1 record from INLINE.
126 +--------+------+-------+------+
127 |Variable|Record|Columns|Format|
128 #========#======#=======#======#
131 +--------+------+-------+------+
132 Documents in the active file:
133 First line of a document
134 This is the second very long line of a document in an attempt to overflow the
135 Note that the last line should end with a period: .
137 This is a test file label
138 Documents in the active file:
139 First line of a document
140 This is the second very long line of a document in an attempt to overflow the
141 Note that the last line should end with a period: .
143 This is a test file label
144 Documents in the active file:
145 First line of a document
146 This is the second very long line of a document in an attempt to overflow the
147 Note that the last line should end with a period: .
148 There should be another document now.
149 Documents in the active file:
150 First line of a document
151 This is the second very long line of a document in an attempt to overflow the
152 Note that the last line should end with a period: .
153 There should be another document now.
155 This is a test file label
157 if [ $? -ne 0 ] ; then fail ; fi