tests/formats/wkday-in.sh \
tests/formats/wkday-out.sh \
tests/formats/360.sh \
- tests/bugs/overwrite-input-file.sh \
tests/bugs/overwrite-special-file.sh \
tests/bugs/shbang.sh \
tests/bugs/signals.sh \
TESTSUITE_AT = \
tests/data/calendar.at \
tests/data/data-in.at \
+ tests/data/por-file.at \
tests/data/sys-file.at \
tests/language/command.at \
tests/language/control/do-if.at \
+++ /dev/null
-#!/bin/sh
-
-# This program tests that simultaneous input and output to a single
-# file properly coexist, with the output atomically replacing the
-# input if successful.
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# ensure that top_builddir are absolute
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-top_builddir=`cd $top_builddir; pwd`
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-# ensure that top_srcdir is absolute
-top_srcdir=`cd $top_srcdir; pwd`
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-
-cleanup()
-{
- if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
- echo "NOT cleaning $TEMPDIR"
- return ;
- fi
- cd /
- rm -rf $TEMPDIR
-}
-
-
-fail()
-{
- echo $activity
- echo FAILED
- cleanup;
- exit 1;
-}
-
-
-no_result()
-{
- echo $activity
- echo NO RESULT;
- cleanup;
- exit 2;
-}
-
-pass()
-{
- cleanup;
- exit 0;
-}
-
-mkdir -p $TEMPDIR
-
-cd $TEMPDIR
-
-activity="create data file"
-cat > foo.data <<EOF
-1
-2
-3
-4
-5
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="create program 1"
-cat > $TESTFILE <<EOF
-DATA LIST FILE='foo.data' /X 1.
-SAVE OUTFILE='foo.sav'.
-EXPORT OUTFILE='foo.por'.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 1"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="check and save copy of output files"
-# Check that the files are nonzero length.
-test -s foo.data || fail
-test -s foo.sav || fail
-test -s foo.por || fail
-# Save copies of them.
-cp foo.data foo.data.backup || fail
-cp foo.sav foo.sav.backup || fail
-cp foo.por foo.por.backup || fail
-
-
-activity="create program 2"
-cat > $TESTFILE <<EOF
-GET 'foo.sav'.
-COMPUTE Y = X + 1.
-XSAVE OUTFILE='foo.sav'.
-XEXPORT OUTFILE='foo.por'.
-PRINT OUTFILE='foo.data'.
-HOST COMMAND=['kill -TERM \$PPID'].
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 2"
-{ $SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e /dev/null; } >/dev/null 2>&1
-# PSPP should have terminated with a signal. POSIX requires that the exit
-# status of a process terminated by a signal be greater than 128.
-if [ $? -le 128 ] ; then no_result ; fi
-
-activity="check for remaining temporary files"
-if test -e *.tmp*; then fail; fi
-
-activity="compare output 1"
-cmp foo.sav foo.sav.backup
-if [ $? -ne 0 ] ; then fail ; fi
-
-activity="compare output 2"
-cmp foo.por foo.por.backup
-if [ $? -ne 0 ] ; then fail ; fi
-
-activity="compare output 3"
-cmp foo.data foo.data.backup
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="create program 3"
-cat > $TESTFILE <<EOF
-DATA LIST NOTABLE LIST FILE='foo.data'/X.
-COMPUTE Y = X + 1.
-PRINT OUTFILE='foo.data'/X Y.
-EXECUTE.
-
-GET 'foo.sav'.
-COMPUTE Y = X + 2.
-SAVE OUTFILE='foo.sav'.
-
-IMPORT 'foo.por'.
-COMPUTE Y = X + 3.
-EXPORT OUTFILE='foo.por'.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 3"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e /dev/null
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="check for remaining temporary files"
-if test -e *.tmp*; then fail; fi
-
-activity="create program 4"
-cat > $TESTFILE <<EOF
-DATA LIST LIST NOTABLE FILE='foo.data'/X Y.
-LIST.
-
-GET 'foo.sav'.
-LIST.
-
-IMPORT 'foo.por'.
-LIST.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 4"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e /dev/null
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output"
-diff -c pspp.csv - << EOF
-Table: Data List
-X,Y
-1.00,2.00
-2.00,3.00
-3.00,4.00
-4.00,5.00
-5.00,6.00
-
-Table: Data List
-X,Y
-1,3.00
-2,4.00
-3,5.00
-4,6.00
-5,7.00
-
-Table: Data List
-X,Y
-1,4.00
-2,5.00
-3,6.00
-4,7.00
-5,8.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-pass;
--- /dev/null
+AT_BANNER([portable files])
+
+AT_SETUP([overwriting portable file])
+AT_DATA([output.por], [abcdef
+])
+cp output.por output.por.backup
+AT_DATA([porfile.sps], [dnl
+DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+5
+END DATA.
+EXPORT OUTFILE='output.por'.
+])
+AT_CHECK([pspp -O format=csv porfile.sps])
+AT_CHECK([cmp output.por output.por.backup], [1], [ignore])
+AT_CLEANUP
+
+AT_SETUP([overwriting portable file atomically])
+AT_DATA([output.por], [abcdef
+])
+cp output.por output.por.backup
+AT_DATA([porfile.sps],
+[[DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+5
+END DATA.
+XEXPORT OUTFILE='output.por'.
+HOST COMMAND=['kill -TERM $PPID'].
+]])
+AT_CHECK([pspp -O format=csv porfile.sps], [143], [], [ignore])
+AT_CHECK([cmp output.por output.por.backup])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_CLEANUP
+
+AT_SETUP([write to same portable file being read])
+AT_DATA([export.sps], [dnl
+DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+2
+END DATA.
+EXPORT OUTFILE='data.por'.
+])
+AT_CHECK([pspp -O format=csv export.sps])
+AT_CHECK([test -s data.por])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_DATA([export2.sps], [dnl
+IMPORT FILE='data.por'.
+COMPUTE y = x * 2.
+EXPORT OUTFILE='data.por'.
+])
+AT_CHECK([pspp -O format=csv export2.sps])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_DATA([export3.sps], [dnl
+IMPORT FILE='data.por'.
+LIST.
+])
+AT_CHECK([pspp -O format=csv export3.sps], [0], [dnl
+Table: Data List
+X,Y
+2,4.00
+])
+AT_CLEANUP
AT_CAPTURE_FILE([com.txt])
AT_CLEANUP
+AT_SETUP([overwriting system file])
+AT_DATA([output.sav], [abcdef
+])
+cp output.sav output.sav.backup
+AT_DATA([sysfile.sps], [dnl
+DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+5
+END DATA.
+SAVE OUTFILE='output.sav'.
+])
+AT_CHECK([pspp -O format=csv sysfile.sps])
+AT_CHECK([cmp output.sav output.sav.backup], [1], [ignore])
+AT_CLEANUP
+
+AT_SETUP([overwriting system file atomically])
+AT_DATA([output.sav], [abcdef
+])
+cp output.sav output.sav.backup
+AT_DATA([sysfile.sps],
+[[DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+5
+END DATA.
+XSAVE OUTFILE='output.sav'.
+HOST COMMAND=['kill -TERM $PPID'].
+]])
+AT_CHECK([pspp -O format=csv sysfile.sps], [143], [], [ignore])
+AT_CHECK([cmp output.sav output.sav.backup])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_CLEANUP
+
+
+AT_SETUP([write to same system file being read])
+AT_DATA([save.sps], [dnl
+DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+3
+END DATA.
+SAVE OUTFILE='data.sav'.
+])
+AT_CHECK([pspp -O format=csv save.sps])
+AT_CHECK([test -s data.sav])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_DATA([save2.sps], [dnl
+GET FILE='data.sav'.
+COMPUTE y = x * 3.
+SAVE OUTFILE='data.sav'.
+])
+AT_CHECK([pspp -O format=csv save2.sps])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_DATA([save3.sps], [dnl
+GET FILE='data.sav'.
+LIST.
+])
+AT_CHECK([pspp -O format=csv save3.sps], [0], [dnl
+Table: Data List
+X,Y
+3,9.00
+])
+AT_CLEANUP
+
AT_SETUP([nonempty case_map doesn't crash])
AT_KEYWORDS([SAVE system file])
AT_DATA([save.sps], [dnl
])
AT_CLEANUP
+
+AT_SETUP([PRINT overwrites file])
+AT_DATA([output.txt], [abcdef
+])
+AT_DATA([print.sps], [dnl
+DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+5
+END DATA.
+PRINT OUTFILE='output.txt'/x.
+EXECUTE.
+])
+AT_CHECK([pspp -O format=csv print.sps])
+AT_CHECK([cat output.txt], [0], [ 5 @&t@
+])
+AT_CLEANUP
+
+AT_SETUP([PRINT overwrites file atomically])
+AT_DATA([output.txt], [abcdef
+])
+AT_DATA([print.sps],
+[[DATA LIST NOTABLE/x 1.
+BEGIN DATA.
+5
+END DATA.
+PRINT OUTFILE='output.txt'/x.
+HOST COMMAND=['kill -TERM $PPID'].
+]])
+AT_CHECK([pspp -O format=csv print.sps], [143], [], [ignore])
+AT_CHECK([cat output.txt], [0], [abcdef
+])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_CLEANUP
+
+AT_SETUP([PRINT to same file being read])
+AT_DATA([data.txt], [5
+])
+AT_DATA([print.sps], [dnl
+DATA LIST FILE='data.txt' NOTABLE/x 1.
+COMPUTE y = x + 1.
+PRINT OUTFILE='data.txt'/y.
+EXECUTE.
+])
+AT_CHECK([pspp -O format=csv print.sps])
+AT_CHECK([cat data.txt], [0], [ 6.00 @&t@
+])
+AT_CHECK(
+ [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
+AT_CLEANUP