]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Speed up test infrastructure
authorJürg Billeter <j@bitron.ch>
Fri, 25 Sep 2009 05:50:05 +0000 (07:50 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 26 Sep 2009 12:38:44 +0000 (14:38 +0200)
The updated test runner builds all tests at once to speed up testing.

35 files changed:
Makefile.am
tests/Makefile.am
tests/basic-types/arrays.vala [moved from tests/basic-types/arrays.test with 96% similarity]
tests/basic-types/floats.vala [moved from tests/basic-types/floats.test with 98% similarity]
tests/basic-types/integers.vala [moved from tests/basic-types/integers.test with 98% similarity]
tests/basic-types/pointers.vala [moved from tests/basic-types/pointers.test with 89% similarity]
tests/basic-types/strings.vala [moved from tests/basic-types/strings.test with 97% similarity]
tests/control-flow/break.vala [moved from tests/control-flow/break.test with 75% similarity]
tests/control-flow/expressions-conditional.vala [moved from tests/control-flow/expressions-conditional.test with 82% similarity]
tests/control-flow/for.vala [moved from tests/control-flow/for.test with 92% similarity]
tests/control-flow/foreach.vala [moved from tests/control-flow/foreach.test with 96% similarity]
tests/control-flow/sideeffects.vala [moved from tests/control-flow/sideeffects.test with 79% similarity]
tests/control-flow/switch.vala [moved from tests/control-flow/switch.test with 94% similarity]
tests/dbus/arrays.test
tests/dbus/async.test
tests/dbus/basic-types.test
tests/delegates/delegates.vala [moved from tests/delegates/delegates.test with 96% similarity]
tests/enums/enums.vala [moved from tests/enums/enums.test with 87% similarity]
tests/errors/errors.vala [moved from tests/errors/errors.test with 94% similarity]
tests/methods/closures.vala [moved from tests/methods/closures.test with 95% similarity]
tests/methods/lambda.vala [moved from tests/methods/lambda.test with 84% similarity]
tests/namespaces.vala [moved from tests/namespaces.test with 65% similarity]
tests/objects/classes.vala [moved from tests/objects/classes.test with 99% similarity]
tests/objects/fields.vala [moved from tests/objects/fields.test with 97% similarity]
tests/objects/interfaces.vala [moved from tests/objects/interfaces.test with 90% similarity]
tests/objects/methods.vala [moved from tests/objects/methods.test with 98% similarity]
tests/objects/properties.vala [moved from tests/objects/properties.test with 97% similarity]
tests/objects/signals.vala [moved from tests/objects/signals.test with 96% similarity]
tests/objects/test-025.vala [moved from tests/objects/test-025.test with 86% similarity]
tests/objects/test-026.vala [moved from tests/objects/test-026.test with 86% similarity]
tests/objects/test-029.vala [moved from tests/objects/test-029.test with 85% similarity]
tests/objects/test-034.vala [moved from tests/objects/test-034.test with 93% similarity]
tests/structs/gvalue.vala [moved from tests/structs/gvalue.test with 98% similarity]
tests/structs/structs.vala [moved from tests/structs/structs.test with 99% similarity]
tests/testrunner.sh

index 3d35273248c4edcc836c13d94f38c8f6acd2bd7c..e603ea9c82719cea4c64abf943b25a013c58dcec 100644 (file)
@@ -36,6 +36,10 @@ DIST_SUBDIRS = \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = vala-1.0.pc
 
+.PHONY: test
+test:
+       cd tests && $(MAKE) $(AM_MAKEFLAGS) check
+
 dist-hook: gen-ChangeLog
 
 gen_start_date = 2009-02-25
index bde7362460432562b352868815a2141e618a52d3..cb29b92e12a6d45dad73e5c6b1eb7fbe55e546a1 100644 (file)
@@ -15,40 +15,43 @@ noinst_PROGRAMS = \
 TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT) $(srcdir)/testrunner.sh
 
 TESTS = \
