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`
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
54 activity="create program"
55 cat > $TESTFILE << EOF
57 /* Set up a dummy active file in memory.
67 /* Add value labels for some further testing of value labels.
68 value labels x y 1 'first label' 2 'second label' 3 'third label'.
69 add value labels x 1 'first label mark two'.
71 /* Add a file label and a few documents.
72 file label This is a test file label.
73 document First line of a document
74 This is the second very long line of a document in an attempt to overflow the input buffer with a really long line
75 Note that the last line should end with a period: .
77 /* Display the documents.
79 display file label. /* undocumented feature of PSPP
81 /* Save the active file then get it and display the documents again.
82 save /OUTFILE='foo.save'.
85 display file label. /* undocumented feature of PSPP
87 /* There is an interesting interaction that occurs if the 'execute'
88 /* command below. What happens is that an error message is output
89 /* at the next 'save' command that 'foo.save' is already open for
90 /* input. This is because the 'get' hasn't been executed yet and
91 /* therefore PSPP would be reading from and writing to the same
92 /* file at once, which is obviously a Bad Thing. But 'execute'
93 /* here clears up that potential problem.
96 /* Add another (shorter) document and try again.
97 document There should be another document now.
101 save /OUTFILE='foo.save'.
102 get /FILE='foo.save'.
104 display file label. /* undocumented feature of PSPP
109 if [ $? -ne 0 ] ; then no_result ; fi
111 activity="run program"
112 $SUPERVISOR $top_builddir/src/pspp --testing-mode -o raw-ascii $TESTFILE
113 if [ $? -ne 0 ] ; then no_result ; fi
115 # We need to filter out the dates/times
116 activity="date filter"
117 grep -v 'Document entered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
118 if [ $? -ne 0 ] ; then no_result ; fi
121 activity="compare results"
122 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.filtered
123 diff -b $TEMPDIR/pspp.filtered - <<EOF
124 1.1 DATA LIST. Reading 1 record from INLINE.
125 +--------+------+-------+------+
126 |Variable|Record|Columns|Format|
127 #========#======#=======#======#
130 +--------+------+-------+------+
131 Documents in the active file:
132 First line of a document
133 This is the second very long line of a document in an attempt to overflow the
134 Note that the last line should end with a period: .
136 This is a test file label
137 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: .
142 This is a test file label
143 Documents in the active file:
144 First line of a document
145 This is the second very long line of a document in an attempt to overflow the
146 Note that the last line should end with a period: .
147 There should be another document now.
148 Documents in the active file:
149 First line of a document
150 This is the second very long line of a document in an attempt to overflow the
151 Note that the last line should end with a period: .
152 There should be another document now.
154 This is a test file label
156 if [ $? -ne 0 ] ; then fail ; fi