TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT)
dist_TESTS = \
- tests/command/match-files.sh \
tests/command/missing-values.sh \
tests/command/no_case_size.sh \
tests/command/n_of_cases.sh \
tests/bugs/get-no-file.sh \
tests/bugs/if_crash.sh \
tests/bugs/input-crash.sh \
- tests/bugs/match-files-scratch.sh \
tests/bugs/multipass.sh \
tests/bugs/overwrite-input-file.sh \
tests/bugs/overwrite-special-file.sh \
tests/language/data-io/get-data-psql.at \
tests/language/data-io/get-data-txt.at \
tests/language/data-io/list.at \
+ tests/language/data-io/match-files.at \
tests/language/data-io/save.at \
tests/language/data-io/save-translate.at \
tests/language/dictionary/attributes.at \
+++ /dev/null
-#!/bin/sh
-
-# This program tests for a bug which caused MATCH FILES to crash
-# when used with scratch variables.
-
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.pspp
-
-# 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 program"
-cat > $TESTFILE <<EOF
-DATA LIST LIST /w * x * y * .
-BEGIN DATA
-4 5 6
-1 2 3
-END DATA.
-
-COMPUTE j=0.
-LOOP #k = 1 to 10.
-COMPUTE j=#k + j.
-END LOOP.
-
-MATCH FILES FILE=* /DROP=w.
-LIST.
-FINISH.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-diff -c $TEMPDIR/pspp.csv - << EOF
-Table: Reading free-form data from INLINE.
-Variable,Format
-w,F8.0
-x,F8.0
-y,F8.0
-
-Table: Data List
-x,y,j
-5.00,6.00,55.00
-2.00,3.00,55.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
+++ /dev/null
-#!/bin/sh
-
-# This program tests the MATCH FILES procedure
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/match-files.pspp
-
-
-# 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="data create"
-cat > a.data <<EOF
-1aB
-8aM
-3aE
-5aG
-0aA
-5aH
-6aI
-7aJ
-2aD
-7aK
-1aC
-7aL
-4aF
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-cat > b.data <<EOF
-1bN
-3bO
-4bP
-6bQ
-7bR
-9bS
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-cat > ff.out <<EOF
-Table: Data List
-A,B,C,D,INA,INB,FIRST,LAST
-0,a,A,,1,0,1,1
-1,a,B,N,1,1,1,0
-1,a,C,,1,0,0,1
-2,a,D,,1,0,1,1
-3,a,E,O,1,1,1,1
-4,a,F,P,1,1,1,1
-5,a,G,,1,0,1,0
-5,a,H,,1,0,0,1
-6,a,I,Q,1,1,1,1
-7,a,J,R,1,1,1,0
-7,a,K,,1,0,0,0
-7,a,L,,1,0,0,1
-8,a,M,,1,0,1,1
-9,b,,S,0,1,1,1
-EOF
-
-cat > ft.out <<EOF
-Table: Data List
-A,B,C,D,INA,INB,FIRST,LAST
-0,a,A,,1,0,1,1
-1,a,B,N,1,1,1,0
-1,a,C,N,1,1,0,1
-2,a,D,,1,0,1,1
-3,a,E,O,1,1,1,1
-4,a,F,P,1,1,1,1
-5,a,G,,1,0,1,0
-5,a,H,,1,0,0,1
-6,a,I,Q,1,1,1,1
-7,a,J,R,1,1,1,0
-7,a,K,R,1,1,0,0
-7,a,L,R,1,1,0,1
-8,a,M,,1,0,1,1
-EOF
-
-# Test nonparallel match and table lookup.
-dla="data list notable file='a.data' /A B C 1-3 (a)."
-sa="save outfile='a.sys'."
-dlb="data list notable file='b.data' /A B C 1-3 (a)."
-sb="save outfile='b.sys'."
-for types in ff ft; do
- type1=file
- if [ $types = ff ]; then
- type2=file
- else
- type2=table
- fi
- for sources in ss sa as; do
- name="$types-$sources"
- activity="create $name.pspp"
- {
- if [ $sources = ss ]; then
- cat <<EOF
-$dla
-$sa
-$dlb
-$sb
-match files $type1='a.sys' /in=INA /sort
- /$type2='b.sys' /in=INB /rename c=D
- /by a /first=FIRST /last=LAST.
-EOF
- elif [ $sources = sa ]; then
- cat <<EOF
-$dla
-$sa
-$dlb
-match files $type1='a.sys' /in=INA /sort
- /$type2=* /in=INB /rename c=D
- /by a /first=FIRST /last=LAST.
-EOF
- elif [ $sources = as ]; then
- cat <<EOF
-$dlb
-$sb
-$dla
-match files $type1=* /in=INA /sort
- /$type2='b.sys' /in=INB /rename c=D
- /by a /first=FIRST /last=LAST.
-EOF
- else
- activity="internal error"
- no_result
- fi
- echo 'list.'
- } > $name.pspp
- if [ $? -ne 0 ] ; then no_result ; fi
-
- activity="run $name.pspp"
- $SUPERVISOR $PSPP -o pspp.csv -e /dev/null $name.pspp
- if [ $? -ne 0 ] ; then no_result ; fi
-
- activity="check $name output"
- diff -c pspp.csv $types.out
- if [ $? -ne 0 ] ; then fail ; fi
- done
-done
-
-# Test parallel match.
-name="parallel"
-activity="create $name.pspp"
-cat > $name.pspp <<EOF
-$dla
-$sa
-$dlb
-$sb
-match files file='a.sys' /file='b.sys' /rename (a b c=D E F).
-list.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run $name.pspp"
-$SUPERVISOR $PSPP -o pspp.csv -e /dev/null $name.pspp
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="check $name output"
-diff -c - pspp.csv <<EOF
-Table: Data List
-A,B,C,D,E,F
-1,a,B,1,b,N
-8,a,M,3,b,O
-3,a,E,4,b,P
-5,a,G,6,b,Q
-0,a,A,7,b,R
-5,a,H,9,b,S
-6,a,I,,,
-7,a,J,,,
-2,a,D,,,
-7,a,K,,,
-1,a,C,,,
-7,a,L,,,
-4,a,F,,,
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-# Test bug handling TABLE from active file found by John Darrington.
-name="active-table"
-activity="create $name.pspp"
-cat > $name.pspp <<EOF
-DATA LIST LIST NOTABLE /x * y *.
-BEGIN DATA
-3 30
-2 21
-1 22
-END DATA.
-
-SAVE OUTFILE='bar.sav'.
-
-DATA LIST LIST NOTABLE /x * z *.
-BEGIN DATA
-3 8
-2 9
-END DATA.
-
-MATCH FILES TABLE=* /FILE='bar.sav' /BY=x.
-LIST.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run $name.pspp"
-$SUPERVISOR $PSPP -o pspp.csv -e /dev/null $name.pspp
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="check $name output"
-diff -c - pspp.csv <<EOF
-Table: Data List
-x,z,y
-3.00,8.00,30.00
-2.00,. ,21.00
-1.00,. ,22.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-pass;
--- /dev/null
+AT_BANNER([MATCH FILES])
+
+m4_define([PREPARE_MATCH_FILES],
+ [AT_DATA([data1.txt], [dnl
+1aB
+8aM
+3aE
+5aG
+0aA
+5aH
+6aI
+7aJ
+2aD
+7aK
+1aC
+7aL
+4aF
+])
+
+ AT_DATA([data2.txt], [dnl
+1bN
+3bO
+4bP
+6bQ
+7bR
+9bS
+])
+
+ AT_DATA([prepare.sps], [dnl
+DATA LIST NOTABLE FILE='data1.txt' /a b c 1-3 (A).
+SAVE OUTFILE='data1.sav'.
+DATA LIST NOTABLE FILE='data2.txt' /a b c 1-3 (A).
+SAVE OUTFILE='data2.sav'.
+])
+ AT_CHECK([pspp -O format=csv prepare.sps])
+ AT_CHECK([test -f data1.sav && test -f data2.sav])])
+
+dnl CHECK_MATCH_FILES(TYPE2, SOURCE1, SOURCE2)
+dnl
+dnl Checks the MATCH FILES procedure with the specified combination of:
+dnl
+dnl - TYPE2: Either "file" or "table" for the type of matching used for
+dnl the second data source. (The first data source is always "file").
+dnl
+dnl - SOURCE1: Either "system" or "active" for the source of data for
+dnl the first data source.
+dnl
+dnl - SOURCE2: Either "system" or "active" for the source of data for
+dnl the second data source. (SOURCE1 and SOURCE2 may not both be
+dnl "active".)
+m4_define([CHECK_MATCH_FILES],
+ [AT_SETUP([MATCH FILES -- $2 file and $3 $1])
+ PREPARE_MATCH_FILES
+ AT_DATA([expout],
+ [m4_if([$1], [file], [dnl
+Table: Data List
+a,b,c,d,ina,inb,first,last
+0,a,A,,1,0,1,1
+1,a,B,N,1,1,1,0
+1,a,C,,1,0,0,1
+2,a,D,,1,0,1,1
+3,a,E,O,1,1,1,1
+4,a,F,P,1,1,1,1
+5,a,G,,1,0,1,0
+5,a,H,,1,0,0,1
+6,a,I,Q,1,1,1,1
+7,a,J,R,1,1,1,0
+7,a,K,,1,0,0,0
+7,a,L,,1,0,0,1
+8,a,M,,1,0,1,1
+9,b,,S,0,1,1,1
+], [dnl
+Table: Data List
+a,b,c,d,ina,inb,first,last
+0,a,A,,1,0,1,1
+1,a,B,N,1,1,1,0
+1,a,C,N,1,1,0,1
+2,a,D,,1,0,1,1
+3,a,E,O,1,1,1,1
+4,a,F,P,1,1,1,1
+5,a,G,,1,0,1,0
+5,a,H,,1,0,0,1
+6,a,I,Q,1,1,1,1
+7,a,J,R,1,1,1,0
+7,a,K,R,1,1,0,0
+7,a,L,R,1,1,0,1
+8,a,M,,1,0,1,1
+])])
+
+ AT_DATA([match-files.sps], [dnl
+m4_if([$2], [active], [GET FILE='data1.sav'.],
+ [$3], [active], [GET FILE='data2.sav'.],
+ [])
+MATCH FILES
+ FILE=m4_if([$2], [active], [*], ['data1.sav']) /IN=ina /SORT
+ $1=m4_if([$3], [active], [*], ['data2.sav']) /in=inb /rename c=d
+ /BY a /FIRST=first /LAST=last.
+LIST.
+])
+ AT_CHECK([pspp -o pspp.csv match-files.sps])
+ AT_CHECK([cat pspp.csv], [0], [expout])
+ AT_CLEANUP])
+
+CHECK_MATCH_FILES([file], [system], [system])
+CHECK_MATCH_FILES([file], [system], [active])
+CHECK_MATCH_FILES([file], [active], [system])
+CHECK_MATCH_FILES([table], [system], [system])
+CHECK_MATCH_FILES([table], [system], [active])
+CHECK_MATCH_FILES([table], [active], [system])
+
+AT_SETUP([MATCH FILES parallel match])
+PREPARE_MATCH_FILES
+AT_DATA([match-files.sps], [dnl
+MATCH FILES FILE='data1.sav' /FILE='data2.sav' /RENAME (a b c=d e f).
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv match-files.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+a,b,c,d,e,f
+1,a,B,1,b,N
+8,a,M,3,b,O
+3,a,E,4,b,P
+5,a,G,6,b,Q
+0,a,A,7,b,R
+5,a,H,9,b,S
+6,a,I,,,
+7,a,J,,,
+2,a,D,,,
+7,a,K,,,
+1,a,C,,,
+7,a,L,,,
+4,a,F,,,
+])
+AT_CLEANUP
+
+dnl Test bug handling TABLE from active file found by John Darrington.
+AT_SETUP([MATCH FILES bug with TABLE from active file])
+AT_DATA([match-files.sps], [dnl
+DATA LIST LIST NOTABLE /x * y *.
+BEGIN DATA
+3 30
+2 21
+1 22
+END DATA.
+
+SAVE OUTFILE='bar.sav'.
+
+DATA LIST LIST NOTABLE /x * z *.
+BEGIN DATA
+3 8
+2 9
+END DATA.
+
+MATCH FILES TABLE=* /FILE='bar.sav' /BY=x.
+LIST.
+])
+AT_CHECK([pspp -o pspp.csv match-files.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+x,z,y
+3.00,8.00,30.00
+2.00,. ,21.00
+1.00,. ,22.00
+])
+AT_CLEANUP
+
+dnl Tests for a bug which caused MATCH FILES to crash
+dnl when used with scratch variables.
+AT_SETUP([MATCH FILES bug with scratch variables])
+AT_DATA([match-files.sps], [dnl
+DATA LIST LIST /w * x * y * .
+BEGIN DATA
+4 5 6
+1 2 3
+END DATA.
+
+COMPUTE j=0.
+LOOP #k = 1 to 10.
+COMPUTE j=#k + j.
+END LOOP.
+
+MATCH FILES FILE=* /DROP=w.
+LIST.
+FINISH.
+])
+AT_CHECK([pspp -o pspp.csv match-files.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Reading free-form data from INLINE.
+Variable,Format
+w,F8.0
+x,F8.0
+y,F8.0
+
+Table: Data List
+x,y,j
+5.00,6.00,55.00
+2.00,3.00,55.00
+])
+AT_CLEANUP