From a0b44156250a6b884edd0a48ef3d4a10c762d811 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sat, 4 Jun 2011 11:16:44 +0200 Subject: tests: Support negative test cases Fixes bug 630597. --- tests/Makefile.am | 2 +- tests/asynchronous/bug646945.test | 29 ++++++++++++++++++++++++++++ tests/asynchronous/bug646945.vala | 20 -------------------- tests/testrunner.sh | 40 ++++++++++++++++++++++++++------------- 4 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 tests/asynchronous/bug646945.test delete mode 100644 tests/asynchronous/bug646945.vala diff --git a/tests/Makefile.am b/tests/Makefile.am index bec9a3f30..83fa746f5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -108,7 +108,7 @@ TESTS = \ asynchronous/bug620740.vala \ asynchronous/bug639591.vala \ asynchronous/bug641182.vala \ - asynchronous/bug646945.vala \ + asynchronous/bug646945.test \ asynchronous/closures.vala \ dbus/basic-types.test \ dbus/arrays.test \ diff --git a/tests/asynchronous/bug646945.test b/tests/asynchronous/bug646945.test new file mode 100644 index 000000000..2708b65c0 --- /dev/null +++ b/tests/asynchronous/bug646945.test @@ -0,0 +1,29 @@ + +Negative: negative + +async void foo () { bar.callback (); } + +async void bar () { foo.callback (); } + +Program: positive + +class Foo : Object { + public virtual async void method1 () { } +} + +interface Bar : Object { + public virtual async void method2 () { } +} + +class Baz : Foo, Bar { + public override async void method1 () { + method1.callback (); + } + + public async void method2 () { + method2.callback (); + } +} + +void main () { +} diff --git a/tests/asynchronous/bug646945.vala b/tests/asynchronous/bug646945.vala deleted file mode 100644 index ad17d486b..000000000 --- a/tests/asynchronous/bug646945.vala +++ /dev/null @@ -1,20 +0,0 @@ -class Foo : Object { - public virtual async void method1 () { } -} - -interface Bar : Object { - public virtual async void method2 () { } -} - -class Baz : Foo, Bar { - public override async void method1 () { - method1.callback (); - } - - public async void method2 () { - method2.callback (); - } -} - -void main () { -} diff --git a/tests/testrunner.sh b/tests/testrunner.sh index 7e528593d..7b8ba48f1 100755 --- a/tests/testrunner.sh +++ b/tests/testrunner.sh @@ -54,6 +54,12 @@ function sourceheader() { SOURCEFILES="$SOURCEFILES $SOURCEFILE" echo " case \"/$testpath\": $ns.main (); break;" >> main.vala echo "namespace $ns {" > $SOURCEFILE + elif [ "$1" = "Negative:" ]; then + testpath=${testfile/.test/}/$2 + ns=${testpath//\//.} + ns=${ns//-/_} + SOURCEFILE=$ns.vala + NEGATIVETEST=1 elif [ $GIRTEST -eq 1 ]; then if [ "$1" = "Input:" ]; then testpath=${testfile/.test/} @@ -91,6 +97,9 @@ function sourceend() { echo "" >> $SOURCEFILE fi echo "$VAPIGEN $VAPIGENFLAGS --library $ns $ns.gir && tail -n +5 $ns.vapi|head -n -1|sed '/^$/d'|sed 's/^\s*//'|cmp --quiet $ns.vapi.ref" > check + elif [ $NEGATIVETEST -eq 1 ]; then + echo "! $VALAC --vapidir $vapidir --fatal-warnings $([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg") -C $SOURCEFILE" > check + addtocheck else echo "}" >> $SOURCEFILE echo "./test$EXEEXT /$testpath" > check @@ -98,6 +107,21 @@ function sourceend() { fi } +function addtocheck() { + cat prepare check > $ns.check + cat << EOF >> checkall +echo -n -e " /$testpath: \033[72G" +((all++)) +if bash $ns.check &>log; then + echo -e "\033[0;32mOK\033[m" +else + ((fail++)) + echo -e "\033[0;31mFAIL\033[m" + cat log +fi +EOF +} + testdir=_test rm -rf $testdir mkdir $testdir @@ -140,6 +164,7 @@ for testfile in "$@"; do PART=0 INHEADER=1 GIRTEST=0 + NEGATIVETEST=0 testpath= while IFS="" read -r line; do if [ $PART -eq 0 ]; then @@ -160,6 +185,7 @@ for testfile in "$@"; do sourceend PART=$(($PART + 1)) INHEADER=1 + NEGATIVETEST=0 testpath= sourceheader $line else @@ -177,19 +203,7 @@ for testfile in "$@"; do sourceend ;; esac - - cat prepare check > $ns.check - cat << EOF >> checkall -echo -n -e " /$testpath: \033[72G" -((all++)) -if bash $ns.check &>log; then - echo -e "\033[0;32mOK\033[m" -else - ((fail++)) - echo -e "\033[0;31mFAIL\033[m" - cat log -fi -EOF + addtocheck done cat << "EOF" >> checkall -- cgit v1.2.1