3 # This program tests the FILE LABEL and DOCUMENT commands
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
13 export STAT_CONFIG_PATH=$top_srcdir/config
49 activity="create program"
50 cat > $TEMPDIR/file-lab.stat << EOF
53 /* Set up a dummy active file in memory.
63 /* Add value labels for some further testing of value labels.
64 value labels x y 1 'first label' 2 'second label' 3 'third label'.
65 add value labels x 1 'first label mark two'.
67 /* Add a file label and a few documents.
68 file label This is a test file label.
69 document First line of a document
70 This is the second very long line of a document in an attempt to overflow the input buffer with a really long line
71 Note that the last line should end with a period: .
73 /* Display the documents.
75 display file label. /* undocumented feature of PSPP
77 /* Save the active file then get it and display the documents again.
81 display file label. /* undocumented feature of PSPP
83 /* There is an interesting interaction that occurs if the 'execute'
84 /* command below. What happens is that an error message is output
85 /* at the next 'save' command that 'foo.save' is already open for
86 /* input. This is because the 'get' hasn't been executed yet and
87 /* therefore PSPP would be reading from and writing to the same
88 /* file at once, which is obviously a Bad Thing. But 'execute'
89 /* here clears up that potential problem.
92 /* Add another (shorter) document and try again.
93 document There should be another document now.
100 display file label. /* undocumented feature of PSPP
105 if [ $? -ne 0 ] ; then no_result ; fi
107 activity="run program"
108 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/file-lab.stat
109 if [ $? -ne 0 ] ; then no_result ; fi
111 # We need to filter out the dates/times
112 activity="date filter"
113 grep -v 'Document entered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
114 if [ $? -ne 0 ] ; then no_result ; fi
117 activity="compare results"
118 diff -b -B $TEMPDIR/pspp.filtered - <<EOF
119 1.1 DATA LIST. Reading 1 record from the command file.
120 +--------+------+-------+------+
121 |Variable|Record|Columns|Format|
122 #========#======#=======#======#
125 +--------+------+-------+------+
127 Documents in the active file:
129 First line of a document
130 This is the second very long line of a document in an attempt to overflow the
131 Note that the last line should end with a period: .
134 This is a test file label
136 Documents in the active file:
138 First line of a document
139 This is the second very long line of a document in an attempt to overflow the
140 Note that the last line should end with a period: .
143 This is a test file label
145 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: .
151 There should be another document now.
153 Documents in the active file:
155 First line of a document
156 This is the second very long line of a document in an attempt to overflow the
157 Note that the last line should end with a period: .
159 There should be another document now.
162 This is a test file label
164 if [ $? -ne 0 ] ; then fail ; fi