[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[autotest 1/5] tests: Rewrite attributes tests to use Autotest.
From: |
Ben Pfaff |
Subject: |
[autotest 1/5] tests: Rewrite attributes tests to use Autotest. |
Date: |
Sun, 8 Aug 2010 22:40:26 -0700 |
---
tests/automake.mk | 2 +-
tests/command/attributes.sh | 133 -------------------------------
tests/language/dictionary/attributes.at | 66 +++++++++++++++
3 files changed, 67 insertions(+), 134 deletions(-)
delete mode 100755 tests/command/attributes.sh
create mode 100644 tests/language/dictionary/attributes.at
diff --git a/tests/automake.mk b/tests/automake.mk
index 481ecce..7da5514 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -11,7 +11,6 @@ TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT)
dist_TESTS = \
tests/command/add-files.sh \
- tests/command/attributes.sh \
tests/command/beg-data.sh \
tests/command/bignum.sh \
tests/command/count.sh \
@@ -421,6 +420,7 @@ TESTSUITE_AT = \
tests/language/data-io/data-list.at \
tests/language/data-io/save.at \
tests/language/data-io/save-translate.at \
+ tests/language/dictionary/attributes.at \
tests/language/dictionary/mrsets.at \
tests/language/expressions/evaluate.at \
tests/language/stats/aggregate.at \
diff --git a/tests/command/attributes.sh b/tests/command/attributes.sh
deleted file mode 100755
index a42a1aa..0000000
--- a/tests/command/attributes.sh
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/sh
-
-# This program tests VARIABLE ATTRIBUTE and DATAFILE ATTRIBUTE
-# commands, including the ability to write attributes to system files
-# and read them back in again.
-
-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 program"
-cat > $TESTFILE <<EOF
-DATA LIST FREE/a b c.
-BEGIN DATA.
-1 2 3
-END DATA.
-
-DATAFILE ATTRIBUTE
- ATTRIBUTE=key('value')
- array('array element 1')
- Array[2]('array element 2').
-VARIABLE ATTRIBUTE
- VARIABLES=a b
- ATTRIBUTE=ValidationRule[2]("a + b > 2")
- ValidationRule[1]('a * b > 3')
- /VARIABLES=c
- ATTRIBUTE=QuestionWording('X or Y?').
-DISPLAY ATTRIBUTES.
-
-SAVE OUTFILE='attributes.sav'.
-NEW FILE.
-GET FILE='attributes.sav'.
-
-DATAFILE ATTRIBUTE
- DELETE=Array[1] Array[2].
-VARIABLE ATTRIBUTE
- VARIABLES=a
- DELETE=ValidationRule
- /VARIABLE=b
- DELETE=validationrule[2].
-
-DISPLAY ATTRIBUTES.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output"
-diff -c $TEMPDIR/pspp.csv - << EOF
-Variable,Description,
-a,Custom attributes:,
-,ValidationRule[1],a * b > 3
-,ValidationRule[2],a + b > 2
-b,Custom attributes:,
-,ValidationRule[1],a * b > 3
-,ValidationRule[2],a + b > 2
-c,Custom attributes:,
-,QuestionWording,X or Y?
-
-Table: Custom data file attributes.
-Attribute,Value
-array[1],array element 1
-array[2],array element 2
-key,value
-
-Variable,Description,
-b,Custom attributes:,
-,ValidationRule,a * b > 3
-c,Custom attributes:,
-,QuestionWording,X or Y?
-
-Table: Custom data file attributes.
-Attribute,Value
-array,array element 2
-key,value
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-pass;
diff --git a/tests/language/dictionary/attributes.at
b/tests/language/dictionary/attributes.at
new file mode 100644
index 0000000..be75e8c
--- /dev/null
+++ b/tests/language/dictionary/attributes.at
@@ -0,0 +1,66 @@
+AT_BANNER([VARIABLE ATTRIBUTES and DATAFILE ATTRIBUTES])
+
+AT_SETUP([VARIABLE ATTRIBUTES and DATAFILE ATTRIBUTES])
+AT_DATA([save-attrs.pspp],
+ [[DATA LIST FREE/a b c.
+BEGIN DATA.
+1 2 3
+END DATA.
+
+DATAFILE ATTRIBUTE
+ ATTRIBUTE=key('value')
+ array('array element 1')
+ Array[2]('array element 2').
+VARIABLE ATTRIBUTE
+ VARIABLES=a b
+ ATTRIBUTE=ValidationRule[2]("a + b > 2")
+ ValidationRule[1]('a * b > 3')
+ /VARIABLES=c
+ ATTRIBUTE=QuestionWording('X or Y?').
+DISPLAY ATTRIBUTES.
+
+SAVE OUTFILE='attributes.sav'.
+]])
+AT_DATA([get-attrs.pspp],
+ [[GET FILE='attributes.sav'.
+
+DATAFILE ATTRIBUTE
+ DELETE=Array[1] Array[2].
+VARIABLE ATTRIBUTE
+ VARIABLES=a
+ DELETE=ValidationRule
+ /VARIABLE=b
+ DELETE=validationrule[2].
+
+DISPLAY ATTRIBUTES.
+]])
+AT_CHECK([pspp -O format=csv save-attrs.pspp], [0],
+ [[Variable,Description,
+a,Custom attributes:,
+,ValidationRule[1],a * b > 3
+,ValidationRule[2],a + b > 2
+b,Custom attributes:,
+,ValidationRule[1],a * b > 3
+,ValidationRule[2],a + b > 2
+c,Custom attributes:,
+,QuestionWording,X or Y?
+
+Table: Custom data file attributes.
+Attribute,Value
+array[1],array element 1
+array[2],array element 2
+key,value
+]])
+AT_CHECK([pspp -O format=csv get-attrs.pspp], [0], [dnl
+Variable,Description,
+b,Custom attributes:,
+,ValidationRule,a * b > 3
+c,Custom attributes:,
+,QuestionWording,X or Y?
+
+Table: Custom data file attributes.
+Attribute,Value
+array,array element 2
+key,value
+])
+AT_CLEANUP
--
1.7.1
- more autotest conversions, Ben Pfaff, 2010/08/09
- [autotest 1/5] tests: Rewrite attributes tests to use Autotest.,
Ben Pfaff <=
- [autotest 5/5] tests: Ignore testsuite.at since it is now a generated file., Ben Pfaff, 2010/08/09
- [autotest 2/5] ADD FILES: Convert testsuite to use Autotest., Ben Pfaff, 2010/08/09
- [autotest 3/5] BEGIN DATA: Convert tests to use Autotest., Ben Pfaff, 2010/08/09
- [autotest 4/5] COUNT: Convert tests to use Autotest., Ben Pfaff, 2010/08/09
- Re: more autotest conversions, Ben Pfaff, 2010/08/10