[vala] Speed up test infrastructure
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Speed up test infrastructure
- Date: Sat, 26 Sep 2009 12:47:32 +0000 (UTC)
commit 2706e671ff9600d252705913342d1890ca1eb43a
Author: Jürg Billeter <j bitron ch>
Date: Fri Sep 25 07:50:05 2009 +0200
Speed up test infrastructure
The updated test runner builds all tests at once to speed up testing.
Makefile.am | 4 +
tests/Makefile.am | 61 +++++----
tests/basic-types/{arrays.test => arrays.vala} | 5 +-
tests/basic-types/{floats.test => floats.vala} | 3 -
tests/basic-types/{integers.test => integers.vala} | 3 -
tests/basic-types/{pointers.test => pointers.vala} | 9 +-
tests/basic-types/{strings.test => strings.vala} | 3 -
tests/control-flow/{break.test => break.vala} | 9 +-
...nditional.test => expressions-conditional.vala} | 9 +-
tests/control-flow/{for.test => for.vala} | 3 -
tests/control-flow/{foreach.test => foreach.vala} | 4 -
.../{sideeffects.test => sideeffects.vala} | 9 +-
tests/control-flow/{switch.test => switch.vala} | 10 +-
tests/dbus/arrays.test | 36 ++---
tests/dbus/async.test | 36 ++---
tests/dbus/basic-types.test | 36 ++---
tests/delegates/{delegates.test => delegates.vala} | 10 +-
tests/enums/{enums.test => enums.vala} | 10 +-
tests/errors/{errors.test => errors.vala} | 10 +-
tests/methods/{closures.test => closures.vala} | 3 -
tests/methods/{lambda.test => lambda.vala} | 10 +-
tests/{namespaces.test => namespaces.vala} | 18 +--
tests/objects/{classes.test => classes.vala} | 3 -
tests/objects/{fields.test => fields.vala} | 10 +-
tests/objects/{interfaces.test => interfaces.vala} | 10 +-
tests/objects/{methods.test => methods.vala} | 9 +-
tests/objects/{properties.test => properties.vala} | 10 +-
tests/objects/{signals.test => signals.vala} | 10 +-
tests/objects/{test-025.test => test-025.vala} | 10 +-
tests/objects/{test-026.test => test-026.vala} | 10 +-
tests/objects/{test-029.test => test-029.vala} | 10 +-
tests/objects/{test-034.test => test-034.vala} | 10 +-
tests/structs/{gvalue.test => gvalue.vala} | 3 -
tests/structs/{structs.test => structs.vala} | 3 -
tests/testrunner.sh | 148 ++++++++++++++------
35 files changed, 295 insertions(+), 252 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3d35273..e603ea9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bde7362..cb29b92 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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) \
diff --git a/tests/basic-types/arrays.test b/tests/basic-types/arrays.vala
similarity index 96%
rename from tests/basic-types/arrays.test
rename to tests/basic-types/arrays.vala
index 0a48cc5..ea88c17 100644
--- a/tests/basic-types/arrays.test
+++ b/tests/basic-types/arrays.vala
@@ -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 ();
diff --git a/tests/basic-types/floats.test b/tests/basic-types/floats.vala
similarity index 98%
rename from tests/basic-types/floats.test
rename to tests/basic-types/floats.vala
index 6a4ac7d..3294bb9 100644
--- a/tests/basic-types/floats.test
+++ b/tests/basic-types/floats.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
void test_double () {
// declaration and initialization
double d = 42d;
diff --git a/tests/basic-types/integers.test b/tests/basic-types/integers.vala
similarity index 98%
rename from tests/basic-types/integers.test
rename to tests/basic-types/integers.vala
index 2c3facc..d9ff890 100644
--- a/tests/basic-types/integers.test
+++ b/tests/basic-types/integers.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
void test_int () {
// declaration and initialization
int i = 42;
diff --git a/tests/basic-types/pointers.test b/tests/basic-types/pointers.vala
similarity index 89%
rename from tests/basic-types/pointers.test
rename to tests/basic-types/pointers.vala
index 75b43ff..7517e71 100644
--- a/tests/basic-types/pointers.test
+++ b/tests/basic-types/pointers.vala
@@ -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 ();
+}
+
diff --git a/tests/basic-types/strings.test b/tests/basic-types/strings.vala
similarity index 97%
rename from tests/basic-types/strings.test
rename to tests/basic-types/strings.vala
index 246549a..2d7df01 100644
--- a/tests/basic-types/strings.test
+++ b/tests/basic-types/strings.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
void test_string () {
// declaration and initialization
string s = "hello";
diff --git a/tests/control-flow/break.test b/tests/control-flow/break.vala
similarity index 75%
rename from tests/control-flow/break.test
rename to tests/control-flow/break.vala
index 71f3297..9eb35d0 100644
--- a/tests/control-flow/break.test
+++ b/tests/control-flow/break.vala
@@ -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 ();
+}
diff --git a/tests/control-flow/expressions-conditional.test b/tests/control-flow/expressions-conditional.vala
similarity index 82%
rename from tests/control-flow/expressions-conditional.test
rename to tests/control-flow/expressions-conditional.vala
index f9e7c1f..5c48350 100644
--- a/tests/control-flow/expressions-conditional.test
+++ b/tests/control-flow/expressions-conditional.vala
@@ -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 ();
+}
diff --git a/tests/control-flow/for.test b/tests/control-flow/for.vala
similarity index 92%
rename from tests/control-flow/for.test
rename to tests/control-flow/for.vala
index 60f3c97..c435c04 100644
--- a/tests/control-flow/for.test
+++ b/tests/control-flow/for.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
void void_method () {
}
diff --git a/tests/control-flow/foreach.test b/tests/control-flow/foreach.vala
similarity index 96%
rename from tests/control-flow/foreach.test
rename to tests/control-flow/foreach.vala
index de8d128..396c9f1 100644
--- a/tests/control-flow/foreach.test
+++ b/tests/control-flow/foreach.vala
@@ -1,7 +1,3 @@
-
-Program: test
-
-
void test_owned (ValueArray array) {
uint i = 0;
diff --git a/tests/control-flow/sideeffects.test b/tests/control-flow/sideeffects.vala
similarity index 79%
rename from tests/control-flow/sideeffects.test
rename to tests/control-flow/sideeffects.vala
index a334d33..56028a5 100644
--- a/tests/control-flow/sideeffects.test
+++ b/tests/control-flow/sideeffects.vala
@@ -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 ();
+}
diff --git a/tests/control-flow/switch.test b/tests/control-flow/switch.vala
similarity index 94%
rename from tests/control-flow/switch.test
rename to tests/control-flow/switch.vala
index 1ee8bb7..9ea363f 100644
--- a/tests/control-flow/switch.test
+++ b/tests/control-flow/switch.vala
@@ -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 ();
+}
+
diff --git a/tests/dbus/arrays.test b/tests/dbus/arrays.test
index 4ee95ff..f119fda 100644
--- a/tests/dbus/arrays.test
+++ b/tests/dbus/arrays.test
@@ -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 ();
}
diff --git a/tests/dbus/async.test b/tests/dbus/async.test
index 03f4e6c..f23aaf9 100644
--- a/tests/dbus/async.test
+++ b/tests/dbus/async.test
@@ -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 ();
}
diff --git a/tests/dbus/basic-types.test b/tests/dbus/basic-types.test
index 289ca17..7dc6a92 100644
--- a/tests/dbus/basic-types.test
+++ b/tests/dbus/basic-types.test
@@ -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 ();
}
diff --git a/tests/delegates/delegates.test b/tests/delegates/delegates.vala
similarity index 96%
rename from tests/delegates/delegates.test
rename to tests/delegates/delegates.vala
index 359d1fa..e80fd3f 100644
--- a/tests/delegates/delegates.test
+++ b/tests/delegates/delegates.vala
@@ -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 ();
+}
+
diff --git a/tests/enums/enums.test b/tests/enums/enums.vala
similarity index 87%
rename from tests/enums/enums.test
rename to tests/enums/enums.vala
index f687e4c..2ee0b63 100644
--- a/tests/enums/enums.test
+++ b/tests/enums/enums.vala
@@ -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 ();
+}
+
diff --git a/tests/errors/errors.test b/tests/errors/errors.vala
similarity index 94%
rename from tests/errors/errors.test
rename to tests/errors/errors.vala
index 4695649..d56f3f2 100644
--- a/tests/errors/errors.test
+++ b/tests/errors/errors.vala
@@ -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 ();
+}
+
diff --git a/tests/methods/closures.test b/tests/methods/closures.vala
similarity index 95%
rename from tests/methods/closures.test
rename to tests/methods/closures.vala
index 526621a..acee5de 100644
--- a/tests/methods/closures.test
+++ b/tests/methods/closures.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
delegate int Func ();
int A (int k, Func x1, Func x2, Func x3, Func x4, Func x5) {
diff --git a/tests/methods/lambda.test b/tests/methods/lambda.vala
similarity index 84%
rename from tests/methods/lambda.test
rename to tests/methods/lambda.vala
index e2f4ad1..d533f68 100644
--- a/tests/methods/lambda.test
+++ b/tests/methods/lambda.vala
@@ -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 ();
+}
+
diff --git a/tests/namespaces.test b/tests/namespaces.vala
similarity index 65%
rename from tests/namespaces.test
rename to tests/namespaces.vala
index 748ae5d..b35db59 100644
--- a/tests/namespaces.test
+++ b/tests/namespaces.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/classes.test b/tests/objects/classes.vala
similarity index 99%
rename from tests/objects/classes.test
rename to tests/objects/classes.vala
index edcbaca..a89f475 100644
--- a/tests/objects/classes.test
+++ b/tests/objects/classes.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
using GLib;
[Compact]
diff --git a/tests/objects/fields.test b/tests/objects/fields.vala
similarity index 97%
rename from tests/objects/fields.test
rename to tests/objects/fields.vala
index 855cfad..5d490c0 100644
--- a/tests/objects/fields.test
+++ b/tests/objects/fields.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/interfaces.test b/tests/objects/interfaces.vala
similarity index 90%
rename from tests/objects/interfaces.test
rename to tests/objects/interfaces.vala
index 64d4279..d9fcdb9 100644
--- a/tests/objects/interfaces.test
+++ b/tests/objects/interfaces.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/methods.test b/tests/objects/methods.vala
similarity index 98%
rename from tests/objects/methods.test
rename to tests/objects/methods.vala
index 0682ed6..49834bd 100644
--- a/tests/objects/methods.test
+++ b/tests/objects/methods.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/properties.test b/tests/objects/properties.vala
similarity index 97%
rename from tests/objects/properties.test
rename to tests/objects/properties.vala
index b8e6f33..e66ecbe 100644
--- a/tests/objects/properties.test
+++ b/tests/objects/properties.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/signals.test b/tests/objects/signals.vala
similarity index 96%
rename from tests/objects/signals.test
rename to tests/objects/signals.vala
index 69aa19b..3a07d99 100644
--- a/tests/objects/signals.test
+++ b/tests/objects/signals.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/test-025.test b/tests/objects/test-025.vala
similarity index 86%
rename from tests/objects/test-025.test
rename to tests/objects/test-025.vala
index 5f224ab..8ffda92 100644
--- a/tests/objects/test-025.test
+++ b/tests/objects/test-025.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/test-026.test b/tests/objects/test-026.vala
similarity index 86%
rename from tests/objects/test-026.test
rename to tests/objects/test-026.vala
index 2a133f9..154efad 100644
--- a/tests/objects/test-026.test
+++ b/tests/objects/test-026.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/test-029.test b/tests/objects/test-029.vala
similarity index 85%
rename from tests/objects/test-029.test
rename to tests/objects/test-029.vala
index ff36bed..acc7ec1 100644
--- a/tests/objects/test-029.test
+++ b/tests/objects/test-029.vala
@@ -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 ();
+}
+
diff --git a/tests/objects/test-034.test b/tests/objects/test-034.vala
similarity index 93%
rename from tests/objects/test-034.test
rename to tests/objects/test-034.vala
index f8394fd..9d39b1f 100644
--- a/tests/objects/test-034.test
+++ b/tests/objects/test-034.vala
@@ -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 ();
+}
+
diff --git a/tests/structs/gvalue.test b/tests/structs/gvalue.vala
similarity index 98%
rename from tests/structs/gvalue.test
rename to tests/structs/gvalue.vala
index 8bd7c42..132af3d 100644
--- a/tests/structs/gvalue.test
+++ b/tests/structs/gvalue.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
void test_value () {
Value v1 = 1;
assert (v1.get_int() == 1);
diff --git a/tests/structs/structs.test b/tests/structs/structs.vala
similarity index 99%
rename from tests/structs/structs.test
rename to tests/structs/structs.vala
index 4b39fee..2a5c06c 100644
--- a/tests/structs/structs.test
+++ b/tests/structs/structs.vala
@@ -1,6 +1,3 @@
-
-Program: test
-
using GLib;
struct SimpleStruct {
diff --git a/tests/testrunner.sh b/tests/testrunner.sh
index 799c16e..6695ad2 100755
--- a/tests/testrunner.sh
+++ b/tests/testrunner.sh
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]