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 diff -b -B $TEMPDIR/pspp.filtered - <<EOF
120 1.1 DATA LIST. Reading 1 record from the command file.
121 +--------+------+-------+------+
122 |Variable|Record|Columns|Format|
123 #========#======#=======#======#
126 +--------+------+-------+------+
128 Documents in the active file:
130 First line of a document
131 This is the second very long line of a document in an attempt to overflow the
132 Note that the last line should end with a period: .
135 This is a test file label
137 Documents in the active file:
139 First line of a document
140 This is the second very long line of a document in an attempt to overflow the
141 Note that the last line should end with a period: .
144 This is a test file label
146 Documents in the active file:
148 First line of a document
149 This is the second very long line of a document in an attempt to overflow the
150 Note that the last line should end with a period: .
152 There should be another document now.
154 Documents in the active file:
156 First line of a document
157 This is the second very long line of a document in an attempt to overflow the
158 Note that the last line should end with a period: .
160 There should be another document now.
163 This is a test file label
165 if [ $? -ne 0 ] ; then fail ; fi