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