[vala/staging] testrunner: Compile and run tests separately



commit 2f556804eb7aca850ea7528c3b408c10a3d10226
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Oct 27 15:28:53 2018 +0200

    testrunner: Compile and run tests separately

 tests/dbus/arrays.test                  |  2 +-
 tests/dbus/async-errors.test            |  2 +-
 tests/dbus/async.test                   |  2 +-
 tests/dbus/basic-types.test             |  2 +-
 tests/dbus/bug602003.test               |  2 +-
 tests/dbus/bug735437.test               |  2 +-
 tests/dbus/bug782719.test               |  2 +-
 tests/dbus/bug783002.test               |  2 +-
 tests/dbus/dicts.test                   |  2 +-
 tests/dbus/enum-string-marshalling.vala |  2 +-
 tests/dbus/errors.test                  |  2 +-
 tests/dbus/filedescriptor-async.test    |  2 +-
 tests/dbus/filedescriptor-errors.test   |  2 +-
 tests/dbus/filedescriptor.test          |  2 +-
 tests/dbus/rawvariants.test             |  2 +-
 tests/dbus/signals.test                 |  2 +-
 tests/dbus/structs.test                 |  2 +-
 tests/testrunner.sh                     | 67 +++++++++++++--------------------
 18 files changed, 44 insertions(+), 57 deletions(-)