-       basic-types/integers.test \
-       basic-types/floats.test \
-       basic-types/strings.test \
-       basic-types/arrays.test \
-       basic-types/pointers.test \
-       namespaces.test \
-       methods/lambda.test \
-       methods/closures.test \
-       control-flow/break.test \
-       control-flow/expressions-conditional.test \
-       control-flow/for.test \
-       control-flow/foreach.test \
-       control-flow/switch.test \
-       control-flow/sideeffects.test \
-       enums/enums.test \
-       structs/structs.test \
-       structs/gvalue.test \
-       delegates/delegates.test \
-       objects/classes.test \
-       objects/fields.test \
-       objects/interfaces.test \
-       objects/methods.test \
-       objects/properties.test \
-       objects/signals.test \
-       objects/test-025.test \
-       objects/test-026.test \
-       objects/test-029.test \
-       objects/test-034.test \
-       errors/errors.test \
+       basic-types/integers.vala \
+       basic-types/floats.vala \
+       basic-types/strings.vala \
+       basic-types/arrays.vala \
+       basic-types/pointers.vala \
+       namespaces.vala \
+       methods/lambda.vala \
+       methods/closures.vala \
+       control-flow/break.vala \
+       control-flow/expressions-conditional.vala \
+       control-flow/for.vala \
+       control-flow/foreach.vala \
+       control-flow/switch.vala \
+       control-flow/sideeffects.vala \
+       enums/enums.vala \
+       structs/structs.vala \
+       structs/gvalue.vala \
+       delegates/delegates.vala \
+       objects/classes.vala \
+       objects/fields.vala \
+       objects/interfaces.vala \
+       objects/methods.vala \
+       objects/properties.vala \
+       objects/signals.vala \
+       objects/test-025.vala \
+       objects/test-026.vala \
+       objects/test-029.vala \
+       objects/test-034.vala \
+       errors/errors.vala \
        dbus/basic-types.test \
        dbus/arrays.test \
        dbus/async.test \
        $(NULL)
 
+check-TESTS: $(TESTS)
+       @EXEEXT=$(EXEEXT) $(srcdir)/testrunner.sh $(TESTS)
+
 EXTRA_DIST = \
        testrunner.sh \
        $(TESTS) \
