From: Luca Bruno Date: Fri, 3 Jun 2011 16:57:34 +0000 (+0200) Subject: tests: Add ref-testing for the GIR parser X-Git-Tag: 0.13.0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf019ecba9d2eabbd06c2fd75b772cfce51e36ce;p=thirdparty%2Fvala.git tests: Add ref-testing for the GIR parser --- diff --git a/tests/Makefile.am b/tests/Makefile.am index df46d936a..bec9a3f30 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -120,6 +120,7 @@ TESTS = \ dbus/filedescriptor.test \ dbus/bug596862.vala \ dbus/bug602003.test \ + gir/bug651773.test \ $(NULL) check-TESTS: $(TESTS) diff --git a/tests/gir/bug651773.test b/tests/gir/bug651773.test new file mode 100644 index 000000000..e4dbdf989 --- /dev/null +++ b/tests/gir/bug651773.test @@ -0,0 +1,24 @@ +GIR + +Input: + + + + + + + + + + + + + + +Output: + +[CCode (cheader_filename = "test.h", array_length_pos = 0.1, array_length_type = "gsize")] +public static unowned uint8[] get_array (); diff --git a/tests/testrunner.sh b/tests/testrunner.sh index 743af630c..adb20d6d5 100755 --- a/tests/testrunner.sh +++ b/tests/testrunner.sh @@ -30,6 +30,8 @@ export G_DEBUG=fatal_warnings VALAC=$topbuilddir/compiler/valac VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -g -X -O0 -X -pipe -X -lm -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast" +VAPIGEN=$topbuilddir/vapigen/vapigen +VAPIGENFLAGS="--vapidir $vapidir" function testheader() { if [ "$1" = "Packages:" ]; then @@ -38,6 +40,8 @@ function testheader() { elif [ "$1" = "D-Bus" ]; then echo 'eval `dbus-launch --sh-syntax`' >> prepare echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare + elif [ "$1" = "GIR" ]; then + GIRTEST=1 fi } @@ -50,13 +54,47 @@ function sourceheader() { SOURCEFILES="$SOURCEFILES $SOURCEFILE" echo " case \"/$testpath\": $ns.main (); break;" >> main.vala echo "namespace $ns {" > $SOURCEFILE + elif [ $GIRTEST -eq 1 ]; then + if [ "$1" = "Input:" ]; then + testpath=${testfile/.test/} + ns=${testpath//\//.} + ns=${ns//-/_} + SOURCEFILE=$ns.gir + cat < $SOURCEFILE + + + + + + +EOF + elif [ "$1" = "Output:" ]; then + testpath=${testfile/.test/} + ns=${testpath//\//.} + ns=${ns//-/_} + SOURCEFILE=$ns.vapi.ref + fi fi } function sourceend() { if [ -n "$testpath" ]; then - echo "}" >> $SOURCEFILE - echo "./test$EXEEXT /$testpath" > check + if [ $GIRTEST -eq 1 ]; then + if [ $PART -eq 1 ]; then + echo " " >> $SOURCEFILE + echo "" >> $SOURCEFILE + fi + echo "$VAPIGEN $VAPIGENFLAGS --library $ns $ns.gir && tail -n +5 $ns.vapi|head -n -1|diff -wu $ns.vapi.ref -" > check + else + echo "}" >> $SOURCEFILE + echo "./test$EXEEXT /$testpath" > check + fi fi } @@ -101,6 +139,7 @@ for testfile in "$@"; do *.test) PART=0 INHEADER=1 + GIRTEST=0 testpath= while IFS="" read -r line; do if [ $PART -eq 0 ]; then