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 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
51 activity="create program"
52 cat > $TESTFILE << EOF
54 /* Set up a dummy active file in memory.
64 /* Add value labels for some further testing of value labels.
65 value labels x y 1 'first label' 2 'second label' 3 'third label'.
66 add value labels x 1 'first label mark two'.
68 /* Add a file label and a few documents.
69 file label This is a test file label.
70 document First line of a document
71 This is the second very long line of a document in an attempt to overflow the input buffer with a really long line
72 Note that the last line should end with a period: .
74 /* Display the documents.
76 display file label. /* undocumented feature of PSPP
78 /* Save the active file then get it and display the documents again.
79 save /OUTFILE='foo.save'.
82 display file label. /* undocumented feature of PSPP
84 /* There is an interesting interaction that occurs if the 'execute'
85 /* command below. What happens is that an error message is output
86 /* at the next 'save' command that 'foo.save' is already open for
87 /* input. This is because the 'get' hasn't been executed yet and
88 /* therefore PSPP would be reading from and writing to the same
89 /* file at once, which is obviously a Bad Thing. But 'execute'
90 /* here clears up that potential problem.
93 /* Add another (shorter) document and try again.
94 document There should be another document now.
98 save /OUTFILE='foo.save'.
101 display file label. /* undocumented feature of PSPP
106 if [ $? -ne 0 ] ; then no_result ; fi
108 activity="run program"
109 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE
110 if [ $? -ne 0 ] ; then no_result ; fi
112 # We need to filter out the dates/times
113 activity="date filter"
114 grep -v 'Document entered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
115 if [ $? -ne 0 ] ; then no_result ; fi
118 activity="compare results"
119 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.filtered
120 diff -b $TEMPDIR/pspp.filtered - <<EOF
121 1.1 DATA LIST. Reading 1 record from INLINE.
122 +--------+------+-------+------+
123 |Variable|Record|Columns|Format|
124 #========#======#=======#======#
127 +--------+------+-------+------+
128 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: .
133 This is a test file label
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: .
144 There should be another document now.
145 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: .
149 There should be another document now.
151 This is a test file label
153 if [ $? -ne 0 ] ; then fail ; fi