similarity index 96%
rename from tests/basic-types/arrays.test
rename to tests/basic-types/arrays.vala
index 0a48cc507538bd47a8191098d8db10eb695d2225..ea88c17052a1c329da953e5a937831a5b0f8f345 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 void test_integer_array () {
        // declaration and initialization
        int[] a = { 42 };
@@ -64,7 +61,7 @@ void test_array_pass () {
        assert (b[0] == 42);
 }
 
-void main (string[] args) {
+void main () {
        test_integer_array ();
        test_string_array ();
        test_array_pass ();
similarity index 98%
rename from tests/basic-types/floats.test
rename to tests/basic-types/floats.vala
index 6a4ac7d6cc3c9fc06a44159e6626c6c823177543..3294bb924fe638299094942e29079441d223320b 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 void test_double () {
        // declaration and initialization
        double d = 42d;
similarity index 98%
rename from tests/basic-types/integers.test
rename to tests/basic-types/integers.vala
index 2c3facca07125ff5fcc011283f630f56368965fe..d9ff8903d8f26141bc6d8ef189fb6653be6b8f29 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 void test_int () {
        // declaration and initialization
        int i = 42;
similarity index 89%
rename from tests/basic-types/pointers.test
rename to tests/basic-types/pointers.vala
index 75b43ff262d53fc133b7787432ad71f837d691c4..7517e71b058980a219c68105308c47c50ca375c8 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 struct SimpleStruct {
@@ -10,7 +7,7 @@ struct SimpleStruct {
                return field;
        }
 
-       static void main () {
+       public static void main () {
                SimpleStruct* st = new SimpleStruct[1];
                st->field = 1;
                assert (st->field == st->test ());
@@ -39,3 +36,7 @@ struct SimpleStruct {
        }
 }
 
+void main () {
+       SimpleStruct.main ();
+}
+
similarity index 97%
rename from tests/basic-types/strings.test
rename to tests/basic-types/strings.vala
index 246549ab5f0775326ab3109e36e9dc298bcc3ce7..2d7df015d58585c8a35b60d517e36870e45fb8a6 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 void test_string () {
        // declaration and initialization
        string s = "hello";
similarity index 75%
rename from tests/control-flow/break.test
rename to tests/control-flow/break.vala
index 71f3297b4eab379355e37677d9b2e091a71c4848..9eb35d0a0bc4ea2942053ee6bed1a2530e62c916 100644 (file)
@@ -1,10 +1,7 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Bar : Object {
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Break Test: 1");
                
                int i;
@@ -18,3 +15,7 @@ class Maman.Bar : Object {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
similarity index 82%
rename from tests/control-flow/expressions-conditional.test
rename to tests/control-flow/expressions-conditional.vala
index f9e7c1fc2f7770879eaafe8fb420db750485a6b5..5c48350b5fa0658a70219526fcba6d6fc5f3fb13 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Bar : Object {
@@ -8,7 +5,7 @@ class Maman.Bar : Object {
                return false ? "BAD" : "4";
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Conditional Expression Test: 1");
 
                stdout.printf (" %d", false ? -1 : 2);
@@ -22,3 +19,7 @@ class Maman.Bar : Object {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
similarity index 92%
rename from tests/control-flow/for.test
rename to tests/control-flow/for.vala
index 60f3c97d8a226d9b3be763bbb94128d9a3b319b2..c435c04171c209944edc4f202ae2e7d57d433226 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 void void_method () {
 }
 
similarity index 96%
rename from tests/control-flow/foreach.test
rename to tests/control-flow/foreach.vala
index de8d1286b184fedfc785abb1b9d402fd164358b2..396c9f19c889deda6fef4ac88ccb43f1ce5c83cf 100644 (file)
@@ -1,7 +1,3 @@
-
-Program: test
-
-
 void test_owned (ValueArray array) {
        uint i = 0;
 
similarity index 79%
rename from tests/control-flow/sideeffects.test
rename to tests/control-flow/sideeffects.vala
index a334d33236be00bcbc5d154a0fe246f09c5f71aa..56028a5320b151ff4e1127b573248c00219a6f84 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 class Maman.Foo : Object {
        public int i = 1;
 
@@ -12,10 +9,14 @@ class Maman.Foo : Object {
 }
 
 class Maman.Bar : Object {
-       static int main (string[] args) {
+       public static int main () {
                var foo = new Foo ();
                foo.sideeffect ().data = "foo";
                assert (foo.i == 0);
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
similarity index 94%
rename from tests/control-flow/switch.test
rename to tests/control-flow/switch.vala
index 1ee8bb7356bfae8cc716a20bf60bfb2eac1e3772..9ea363fd1b586685ed42a43c8fdec20bba52687e 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Bar : Object {
@@ -14,7 +11,7 @@ class Maman.Bar : Object {
                }
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("For Test: 1");
 
                int i;
@@ -84,3 +81,8 @@ class Maman.Foo : Object {
        private int counter = 0;
 }
 
+
+void main () {
+       Maman.Bar.main ();
+}
+
index 4ee95ff52f368714d835d2ecc6ca01aa8fc92aac..f119fda459a1b01ecd1437a0f1cb172debe4e28b 100644 (file)
@@ -51,36 +51,30 @@ class Test : Object {
 }
 
 MainLoop main_loop;
-int exit_status;
 
 void client_exit (Pid pid, int status) {
        // client finished, terminate server
-       if (status != 0) {
-               exit_status = 1;
-       }
+       assert (status == 0);
        main_loop.quit ();
 }
 
-int main () {
+void main () {
        var conn = DBus.Bus.get (DBus.BusType.SESSION);
        dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
 
        // try to register service in session bus
        uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
-       if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
-               // start server
-               var server = new Test ();
-               conn.register_object ("/org/example/test", server);
-
-               // server ready, spawn client
-               Pid client_pid;
-               Process.spawn_async (null, { "client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
-               ChildWatch.add (client_pid, client_exit);
-
-               main_loop = new MainLoop (null, false);
-               main_loop.run ();
-       } else {
-               exit_status = 1;
-       }
-       return exit_status;
+       assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
+
+       // start server
+       var server = new Test ();
+       conn.register_object ("/org/example/test", server);
+
+       // 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);
+       ChildWatch.add (client_pid, client_exit);
+
+       main_loop = new MainLoop (null, false);
+       main_loop.run ();
 }
index 03f4e6c039f4168e4a98b1ad37961a6c37d13c19..f23aaf9c53f6ba8254f96719a106214746252962 100644 (file)
@@ -58,36 +58,30 @@ class Test : Object {
 }
 
 MainLoop main_loop;
-int exit_status;
 
 void client_exit (Pid pid, int status) {
        // client finished, terminate server
-       if (status != 0) {
-               exit_status = 1;
-       }
+       assert (status == 0);
        main_loop.quit ();
 }
 
-int main () {
+void main () {
        var conn = DBus.Bus.get (DBus.BusType.SESSION);
        dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
 
        // try to register service in session bus
        uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
-       if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
-               // start server
-               var server = new Test ();
-               conn.register_object ("/org/example/test", server);
-
-               // server ready, spawn client
-               Pid client_pid;
-               Process.spawn_async (null, { "client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
-               ChildWatch.add (client_pid, client_exit);
-
-               main_loop = new MainLoop (null, false);
-               main_loop.run ();
-       } else {
-               exit_status = 1;
-       }
-       return exit_status;
+       assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
+
+       // start server
+       var server = new Test ();
+       conn.register_object ("/org/example/test", server);
+
+       // 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);
+       ChildWatch.add (client_pid, client_exit);
+
+       main_loop = new MainLoop (null, false);
+       main_loop.run ();
 }
index 289ca1763fc4c3a49a4806a6c87a986ea22cb78d..7dc6a9200918f3305d5fbe6c8b91ced00676736a 100644 (file)
@@ -51,36 +51,30 @@ class Test : Object {
 }
 
 MainLoop main_loop;
-int exit_status;
 
 void client_exit (Pid pid, int status) {
        // client finished, terminate server
-       if (status != 0) {
-               exit_status = 1;
-       }
+       assert (status == 0);
        main_loop.quit ();
 }
 
-int main () {
+void main () {
        var conn = DBus.Bus.get (DBus.BusType.SESSION);
        dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
 
        // try to register service in session bus
        uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
-       if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
-               // start server
-               var server = new Test ();
-               conn.register_object ("/org/example/test", server);
-
-               // server ready, spawn client
-               Pid client_pid;
-               Process.spawn_async (null, { "client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
-               ChildWatch.add (client_pid, client_exit);
-
-               main_loop = new MainLoop (null, false);
-               main_loop.run ();
-       } else {
-               exit_status = 1;
-       }
-       return exit_status;
+       assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
+
+       // start server
+       var server = new Test ();
+       conn.register_object ("/org/example/test", server);
+
+       // 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);
+       ChildWatch.add (client_pid, client_exit);
+
+       main_loop = new MainLoop (null, false);
+       main_loop.run ();
 }
similarity index 96%
rename from tests/delegates/delegates.test
rename to tests/delegates/delegates.vala
index 359d1faf568ef434d4443c1ea0ec706970666726..e80fd3fe83f73a7b33791896289d51ca84416771 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 public enum ParameterEnum { FOO, BAR }
@@ -71,7 +68,7 @@ class Maman.Bar : Object, Foo {
                call_instance_delegate (bar.foo_method);
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Delegate Test: 1");
                
                VoidCallback void_cb = do_void_action;
@@ -103,3 +100,8 @@ class Maman.Bar : Object, Foo {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 87%
rename from tests/enums/enums.test
rename to tests/enums/enums.vala
index f687e4c13f779e29ec7f48b21d420ca901c23662..2ee0b6368a5870204bec6636cb09fbc7efe6d92f 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 enum Maman.Foo {
@@ -24,7 +21,7 @@ class Maman.Bar : Object {
                Foo foo = 0;
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Enum Test: 1");
                
                var bar = new Bar ();
@@ -37,3 +34,8 @@ class Maman.Bar : Object {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 94%
rename from tests/errors/errors.test
rename to tests/errors/errors.vala
index 46956493032f63a3d62970b848a7345557fa9af6..d56f3f230846a454bf82c438007a007967a9943f 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 errordomain Maman.BarError {
@@ -74,7 +71,7 @@ class Maman.Bar : Object {
                }
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Exception Test: 1");
                
                var bar = new Bar ();
@@ -87,3 +84,8 @@ class Maman.Bar : Object {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 95%
rename from tests/methods/closures.test
rename to tests/methods/closures.vala
index 526621a67a86c9307cc955c7e361e6693bb9e6a3..acee5de289e015adceb9effcfeeb4aab48ae4221 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 delegate int Func ();
 
 int A (int k, Func x1, Func x2, Func x3, Func x4, Func x5) {
similarity index 84%
rename from tests/methods/lambda.test
rename to tests/methods/lambda.vala
index e2f4ad1e6a4144ea7baf9c0215eb85c386a2e868..d533f688bf5715bea4a83ee5810a8cd11bea2cc9 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 static delegate int Maman.ActionCallback (int i);
@@ -10,7 +7,7 @@ class Maman.Bar : Object {
                return cb (1);
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Lambda Test: 1");
                
                stdout.printf (" %d", do_action (i => i * 2));
@@ -22,3 +19,8 @@ class Maman.Bar : Object {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 65%
rename from tests/namespaces.test
rename to tests/namespaces.vala
index 748ae5d24891aa227986e64343d83db8acef7ff5..b35db592744eccc1ddae442a23e0a74ae548ab54 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using Foo.Sub;
 
 public class GlobalTestClass {
@@ -9,18 +6,12 @@ public class GlobalTestClass {
 }
 
 namespace Maman {
-       public class GlobalTestClass {
-               public GlobalTestClass() {
-                       stdout.printf("Incorrect class constructed");
-               }
-       }
-
-       static int main (string[] args) {
+       static int main () {
                stdout.printf ("Namespace Test\n");
 
                Bar.run ();
 
-               new global::GlobalTestClass();
+               new GlobalTestClass();
 
                var obj = new ClassInNestedNamespace ();
 
@@ -37,3 +28,8 @@ namespace Maman {
 public class Foo.Sub.ClassInNestedNamespace {
 }
 
+
+void main () {
+       Maman.main ();
+}
+
similarity index 99%
rename from tests/objects/classes.test
rename to tests/objects/classes.vala
index edcbaca4881665a9997f4fffe9ace01acf0e7248..a89f475e66e627043991a11a8a7dc44e0dd1d5d9 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 [Compact]
similarity index 97%
rename from tests/objects/fields.test
rename to tests/objects/fields.vala
index 855cfadd7313fd46f09390ef4e6e5b4bbb605a93..5d490c0909bb699890d205cbe0133d731810ea45 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 [Compact]
@@ -71,7 +68,7 @@ class Maman.Bar : Foo {
                                           private_class_field, public_class_field);
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Field Test: 1");
                
                var bar = new Bar ();
@@ -100,3 +97,8 @@ class Maman.Bar : Foo {
                return 0;
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 90%
rename from tests/objects/interfaces.test
rename to tests/objects/interfaces.vala
index 64d42794cd004f611889557f76af9600a19d4364..d9fcdb9c50a0cd6ee7c616c079e040d4fc4932a7 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 interface Maman.Ibaz : Object {
@@ -24,7 +21,7 @@ class Maman.SubBaz : Baz {
                stdout.printf (" 6");
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Interface Test: 1");
 
                Ibaz ibaz = new Baz ();
@@ -44,3 +41,8 @@ class Maman.SubBaz : Baz {
                return 0;
        }
 }
+
+void main () {
+       Maman.SubBaz.main ();
+}
+
similarity index 98%
rename from tests/objects/methods.test
rename to tests/objects/methods.vala
index 0682ed67422ec7923f512de9aa04003fb6d584a6..49834bdd44b3c5a1a0fbfb995e880a009cee9948 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Bar : Object {
@@ -30,7 +27,7 @@ class Maman.SubBar : Bar {
                accept_ref_string (ref str);
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Inheritance Test: 1");
 
                var bar = new SubBar ();
@@ -218,3 +215,7 @@ class Maman.ClassTest {
        }
 }
 
+void main () {
+       Maman.SubBar.main ();
+}
+
similarity index 97%
rename from tests/objects/properties.test
rename to tests/objects/properties.vala
index b8e6f332be60a6236f452f7f7337f712da8d5336..e66ecbeb3c796a61c202a9c06f92248da73f5140 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 public class Sample : Object {
@@ -45,7 +42,7 @@ public class Sample : Object {
                stdout.printf("automatic: %s\n", automatic);
         }
 
-       static int main (string[] args) {
+       public static int main () {
                var test = new Sample("InitialName");
 
                test.run();
@@ -115,3 +112,8 @@ class Maman.Baz : Object, Ibaz {
                get { return 2; }
        }
 }
+
+void main () {
+       Sample.main ();
+}
+
similarity index 96%
rename from tests/objects/signals.test
rename to tests/objects/signals.vala
index 69aa19bf361890cfc2d9d6e382a608a15e67a6cb..3a07d99f44937bfde92b625da679ac371b8a0f0e 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Foo : Object {
@@ -50,7 +47,7 @@ class Maman.Bar : Object {
                stdout.printf (" 9");
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Signal Test: 1");
                
                var bar = new Bar ();
@@ -130,3 +127,8 @@ class Maman.ReturnBar : Object {
                stdout.printf (" 7");
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 86%
rename from tests/objects/test-025.test
rename to tests/objects/test-025.vala
index 5f224ab0c10217c77c27bbedc3e26c5782449f35..8ffda92cf8d0811f658e5eb34c1798b4fd477502 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Bar : Object {
@@ -22,7 +19,7 @@ class Maman.SubBar : Bar {
                stdout.printf (" 4");
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Base Access Test: 1");
 
                var bar = new SubBar ();
@@ -33,3 +30,8 @@ class Maman.SubBar : Bar {
                return 0;
        }
 }
+
+void main () {
+       Maman.SubBar.main ();
+}
+
similarity index 86%
rename from tests/objects/test-026.test
rename to tests/objects/test-026.vala
index 2a133f94e0c7bf0a4714723ae3f522b37490d06f..154efadb1d0b68d8965b410cc97eba3dffbf2a4c 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Bar : Object {
@@ -22,7 +19,7 @@ class Maman.SubBar : Bar {
                stdout.printf (" 4");
        }
 
-       static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Hidden Base Method Access Test: 1");
 
                var bar = new SubBar ();
@@ -33,3 +30,8 @@ class Maman.SubBar : Bar {
                return 0;
        }
 }
+
+void main () {
+       Maman.SubBar.main ();
+}
+
similarity index 85%
rename from tests/objects/test-029.test
rename to tests/objects/test-029.vala
index ff36beda6bc97b5fdf41fce93afd8a16441522c8..acc7ec1d719d006621972062ccadfbcec18f03c7 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.Foo : Object {
@@ -12,7 +9,7 @@ class Maman.Foo : Object {
                this.p2 = p2;
        }
        
-       public static int main (string[] args) {
+       public static int main () {
                stdout.printf ("Construct Formal Parameter Test: 1");
                
                var foo = new Foo (2, 3);
@@ -26,3 +23,8 @@ class Maman.Foo : Object {
                return 0;
        }
 }
+
+void main () {
+       Maman.Foo.main ();
+}
+
similarity index 93%
rename from tests/objects/test-034.test
rename to tests/objects/test-034.vala
index f8394fd43846d78b9f676833dfb5d06f519a2442..9d39b1f3b6e54a29dc059b82096dd39b59cbc60c 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 class Maman.A : Object {
@@ -13,7 +10,7 @@ class Maman.C : Object {
 }
 
 class Maman.Bar : Object {
-       static void main () {
+       public static void main () {
                var a = new A ();
                var b = new B ();
                var c = new C ();
@@ -29,3 +26,8 @@ class Maman.Bar : Object {
                stdout.printf ("as C: %d %d %d\n", null != (a as C) ? 1 : 0, null != (b as C) ? 1 : 0, null != (c as C) ? 1 : 0);
        }
 }
+
+void main () {
+       Maman.Bar.main ();
+}
+
similarity index 98%
rename from tests/structs/gvalue.test
rename to tests/structs/gvalue.vala
index 8bd7c42d1c04c05cdf916363072b3f9f38e80a3e..132af3d450aee36f6f880301e7b12f71d6736bd3 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 void test_value () {
        Value v1 = 1;
        assert (v1.get_int() == 1);
similarity index 99%
rename from tests/structs/structs.test
rename to tests/structs/structs.vala
index 4b39feeb45bca5ef1addd7eecc8ab629759fb6be..2a5c06c476fb56da783ebbaf28056e574ec4470a 100644 (file)
@@ -1,6 +1,3 @@
-
-Program: test
-
 using GLib;
 
 struct SimpleStruct {
index 799c16eb26ca9d539b5ad4e4f020c2d843c67df8..6695ad24950b2f0f32ffd532f740e6e21026951b 100755 (executable)
@@ -29,18 +29,13 @@ vapidir=$topsrcdir/vapi
 export G_DEBUG=fatal_warnings
 
 VALAC=$topbuilddir/compiler/valac
-VALAFLAGS="--vapidir $vapidir"
-CC="gcc -std=c99"
-CFLAGS="-O0 -g3"
-LDLIBS="-lm"
-
-CODE=0
+VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -O0 -X -pipe -X -lm"
 
 function testheader() {
        if [ "$1" = "Packages:" ]; then
                shift
-               PACKAGES="$@"
-               for pkg in $PACKAGES; do
+               PACKAGES="$PACKAGES $@"
+               for pkg in "$@"; do
                        if [ "$pkg" = "dbus-glib-1" ]; then
                                echo 'eval `dbus-launch --sh-syntax`' >> prepare
                                echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare
@@ -51,36 +46,66 @@ function testheader() {
 
 function sourceheader() {
        if [ "$1" = "Program:" ]; then
-               PROGRAM=$2
-               SOURCEFILE=$PROGRAM.vala
+               testpath=${testfile/.test/}/$2
+               ns=${testpath//\//.}
+               ns=${ns//-/_}
+               SOURCEFILE=$ns.vala
+               SOURCEFILES="$SOURCEFILES $SOURCEFILE"
+               echo "  case \"/$testpath\": $ns.main (); break;" >> main.vala
+               echo "namespace $ns {" > $SOURCEFILE
        fi
 }
 
 function sourceend() {
-       if [ -n "$PROGRAM" ]; then
-               echo "$VALAC $VALAFLAGS $(echo $PACKAGES | xargs -n 1 -r echo -n " --pkg") -C $SOURCEFILE" >> build
-               echo "$CC $CFLAGS -o $PROGRAM$EXEEXT $PROGRAM.c \$(pkg-config --cflags --libs glib-2.0 gobject-2.0 $PACKAGES) $LDLIBS" >> build
-               echo "./$PROGRAM$EXEEXT" > check
+       if [ -n "$testpath" ]; then
+               echo "}" >> $SOURCEFILE
+               echo "./test$EXEEXT /$testpath" > check
        fi
 }
 
-for testfile in "$@"; do
-       testname=$(basename $testfile)
-       testdir=${testname/.test/.d}
-       rm -rf $testdir
-       mkdir $testdir
-       cd $testdir
+testdir=_test
+rm -rf $testdir
+mkdir $testdir
+cd $testdir
+
+echo -n -e "TEST: Building...\033[72G"
+
+cat << "EOF" > checkall
+all=0
+fail=0
+EOF
 
-       touch prepare build check cleanup
+cat << "EOF" > main.vala
+void main (string[] args) {
+       switch (args[1]) {
+EOF
 
+PACKAGES=
+SOURCEFILES=
+for testfile in "$@"; do
+       rm -f prepare check
        echo 'set -e' >> prepare
 
-       PART=0
-       INHEADER=1
-       PACKAGES=
-       PROGRAM=
-       cat "$builddir/$testfile" | while true; do
-               if IFS="" read -r line; then
+       case "$testfile" in
+       *.vala)
+               testpath=${testfile/.vala/}
+               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 "./test$EXEEXT /$testpath" > check
+               ;;
+       *.test)
+               PART=0
+               INHEADER=1
+               testpath=
+               while IFS="" read -r line; do
                        if [ $PART -eq 0 ]; then
                                if [ -n "$line" ]; then
                                        testheader $line
@@ -99,31 +124,64 @@ for testfile in "$@"; do
                                                sourceend
                                                PART=$(($PART + 1))
                                                INHEADER=1
-                                               PROGRAM=
+                                               testpath=
                                                sourceheader $line
                                        else
                                                echo "$line" >> $SOURCEFILE
                                        fi
                                fi
                        fi
-               else
-                       sourceend
-                       break
-               fi
-       done
-
-       cat prepare build check cleanup > script
-       if ! bash script >log 2>&1; then
-               cat log
-               CODE=1
-       fi
+               done < "$srcdir/$testfile"
+               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
+done
 
-       cd $builddir
+cat << "EOF" >> checkall
+if [ $fail -eq 0 ]; then
+       echo "All $all tests passed"
+else
+       echo "$fail of $all tests failed"
+       exit 1
+fi
+EOF
+
+cat << "EOF" >> main.vala
+       default: assert_not_reached ();
+       }
+}
+EOF
 
-       if [ $CODE -eq 0 ]; then
-               rm -rf $testdir
-       fi
-done
+cat $SOURCEFILES >> main.vala
 
-exit $CODE
+if $VALAC $VALAFLAGS -o test$EXEEXT $(echo $PACKAGES | xargs -n 1 -r 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
+
+if bash checkall; then
+       cd $builddir
+       rm -rf $testdir
+else
+       cd $builddir
+       exit 1
+fi