---
diff --git a/tests/dbus/arrays.test b/tests/dbus/arrays.test
index fa884ca24..0557cb23d 100644
--- a/tests/dbus/arrays.test
+++ b/tests/dbus/arrays.test
@@ -68,7 +68,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/arrays/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_arrays_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/async-errors.test b/tests/dbus/async-errors.test
index 4c9483f5d..a23f0a653 100644
--- a/tests/dbus/async-errors.test
+++ b/tests/dbus/async-errors.test
@@ -102,7 +102,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/async-errors/client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+       Process.spawn_async (null, { "dbus_async_errors_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, 
out client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/async.test b/tests/dbus/async.test
index cb6a541fc..fb8fea9df 100644
--- a/tests/dbus/async.test
+++ b/tests/dbus/async.test
@@ -83,7 +83,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/async/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_async_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/basic-types.test b/tests/dbus/basic-types.test
index dbe63b13a..cb61ea662 100644
--- a/tests/dbus/basic-types.test
+++ b/tests/dbus/basic-types.test
@@ -80,7 +80,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/basic-types/client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+       Process.spawn_async (null, { "dbus_basic_types_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, 
out client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/bug602003.test b/tests/dbus/bug602003.test
index ceb2327e5..ab0bb2213 100644
--- a/tests/dbus/bug602003.test
+++ b/tests/dbus/bug602003.test
@@ -46,7 +46,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/bug602003/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_bug602003_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/bug735437.test b/tests/dbus/bug735437.test
index c2b75821c..70239859a 100644
--- a/tests/dbus/bug735437.test
+++ b/tests/dbus/bug735437.test
@@ -60,7 +60,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/bug735437/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_bug735437_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/bug782719.test b/tests/dbus/bug782719.test
index fe52eb3e2..781d9749c 100644
--- a/tests/dbus/bug782719.test
+++ b/tests/dbus/bug782719.test
@@ -55,7 +55,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/bug782719/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_bug782719_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/bug783002.test b/tests/dbus/bug783002.test
index f300c2beb..b11ee1b59 100644
--- a/tests/dbus/bug783002.test
+++ b/tests/dbus/bug783002.test
@@ -62,7 +62,7 @@ void main () {
        assert ((uint) request_result.get_child_value (0) == 1);
 
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/bug783002/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_bug783002_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, on_client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/dicts.test b/tests/dbus/dicts.test
index 1e7037ed7..9837f933d 100644
--- a/tests/dbus/dicts.test
+++ b/tests/dbus/dicts.test
@@ -64,7 +64,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/dicts/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_dicts_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/enum-string-marshalling.vala b/tests/dbus/enum-string-marshalling.vala
index 2cc764852..536daad08 100644
--- a/tests/dbus/enum-string-marshalling.vala
+++ b/tests/dbus/enum-string-marshalling.vala
@@ -7,7 +7,7 @@ public enum FooEnum {
 public interface Test : GLib.Object {
        public abstract async void test1 (FooEnum e) throws DBusError;
        public abstract void test2 (FooEnum e) throws DBusError;
-       public abstract void test3 (FooEnum e1, UnixOutputStream output_stream, FooEnum e2) throws DBusError;
+       public abstract void test3 (FooEnum e1, int fd, FooEnum e2) throws DBusError;
        public abstract void test4 (FooEnum e);
        public abstract async void test5 (FooEnum e);
 }
diff --git a/tests/dbus/errors.test b/tests/dbus/errors.test
index 9088fb4fd..508254286 100644
--- a/tests/dbus/errors.test
+++ b/tests/dbus/errors.test
@@ -85,7 +85,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/errors/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_errors_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/filedescriptor-async.test b/tests/dbus/filedescriptor-async.test
index 96fc9764a..9558866bf 100644
--- a/tests/dbus/filedescriptor-async.test
+++ b/tests/dbus/filedescriptor-async.test
@@ -91,7 +91,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/filedescriptor-async/client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+       Process.spawn_async (null, { "dbus_filedescriptor_async_client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/filedescriptor-errors.test b/tests/dbus/filedescriptor-errors.test
index ad3081653..c2e102a2a 100644
--- a/tests/dbus/filedescriptor-errors.test
+++ b/tests/dbus/filedescriptor-errors.test
@@ -63,7 +63,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/filedescriptor-errors/client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+       Process.spawn_async (null, { "dbus_filedescriptor_errors_client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/filedescriptor.test b/tests/dbus/filedescriptor.test
index 3eeb9ef28..3ad29acf9 100644
--- a/tests/dbus/filedescriptor.test
+++ b/tests/dbus/filedescriptor.test
@@ -76,7 +76,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/filedescriptor/client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+       Process.spawn_async (null, { "dbus_filedescriptor_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/rawvariants.test b/tests/dbus/rawvariants.test
index ca80e74fb..32cf26f03 100644
--- a/tests/dbus/rawvariants.test
+++ b/tests/dbus/rawvariants.test
@@ -128,7 +128,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/rawvariants/client" }, null, 
SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+       Process.spawn_async (null, { "dbus_rawvariants_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, 
out client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/signals.test b/tests/dbus/signals.test
index e46320b75..10544c520 100644
--- a/tests/dbus/signals.test
+++ b/tests/dbus/signals.test
@@ -57,7 +57,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/signals/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_signals_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/dbus/structs.test b/tests/dbus/structs.test
index d23dd84b8..99520e82c 100644
--- a/tests/dbus/structs.test
+++ b/tests/dbus/structs.test
@@ -81,7 +81,7 @@ void main () {
 
        // server ready, spawn client
        Pid client_pid;
-       Process.spawn_async (null, { "test", "/dbus/structs/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, 
null, out client_pid);
+       Process.spawn_async (null, { "dbus_structs_client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out 
client_pid);
        ChildWatch.add (client_pid, client_exit);
 
        main_loop = new MainLoop ();
diff --git a/tests/testrunner.sh b/tests/testrunner.sh
index 44fbd78cf..f8f4ba20d 100755
--- a/tests/testrunner.sh
+++ b/tests/testrunner.sh
@@ -37,7 +37,7 @@ VALAFLAGS="$VALAFLAGS \
        -X -O0 \
        -X -pipe \
        -X -lm \
-       -X -DGETTEXT_PACKAGE=\"valac\" \
+       -X -DGETTEXT_PACKAGE=\\\"valac\\\" \
        -X -Werror=return-type \
        -X -Werror=init-self \
        -X -Werror=implicit \
@@ -69,10 +69,11 @@ function testheader() {
                INVALIDCODE=1
                INHEADER=0
                testpath=${testfile/.test/}
-               ns=${testpath//\//.}
-               ns=${ns//-/_}
+               ns=${testpath//\//_}
+               ns=${ns//-/_}\_invalid
                SOURCEFILE=$ns.vala
        elif [ "$1" = "D-Bus" ]; then
+               DBUSTEST=1
                run_prefix="dbus-run-session -- $run_prefix"
        elif [ "$1" = "GIR" ]; then
                GIRTEST=1
@@ -81,17 +82,18 @@ function testheader() {
 
 function sourceheader() {
        if [ "$1" = "Program:" ]; then
+               if [ "$2" = "server" ]; then
+                       ISSERVER=1
+               fi
                testpath=${testfile/.test/}/$2
-               ns=${testpath//\//.}
+               ns=${testpath//\//_}
                ns=${ns//-/_}
                SOURCEFILE=$ns.vala
                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=${testpath//\//_}
                        ns=${ns//-/_}
                        SOURCEFILE=$ns.gir
                        cat <<EOF > $SOURCEFILE
@@ -110,7 +112,7 @@ function sourceheader() {
 EOF
                elif [ "$1" = "Output:" ]; then
                        testpath=${testfile/.test/}
-                       ns=${testpath//\//.}
+                       ns=${testpath//\//_}
                        ns=${ns//-/_}
                        SOURCEFILE=$ns.vapi.ref
                fi
@@ -129,8 +131,15 @@ function sourceend() {
                        fi
                        echo "$VAPIGEN $VAPIGENFLAGS --library $ns $ns.gir && tail -n +5 $ns.vapi|sed 
'\$d'|diff -wu $ns.vapi.ref -" > check
                else
-                       echo "}" >> $SOURCEFILE
-                       echo "./test$EXEEXT /$testpath" > check
+                       PACKAGEFLAGS=$([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg")
+                       echo "$VALAC $VALAFLAGS $PACKAGEFLAGS -o $ns$EXEEXT $SOURCEFILE" >> prepare
+                       if [ $DBUSTEST -eq 1 ]; then
+                               if [ $ISSERVER -eq 1 ]; then
+                                       echo "G_DEBUG=fatal-warnings ./$ns$EXEEXT" >> check
+                               fi
+                       else
+                               echo "G_DEBUG=fatal-warnings ./$ns$EXEEXT" >> check
+                       fi
                fi
        fi
 }
@@ -140,20 +149,14 @@ rm -rf $testdir
 mkdir $testdir
 cd $testdir
 
-echo -n -e "TEST: Building...\033[72G"
+echo -n -e "TEST: Preparing...\033[72G"
 
 cat << "EOF" > checkall
 all=0
 fail=0
 EOF
 
-cat << "EOF" > main.vala
-void main (string[] args) {
-       switch (args[1]) {
-EOF
-
 PACKAGES=gio-2.0
-SOURCEFILES=
 for testfile in "$@"; do
        rm -f prepare check
        echo 'set -e' >> prepare
@@ -162,23 +165,23 @@ for testfile in "$@"; do
        case "$testfile" in
        *.vala)
                testpath=${testfile/.vala/}
-               ns=${testpath//\//.}
+               ns=${testpath//\//_}
                ns=${ns//-/_}
                SOURCEFILE=$ns.vala
-               SOURCEFILES="$SOURCEFILES $SOURCEFILE"
 
-               echo "  case \"/$testpath\": $ns.main (); break;" >> main.vala
-               echo "namespace $ns {" > $SOURCEFILE
                cat "$srcdir/$testfile" >> $SOURCEFILE
-               echo "}" >> $SOURCEFILE
 
-               echo "G_DEBUG=fatal-warnings ./test$EXEEXT /$testpath" > check
+               PACKAGEFLAGS=$([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg")
+               echo "$VALAC $VALAFLAGS $PACKAGEFLAGS -o $ns$EXEEXT $SOURCEFILE" >> prepare
+               echo "G_DEBUG=fatal-warnings ./$ns$EXEEXT" >> check
                ;;
        *.test)
                PART=0
                INHEADER=1
                INVALIDCODE=0
                GIRTEST=0
+               DBUSTEST=0
+               ISSERVER=0
                testpath=
                while IFS="" read -r line; do
                        if [ $PART -eq 0 ]; then
@@ -234,23 +237,7 @@ else
 fi
 EOF
 
-cat << "EOF" >> main.vala
-       default: assert_not_reached ();
-       }
-}
-EOF
-
-cat $SOURCEFILES >> main.vala
-
-if $VALAC $VALAFLAGS -o test$EXEEXT $([ -z "$PACKAGES" ] || echo $PACKAGES | xargs -n 1 echo -n " --pkg") 
main.vala &>log; then
-       echo -e "\033[0;32mOK\033[m"
-else
-       echo -e "\033[0;31mFAIL\033[m"
-       cat log
-
-       cd $builddir
-       exit 1
-fi
+echo -e "\033[0;33mDONE\033[m"
 
 if bash checkall; then
        cd $builddir


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]