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 $SUPERVISOR $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
116 activity="compare results"
117 diff -b -B $TEMPDIR/pspp.filtered - <<EOF
118 1.1 DATA LIST. Reading 1 record from the command file.
119 +--------+------+-------+------+
120 |Variable|Record|Columns|Format|
121 #========#======#=======#======#
124 +--------+------+-------+------+
126 Documents in the active file:
128 First line of a document
129 This is the second very long line of a document in an attempt to overflow the
130 Note that the last line should end with a period: .
133 This is a test file label
135 Documents in the active file:
137 First line of a document
138 This is the second very long line of a document in an attempt to overflow the
139 Note that the last line should end with a period: .
142 This is a test file label
144 Documents in the active file:
146 First line of a document
147 This is the second very long line of a document in an attempt to overflow the
148 Note that the last line should end with a period: .
150 There should be another document now.
152 Documents in the active file:
154 First line of a document
155 This is the second very long line of a document in an attempt to overflow the
156 Note that the last line should end with a period: .
158 There should be another document now.
161 This is a test file label
163 if [ $? -ne 0 ] ; then fail ; fi