[vala/wip/valadate: 44/71] Codestyle and source adjustments



commit d7b5cdd083f118820ffe4ec408abc0efd60c99b7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Sep 26 17:09:19 2016 +0200

    Codestyle and source adjustments

 Makefile.am                 |    1 +
 tests/Makefile.am           |    4 +-
 tests/valadatetests.vala    |   64 +++-----
 tests/valatests.vala        |   80 +++++-----
 tests/valatestsfactory.vala |  376 +++++++++++++++++++++----------------------
 valadate/module.vala        |   25 ++--
 valadate/test.vala          |   21 ++--
 valadate/testcase.vala      |  111 +++++++-------
 valadate/testconfig.vala    |   14 +-
 valadate/testexplorer.vala  |  114 +++++++-------
 valadate/testfixture.vala   |    1 -
 valadate/testiterator.vala  |    1 +
 valadate/testresult.vala    |  150 +++++++++---------
 valadate/testrunner.vala    |   15 +-
 valadate/testsuite.vala     |   35 +++--
 15 files changed, 495 insertions(+), 517 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 5e3203d..a4a6b15 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -92,6 +92,7 @@ EXTRA_DIST = \
        build-aux/gitlog-to-changelog \
        build-aux/glib-tap.mk \
        build-aux/tap-driver.sh \
+       build-aux/tap-test \
        $(NULL)
 
 DISTCLEANFILES = version.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fa82237..5790044 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,9 @@
 include $(top_srcdir)/Makefile.common
 include $(top_srcdir)/build-aux/glib-tap.mk
 
-test_programs = valadatetests valactests@PACKAGE_SUFFIX@
+noinst_PROGRAMS = valadatetests valactests@PACKAGE_SUFFIX@
+
+test_programs = $(noinst_PROGRAMS)
 
 # Valadate tests
 valadatetests_VALAFLAGS = \
diff --git a/tests/valadatetests.vala b/tests/valadatetests.vala
index 6a2abb0..95c28fb 100644
--- a/tests/valadatetests.vala
+++ b/tests/valadatetests.vala
@@ -15,64 +15,50 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- * 
+ *
  * Authors:
  *     Chris Daley <chebizarro gmail com>
  */
- 
+
 public class Valadate.Tests.TestFixture : Valadate.TestCase {
-       
-       public void test_testcase() {
-               
+
+       public void test_testcase () {
                bug_base = "http://bugzilla.gnome.org/";;
-               
-               bug("555666");
-               
-               stdout.puts("This is a test of the system");
+               bug ("555666");
+               stdout.puts ("This is a test of the system");
        }
 
-       public void test_testcase_1() {
-
+       public void test_testcase_1 () {
                string key = "XDG_DATA_DIRS";
-               var val = Environment.get_variable(key);
-               message("%s = %s",key, val);
-               
-               foreach(var item in Environment.get_system_data_dirs())
-                       message("%s",item);
-
+               var val = Environment.get_variable (key);
+               message ("%s = %s",key, val);
+               foreach (var item in Environment.get_system_data_dirs ())
+                       message ("%s",item);
        }
 
-       public void test_testcase_2() {
-               message(Valadate.get_current_test_path());
-               skip("No reason");
-               debug("This is a second test of the system");
+       public void test_testcase_2 () {
+               message (Valadate.get_current_test_path ());
+               skip ("No reason");
+               debug ("This is a second test of the system");
        }
 
-       public void test_testcase_3() {
-               
-               //stdout.puts("Before");
-               //assert(false);
-               //fail("after");
-               
+       public void test_testcase_3 () {
+               //stdout.puts ("Before");
+               //assert (false);
+               //fail ("after");
+
                void* nullisland = null;
-               
                Object nullobj = nullisland as Object;
-               
-               //nullobj.get_type().name();
-               
+
+               //nullobj.get_type ().name ();
        }
-       
 }
 
 public class Valadate.Tests.TestFixtureTwo : Valadate.TestCase {
 
-       public void test_testcase() {
-               
+       public void test_testcase () {
                bug_base = "http://bugzilla.gnome.org/";;
-               
-               bug("555999");
-               
-               stdout.puts("This is a test of the system");
+               bug ("555999");
+               stdout.puts ("This is a test of the system");
        }
-
 }
diff --git a/tests/valatests.vala b/tests/valatests.vala
index 9ecc69b..22322ab 100644
--- a/tests/valatests.vala
+++ b/tests/valatests.vala
@@ -19,25 +19,23 @@
 
 public class Vala.Tests : Valadate.TestSuite {
        
-       public Tests() {
-               load_tests();
-       }
+       private const string BUGZILLA_URL = "http://bugzilla.gnome.org/";;
 
-       private void load_tests() {
+       construct {
                try {
-                       var testdir = File.new_for_path(GLib.Environment.get_current_dir());
-                       var testpath = Valadate.get_current_test_path();
+                       var testdir = File.new_for_path (GLib.Environment.get_current_dir ());
+                       var testpath = Valadate.get_current_test_path ();
                        
                        if (testpath != null) {
-                               var testpaths = testpath.split("/");
+                               var testpaths = testpath.split ("/");
                                if (testpaths.length < 4)
                                        return;
-                               var runtest = testdir.get_child(testpaths[3]);
-                               if(runtest.query_exists())
-                                       add_test(new ValaTest(runtest));
+                               var runtest = testdir.get_child (testpaths[3]);
+                               if (runtest.query_exists ())
+                                       add_test (new ValaTest (runtest));
                        } else {
-                               var tempdir = testdir.get_child(".tests");
-                               if(!tempdir.query_exists())
+                               var tempdir = testdir.get_child (".tests");
+                               if (!tempdir.query_exists())
                                        tempdir.make_directory();
 
                                var enumerator = testdir.enumerate_children (FileAttribute.STANDARD_NAME, 0);
@@ -45,60 +43,56 @@ public class Vala.Tests : Valadate.TestSuite {
                                while ((file_info = enumerator.next_file ()) != null)
                                        if (file_info.get_file_type() == GLib.FileType.DIRECTORY &&
                                                !file_info.get_name().has_prefix("."))
-                                               add_test(new 
ValaTest(testdir.get_child(file_info.get_name())));
+                                               add_test (new ValaTest 
(testdir.get_child(file_info.get_name())));
                        }
                } catch (Error e) {
                        stderr.printf ("Error: %s\n", e.message);
                }
        }
 
-
        private class ValaTest : Valadate.TestCase {
 
-               private const string BUGZILLA_URL = "http://bugzilla.gnome.org/";;
-               
-               private TestsFactory factory = TestsFactory.get_instance();
+               private TestsFactory factory = TestsFactory.get_instance ();
                
-               public ValaTest(File directory) throws Error {
-                       this.name = directory.get_basename();
+               public ValaTest (File directory) throws Error {
+                       this.name = directory.get_basename ();
                        this.bug_base = BUGZILLA_URL;
 
-                       string current_test = Valadate.get_current_test_path();
+                       string current_test = Valadate.get_current_test_path ();
 
-                       if(current_test != null) {
-                               var basename = Path.get_basename(current_test);
-                               if (directory.get_child(basename + ".vala").query_exists())
-                                       load_test(directory.get_child(basename + ".vala"));
-                               else if (directory.get_child(basename + ".test").query_exists())
-                                       load_test(directory.get_child(basename + ".test"));
-                               else if (directory.get_child(basename + ".gs").query_exists())
-                                       load_test(directory.get_child(basename + ".gs"));
+                       if (current_test != null) {
+                               var basename = Path.get_basename (current_test);
+                               if (directory.get_child (basename + ".vala").query_exists ())
+                                       load_test (directory.get_child (basename + ".vala"));
+                               else if (directory.get_child (basename + ".test").query_exists ())
+                                       load_test (directory.get_child (basename + ".test"));
+                               else if (directory.get_child (basename + ".gs").query_exists ())
+                                       load_test (directory.get_child (basename + ".gs"));
                        } else {
                                var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 
0);
                                FileInfo file_info;
                                while ((file_info = enumerator.next_file ()) != null) {
-                                       if (file_info.get_file_type() == GLib.FileType.DIRECTORY)
+                                       if (file_info.get_file_type () == GLib.FileType.DIRECTORY)
                                                continue;
-                                       load_test(directory.get_child(file_info.get_name()));
+                                       load_test (directory.get_child (file_info.get_name ()));
                                }
                        }
                }
 
-               private void load_test(File testfile) throws Error {
-                       string testname = testfile.get_basename().substring(
-                               0,testfile.get_basename().last_index_of("."));
-
-                       add_test(testname,
-                        ()=> {
+               private void load_test (File testfile) throws Error {
+                       string basename = testfile.get_basename ();
+                       string testname = basename.substring (0, basename.last_index_of ("."));
+                       add_test (testname, () => {
                                try {
-                                       if(testname.has_prefix("bug"))
-                                               bug(testname.substring(3));
-                                       var prog = factory.get_test_program(testfile);
-                                       prog.run();
-                                       factory.cleanup();
+                                       if (testname.has_prefix ("bug"))
+                                               bug (testname.substring(3));
+                                       var prog = factory.get_test_program (testfile);
+                                       prog.run ();
+                                       factory.cleanup ();
                                } catch (Error e) {
-                                       fail(e.message);
-                               }});
+                                       fail (e.message);
+                               }
+                       });
                }
        }
 }
diff --git a/tests/valatestsfactory.vala b/tests/valatestsfactory.vala
index ebe140e..24e2092 100644
--- a/tests/valatestsfactory.vala
+++ b/tests/valatestsfactory.vala
@@ -20,94 +20,92 @@
  *     Chris Daley <chebizarro gmail com>
  */
 
-internal class Vala.TestsFactory : Object {
+public class Vala.TestsFactory : Object {
 
-       internal static File currdir;
-       internal static File testdir;
-       internal static File buildir;
-       internal static File valac;
-       internal static File vapidir;
+       static File currdir;
+       static File testdir;
+       static File buildir;
+       static File valac;
+       static File vapidir;
 
        class construct {
-               currdir = File.new_for_path(GLib.Environment.get_current_dir());
-               testdir = currdir.get_child(".tests");
-               buildir = currdir.get_parent();
+               currdir = File.new_for_path (GLib.Environment.get_current_dir());
+               testdir = currdir.get_child (".tests");
+               buildir = currdir.get_parent ();
 
-               var usevalac = Environment.get_variable("VALAC");
+               var usevalac = Environment.get_variable ("VALAC");
                if (usevalac != null && File.new_for_path(usevalac).query_exists())
                        valac = File.new_for_path(usevalac);
                else
                        valac = buildir.get_child("compiler").get_child("valac");
 
-               var usevapidir = Environment.get_variable("VAPIDIR");
-               if (usevapidir != null && File.new_for_path(usevapidir).query_exists())
-                       vapidir = File.new_for_path(usevapidir);
+               var usevapidir = Environment.get_variable ("VAPIDIR");
+               if (usevapidir != null && File.new_for_path (usevapidir).query_exists())
+                       vapidir = File.new_for_path (usevapidir);
                else
-                       vapidir = buildir.get_child("vapi");
+                       vapidir = buildir.get_child ("vapi");
                
        }
 
        private static TestsFactory instance;
-       public ValaCompiler compiler;
 
-       private Program[] programs = {};
-       private File[] tempfiles = {};
-       
-       public static TestsFactory get_instance() {
+       public static unowned TestsFactory get_instance() {
                if (instance == null)
-                       instance = new TestsFactory();
+                       instance = new TestsFactory ();
                return instance;
        }
 
-       private TestsFactory() {
-               compiler = new ValaCompiler(valac);
+       public ValaCompiler compiler;
+
+       private Program[] programs = {};
+       private File[] tempfiles = {};
+
+       private TestsFactory () {
+               compiler = new ValaCompiler (valac);
        }
 
-       public void cleanup() throws Error {
-               foreach (var file in tempfiles)
-                       if(file.query_exists())
-                               file.delete();
+       public void cleanup () throws Error {
+               foreach (unowned File file in tempfiles)
+                       if (file.query_exists ())
+                               file.delete ();
+               tempfiles = {};
 
-               foreach (var prog in programs)
-                       prog.cleanup();
+               foreach (unowned Program prog in programs)
+                       prog.cleanup ();
+               programs = {};
        }
 
-       public Program get_test_program(File testfile) throws Error {
-               string testname = testfile.get_basename().substring(
-                       0,testfile.get_basename().last_index_of("."));
+       public Program get_test_program (File testfile) throws Error {
+               string basename = testfile.get_basename ();
+               string testname = basename.substring (0, basename.last_index_of ("."));
                
                Program program = null;
                
-               if(testfile.get_basename().has_suffix(".vala") || testfile.get_basename().has_suffix(".gs")) {
-                       program = compiler.compile(testdir.get_child(testname), testfile, "--main main");
-               } else if(testfile.get_basename().has_suffix(".test")) {
-                       var stream = new DataInputStream(testfile.read());
-                       
-                       string line = stream.read_line(null);
-                       
+               if (basename.has_suffix (".vala") || basename.has_suffix (".gs")) {
+                       program = compiler.compile (testdir.get_child (testname), testfile, "--main main");
+               } else if (basename.has_suffix (".test")) {
+                       var stream = new DataInputStream (testfile.read ());
+                       string line = stream.read_line (null);
                        string packages = "";
-                       
-                       if (line.has_prefix("Packages:")) {
-                               packages = line.split(":")[1];
-                               packages = string.joinv(" --pkg ", packages.split(" "));
-                               line = stream.read_line(null);
+
+                       if (line.has_prefix ("Packages:")) {
+                               packages = line.split (":")[1];
+                               packages = string.joinv (" --pkg ", packages.split (" "));
+                               line = stream.read_line (null);
                        }
-                       
+
                        switch (line) {
                                case "D-Bus":
-                                       program = new DBusTest(testname, packages, stream);
+                                       program = new DBusTest (testname, packages, stream);
                                        break;
-
                                case "Invalid Code":
-                                       program = new InvalidCode(testname, packages, stream);
+                                       program = new InvalidCode (testname, packages, stream);
                                        break;
-
                                case "GIR":
-                                       program = new GIRTestProgram(testname, packages, stream);
+                                       program = new GIRTestProgram (testname, packages, stream);
                                        break;
-                               
                                default:
-                                       program = new TestProgram(testdir.get_child(testname));
+                                       program = new TestProgram (testdir.get_child (testname));
                                        break;
                        }
                }
@@ -117,159 +115,156 @@ internal class Vala.TestsFactory : Object {
 
        public abstract class Program : Object {
 
-               public delegate void CommandCallback(bool err, string buffer);
+               [CCode (has_target = false)]
+               public delegate void CommandCallback (bool err, string buffer);
 
-               public static SubprocessLauncher launcher;
+               static SubprocessLauncher launcher;
 
                class construct {
-                       launcher = new SubprocessLauncher(GLib.SubprocessFlags.STDOUT_PIPE | 
GLib.SubprocessFlags.STDERR_MERGE);
-                       launcher.set_cwd(testdir.get_path());
+                       launcher = new SubprocessLauncher (GLib.SubprocessFlags.STDOUT_PIPE | 
GLib.SubprocessFlags.STDERR_MERGE);
+                       launcher.set_cwd (testdir.get_path ());
                }
-               
-               public File program {get; private set;}
-               
-               public CommandCallback callback {get;set;}
-               
-               private File[] files = {};
-               
-               public Program(File program) {
-                       this.program = program;
-                       files += program;
-                       callback = default_callback;
+
+               public File program { get; construct; }
+
+               public CommandCallback callback { get; set; default = default_callback; }
+
+               private File[] files;
+
+               public Program (File program) {
+                       Object (program : program);
+               }
+
+               construct {
+                       files = {};
                }
-       
-               public void add_file(File file) {
+
+               public void add_file (File file) {
                        files += file;
                }
-       
-               private void default_callback(bool err, string buffer) {
+
+               private static void default_callback (bool err, string buffer) {
                        if (err)
-                               error(buffer);
+                               error (buffer);
                        else
                                stdout.printf ("%s", buffer);
                }
-               
-               public virtual void run(string? command = null) throws Error {
+
+               public virtual void run (string? command = null) throws Error {
                        string[] args;
-                       Shell.parse_argv("%s %s".printf(program.get_path(), command ?? ""), out args);
+                       Shell.parse_argv ("%s %s".printf (program.get_path (), command ?? ""), out args);
                        string buffer = null;
-                       var process = launcher.spawnv(args);
-                       process.communicate_utf8(null, null, out buffer, null);
+                       var process = launcher.spawnv (args);
+                       process.communicate_utf8 (null, null, out buffer, null);
 
                        try {
-                               if(process.wait_check())
-                                       callback(false, buffer);
+                               if (process.wait_check ())
+                                       callback (false, buffer);
                        } catch (Error e) {
-                               callback(true, buffer);
+                               callback (true, buffer);
                        }
                }
-               
+
                public virtual void cleanup() throws Error {
-                       foreach(File file in files)
-                               if(file.query_exists())
-                                       file.delete();
+                       foreach (unowned File file in files)
+                               if (file.query_exists ())
+                                       file.delete ();
                }
        }
-       
+
        public class TestProgram : Program {
-               public TestProgram(File program) {
-                       base(program);
+               public TestProgram (File program) {
+                       Object (program : program);
                }
 
-               public void add_file_from_stream(
-                       File file,
-                       DataInputStream stream,
-                       string? start,
-                       string? end,
-                       string? header = null,
-                       string? footer = null) throws Error {
-                       
-                               var newfile = file.create(FileCreateFlags.NONE);
-                               var outstream = new DataOutputStream (newfile);
-                               string line;
-                               
-                               if(header != null)
-                                       outstream.put_string(header + "\n");
-                               
-                               if(start != null)
-                                       do {} while ((line = stream.read_line (null)) != start);
-
-                               while ((line = stream.read_line (null)) != end)
-                                       outstream.put_string(line + "\n");
-
-                               if(footer != null)
-                                       outstream.put_string(footer);
-                       
-                               add_file(file);
+               construct {
+                       add_file (program);
+               }
+
+               public void add_file_from_stream (File file, DataInputStream stream, string? start, string? 
end,
+                       string? header = null, string? footer = null) throws Error {
+                       var newfile = file.create (FileCreateFlags.NONE);
+                       var outstream = new DataOutputStream (newfile);
+                       string line;
+
+                       if (header != null)
+                               outstream.put_string (header + "\n");
+
+                       if (start != null)
+                               do {} while ((line = stream.read_line (null)) != start);
+
+                       while ((line = stream.read_line (null)) != end)
+                               outstream.put_string (line + "\n");
+
+                       if (footer != null)
+                               outstream.put_string (footer);
+
+                       add_file (file);
                }
        }
 
        public class DBusTest : TestProgram {
-               
                private Program server;
                private Program client;
-               
-               public DBusTest(string testname, string packages, DataInputStream stream) throws Error {
-                       base(testdir.get_child(testname + ".server"));
+
+               public DBusTest (string testname, string packages, DataInputStream stream) throws Error {
+                       Object (program : testdir.get_child (testname + ".server"));
+
                        var factory = TestsFactory.get_instance();
-                       var clientfile = testdir.get_child(testname + ".client.vala");
-                       var serverfile = testdir.get_child(testname + ".server.vala");
-                       add_file_from_stream(clientfile, stream, "Program: client", "Program: server");
-                       add_file_from_stream(serverfile, stream, null, null);
-                       client = factory.compiler.compile(testdir.get_child(testname + ".client"), 
clientfile, packages);
-                       server = factory.compiler.compile(testdir.get_child(testname + ".server"), 
serverfile, packages);
+                       var clientfile = testdir.get_child (testname + ".client.vala");
+                       var serverfile = testdir.get_child (testname + ".server.vala");
+                       add_file_from_stream (clientfile, stream, "Program: client", "Program: server");
+                       add_file_from_stream (serverfile, stream, null, null);
+                       client = factory.compiler.compile (testdir.get_child (testname + ".client"), 
clientfile, packages);
+                       server = factory.compiler.compile (testdir.get_child (testname + ".server"), 
serverfile, packages);
                }
-               
-               public override void run(string? command = null) throws Error {
-                       Bus.watch_name(
-                               BusType.SESSION,
-                               "org.example.Test",
-                               GLib.BusNameWatcherFlags.NONE,
-                               null,
-                               (c,n) => {
-                                       this.server.run(command);
-                               });
+
+               public override void run (string? command = null) throws Error {
+                       //FIXME run client
+                       Bus.watch_name (BusType.SESSION, "org.example.Test", GLib.BusNameWatcherFlags.NONE, 
null, (c,n) => {
+                               this.server.run (command);
+                       });
                }
-               
-               public override void cleanup() throws Error {
-                       server.cleanup();
-                       client.cleanup();
-                       base.cleanup();
+
+               public override void cleanup () throws Error {
+                       server.cleanup ();
+                       client.cleanup ();
+                       base.cleanup ();
                }
        }
-       
+
        public class InvalidCode : TestProgram {
-               
                private File source;
-               private ValaCompiler compiler = new ValaCompiler(valac);
+               private ValaCompiler compiler;
                private string packages;
                private Program testprogam;
-               
-               public InvalidCode(string testname, string packages, DataInputStream stream) throws Error {
-                       base(testdir.get_child(testname));
+
+               public InvalidCode (string testname, string packages, DataInputStream stream) throws Error {
+                       Object (program : testdir.get_child (testname));
                        this.packages = packages;
                        source = testdir.get_child(testname + ".vala");
-                       add_file_from_stream(source, stream, null, null);
+                       add_file_from_stream (source, stream, null, null);
+                       compiler = new ValaCompiler (valac);
                        compiler.callback = new_callback;
                }
-               
-               private void new_callback(bool err, string buffer) {
+
+               private static void new_callback (bool err, string buffer) {
                        if (!err)
-                               error(buffer);
+                               error (buffer);
                        else
                                stdout.printf ("%s", buffer);
                }
-               
-               public override void run(string? command = null) throws Error {
-                       testprogam = compiler.compile(program, source, packages);
+
+               public override void run (string? command = null) throws Error {
+                       testprogam = compiler.compile (program, source, packages);
                }
-               
+
                public override void cleanup() throws Error {
                        testprogam.cleanup();
                        base.cleanup();
                }
        }
-       
+
        public class GIRTestProgram : TestProgram {
                private const string GIRHEADER =
                """<?xml version="1.0"?>
@@ -293,51 +288,45 @@ internal class Vala.TestsFactory : Object {
                namespace Test {""";
 
                private string testname;
-               
                private File vapifile;
-               
-               public GIRTestProgram(string testname, string packages, DataInputStream stream) throws Error {
-                       base(testdir.get_child(testname + ".gir"));
+
+               public GIRTestProgram (string testname, string packages, DataInputStream stream) throws Error 
{
+                       Object (program : testdir.get_child(testname + ".gir"));
                        this.testname = testname;
-                       add_file_from_stream(program, stream, "Input:", "Output:", GIRHEADER, GIRFOOTER);
-                       vapifile = testdir.get_child(testname + ".vapi.ref");
-                       add_file_from_stream(vapifile, stream, null, null, VAPIHEADER.printf(testname), 
"\n}\n");
+                       add_file_from_stream (program, stream, "Input:", "Output:", GIRHEADER, GIRFOOTER);
+                       vapifile = testdir.get_child (testname + ".vapi.ref");
+                       add_file_from_stream (vapifile, stream, null, null, VAPIHEADER.printf(testname), 
"\n}\n");
                }
-               
-               public override void run(string? command = null) throws Error {
-                       var vgen = new VapiGen();
-                       var vapi = vgen.compile(testname, program);
-                       add_file(vapi);
-                       var diff = new Diff();
-                       diff.run("-Bw %s %s".printf(vapi.get_path(), vapifile.get_path()));
+
+               public override void run (string? command = null) throws Error {
+                       var vgen = new VapiGen ();
+                       var vapi = vgen.compile (testname, program);
+                       add_file (vapi);
+                       var diff = new Diff ();
+                       diff.run ("-Bw %s %s".printf (vapi.get_path (), vapifile.get_path ()));
                }
        }
-       
-       public class Diff : Program {
 
+       public class Diff : Program {
                public Diff() {
-                       base(File.new_for_path(Environment.find_program_in_path ("diff")));
+                       Object (program : File.new_for_path(Environment.find_program_in_path ("diff")));
                }
        }
-       
-       public class VapiGen : Program {
 
-               public VapiGen() {
-                       base(buildir.get_child("vapigen").get_child("vapigen"));
+       public class VapiGen : Program {
+               public VapiGen () {
+                       Object (program : buildir.get_child ("vapigen").get_child ("vapigen"));
                }
-               
-               public File compile(string testname, File girfile) throws Error {
-                       string command = "--vapidir %s --library %s %s".printf(
-                               vapidir.get_path(),
-                               testname,
-                               girfile.get_path());
-                       run(command);
-                       return testdir.get_child(testname + ".vapi");
+
+               public File compile (string testname, File girfile) throws Error {
+                       string command = "--vapidir %s --library %s %s".printf (
+                               vapidir.get_path (), testname, girfile.get_path ());
+                       run (command);
+                       return testdir.get_child (testname + ".vapi");
                }
        }
-       
+
        public class ValaCompiler : Program {
-               
                private const string VALA_FLAGS =
                        """--save-temps --disable-warnings --pkg gio-2.0 
                          -X -lm -X -g -X -O0 -X -pipe
@@ -349,17 +338,20 @@ internal class Vala.TestsFactory : Object {
                          -X -Wformat -X -Werror=format-security -X -Werror=format-nonliteral
                          -X -Werror=redundant-decls""";
 
-               public ValaCompiler(File compiler) {
-                       base(compiler);
+               public ValaCompiler (File compiler) {
+                       Object (program : compiler);
                }
-               
-               public Program compile(File binary, File sourcefile, string? parameters = null) throws Error {
-                       string command = "--vapidir %s %s %s -o %s %s".printf(
-                               vapidir.get_path(), VALA_FLAGS, parameters ?? "", binary.get_path(), 
sourcefile.get_path());
-                       run(command);
-                       var prog = new TestProgram(binary);
-                       prog.add_file(binary.get_parent().get_child(binary.get_basename() + ".c"));
+
+               public Program compile (File binary, File sourcefile, string? parameters = null) throws Error 
{
+                       if (binary.query_exists ())
+                               throw new IOError.EXISTS ("binary `%s' already exists", binary.get_path ());
+
+                       string command = "--vapidir %s %s %s -o %s %s".printf (
+                               vapidir.get_path (), VALA_FLAGS, parameters ?? "", binary.get_path (), 
sourcefile.get_path ());
+                       run (command);
+                       var prog = new TestProgram (binary);
+                       prog.add_file (binary.get_parent().get_child (binary.get_basename () + ".c"));
                        return prog;
-               }       
+               }
        }
 }
diff --git a/valadate/module.vala b/valadate/module.vala
index 80934c4..1cf32c8 100644
--- a/valadate/module.vala
+++ b/valadate/module.vala
@@ -30,30 +30,29 @@ public errordomain Valadate.ModuleError {
  * Represents a loadable module containing {@link Valadate.Test}s
  */
 public class Valadate.Module : Object {
-       
+
        private string lib_path;
        private GLib.Module module;
 
-
        public Module (string libpath) {
                lib_path = libpath;
-       } 
-       
-       public void load_module() throws ModuleError {
-               if (!File.new_for_path(lib_path).query_exists())
-                       throw new ModuleError.NOT_FOUND("Module: %s does not exist", lib_path);
+       }
+
+       public void load_module () throws ModuleError {
+               if (!File.new_for_path (lib_path).query_exists ())
+                       throw new ModuleError.NOT_FOUND ("Module: %s does not exist", lib_path);
                
                module = GLib.Module.open (lib_path, ModuleFlags.BIND_LOCAL);
                if (module == null)
-                       throw new ModuleError.LOAD(GLib.Module.error());
-               module.make_resident();
+                       throw new ModuleError.LOAD (GLib.Module.error ());
+               module.make_resident ();
        }
-       
-       internal void* get_method(string method_name) throws ModuleError {
+
+       internal void* get_method (string method_name) throws ModuleError {
                void* function;
-               if(module.symbol (method_name, out function))
+               if (module.symbol (method_name, out function))
                        if (function != null)
                                return function;
-               throw new ModuleError.METHOD(GLib.Module.error());
+               throw new ModuleError.METHOD (GLib.Module.error ());
        }
 }
diff --git a/valadate/test.vala b/valadate/test.vala
index f49e928..1789f7e 100644
--- a/valadate/test.vala
+++ b/valadate/test.vala
@@ -19,18 +19,12 @@
  * Authors:
  *     Chris Daley <chebizarro gmail com>
  */
+
 /**
  * The Test interface is implemented by TestCase and TestSuite.
  * It is the base interface for all runnable Tests.
  */
 public interface Valadate.Test : Object {
-               
-       /**
-        * Runs the Tests and collects the results in a TestResult 
-        *
-        * @param result the TestResult object used to store the results of the Test
-        */
-       public abstract void run (TestResult result);
 
        /**
         * The name of the test
@@ -40,11 +34,18 @@ public interface Valadate.Test : Object {
        /**
         * Returns the number of tests that will be run by this test
         */
-       public abstract int count {get;}
+       public abstract int count { get; }
+
+       /**
+        * Runs the Tests and collects the results in a TestResult
+        *
+        * @param result the TestResult object used to store the results of the Test
+        */
+       public abstract void run (TestResult result);
 
-       public abstract Test get_test(int index);
+       public abstract Test get_test (int index);
 
        public virtual TestIterator iterator() {
-               return new TestIterator(this);
+               return new TestIterator (this);
        }
 }
diff --git a/valadate/testcase.vala b/valadate/testcase.vala
index eecc5fc..aaef016 100644
--- a/valadate/testcase.vala
+++ b/valadate/testcase.vala
@@ -42,95 +42,96 @@ public abstract class Valadate.TestCase : Object, Test, TestFixture {
        public string name { get; set; }
 
        /**
-        * The public constructor takes an optional string parameter for the
-        * TestCase's name
-        */
-       public TestCase(string? name = null) {
-               this.name = name ?? this.get_type().name();
-       }
-
-       /**
         * Returns the number of {@link Valadate.Test}s that will be run by this TestCase
         */
        public int count {
                get {
                        int testcount = 0;
-                       _tests.foreach((t) => {
+                       tests.foreach ((t) => {
                                testcount += t.count;
                        });
                        return testcount;
                }
        }
 
-       public string bug_base {get;set;}
-       
+       public string bug_base { get; set; }
 
-       private List<Test> _tests = new List<Test>();
+       private List<Test> tests = new List<Test>();
 
-       public void add_test(string testname, owned TestMethod test) {
-               var adaptor = new TestAdaptor (testname, (owned)test, this);
-               _tests.append(adaptor);
+       /**
+        * The public constructor takes an optional string parameter for the
+        * TestCase's name
+        */
+       public TestCase (string? name = null) {
+               Object (name : name);
        }
 
-       
-       public virtual void run(TestResult result) { }
-
-       public Test get_test(int index) {
+       construct {
+               if (name == null)
+                       name = get_type ().name ();
+       }
 
-               return _tests.nth_data(index);
+       public void add_test (string testname, owned TestMethod test) {
+               var adaptor = new TestAdaptor (testname, (owned) test, this);
+               tests.append (adaptor);
+       }
 
+       public Test get_test (int index) {
+               return tests.nth_data (index);
        }
 
-       public void bug(string reference)
-               requires(bug_base != null)
+       public void bug (string reference)
+               requires (bug_base != null)
        {
-               stdout.printf("MSG: Bug Reference: %s%s",bug_base, reference);
-               stdout.flush();
+               stdout.printf ("MSG Bug Reference: %s%s", bug_base, reference);
+               stdout.flush ();
        }
 
-       public void skip(string message) {
-               stderr.printf("SKIP %s", message);
-               stdout.flush();
+       public void skip (string message) {
+               stderr.printf ("SKIP %s", message);
+               stdout.flush ();
        }
 
-       public void fail(string? message = null) {
-               error("FAIL %s", message ?? "");
+       public void fail (string? message = null) {
+               error ("FAIL %s", message ?? "");
        }
 
-       public virtual void set_up() {}
-
-       public virtual void tear_down() {}
+       public virtual void run (TestResult result) {
+       }
 
+       public virtual void set_up() {
+       }
 
-       private class TestAdaptor : Object, Test {
+       public virtual void tear_down() {
+       }
+}
 
-               private TestMethod test;
-               private unowned TestCase testcase;
+private class Valadate.TestAdaptor : Object, Test {
 
-               public string name {get;set;}
+       public string name { get; set; }
 
-               public int count {
-                       get {
-                               return 1;
-                       }
-               }
-               
-               public Test get_test(int index) {
-                       return this;
-               }
-               
-               public TestAdaptor(string name, owned TestMethod test, TestCase testcase) {
-                       this.test = (owned)test;
-                       this.name = name;
-                       this.testcase = testcase;
+       public int count {
+               get {
+                       return 1;
                }
+       }
 
-               public void run(TestResult result) {
-                       this.testcase.set_up();
-                       this.test();
-                       this.testcase.tear_down();
-               }
+       private TestMethod test;
+       private unowned TestCase testcase;
 
+       public TestAdaptor (string name, owned TestMethod test, TestCase testcase) {
+               this.test = (owned) test;
+               this.name = name;
+               this.testcase = testcase;
        }
 
+       public Test get_test (int index) {
+               return this;
+       }
+
+       public void run (TestResult result) {
+               this.testcase.set_up ();
+               this.test ();
+               this.testcase.tear_down ();
+       }
 }
diff --git a/valadate/testconfig.vala b/valadate/testconfig.vala
index 525e6ae..2b31b85 100644
--- a/valadate/testconfig.vala
+++ b/valadate/testconfig.vala
@@ -19,12 +19,18 @@
  * Authors:
  *     Chris Daley <chebizarro gmail com>
  */
+
 namespace Valadate {
-       public static string? get_current_test_path() {
+       public static string? get_current_test_path () {
                return TestConfig._runtest;
        }
 }
 
+public errordomain Valadate.ConfigError {
+       MODULE,
+       TESTPLAN
+}
+
 public class Valadate.TestConfig : Object {
 
        private static string _seed;
@@ -140,10 +146,4 @@ public class Valadate.TestConfig : Object {
                var testexplorer = new TestExplorer(binary, root);
                testexplorer.load();
        }
-
-}
-
-public errordomain Valadate.ConfigError {
-       MODULE,
-       TESTPLAN
 }
diff --git a/valadate/testexplorer.vala b/valadate/testexplorer.vala
index d812340..97a72f2 100644
--- a/valadate/testexplorer.vala
+++ b/valadate/testexplorer.vala
@@ -15,58 +15,58 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- * 
+ *
  * Authors:
  *     Chris Daley <chebizarro gmail com>
  */
- 
+
 internal class Valadate.TestExplorer : Vala.CodeVisitor {
 
-       internal delegate void* Constructor(); 
-       internal delegate void TestMethod(TestCase self);
+       internal delegate void* Constructor ();
+       internal delegate void TestMethod (TestCase self);
 
        private TestSuite current;
        private Vala.CodeContext context;
        private Module module;
        private string binary;
        private string? running;
-       
-       public TestExplorer(string binary, TestSuite root) {
+
+       public TestExplorer (string binary, TestSuite root) {
                this.binary = binary;
                this.current = root;
-               this.running = Valadate.get_current_test_path();
+               this.running = Valadate.get_current_test_path ();
        }
 
-       public void load() throws ConfigError {
-               string testdir = Path.get_dirname(binary).replace(".libs", "");
-               
-               string testplan = Path.get_basename(binary);
-               if(testplan.has_prefix("lt-"))
-                       testplan = testplan.substring(3);
-               
+       public void load () throws ConfigError {
+               string testdir = Path.get_dirname (binary).replace (".libs", "");
+
+               string testplan = Path.get_basename (binary);
+               if (testplan.has_prefix ("lt-"))
+                       testplan = testplan.substring (3);
+
                string testplanfile = testdir + GLib.Path.DIR_SEPARATOR_S + testplan + ".vapi";
                
                if (!FileUtils.test (testplanfile, FileTest.EXISTS))
-                       throw new ConfigError.TESTPLAN("Test Plan %s Not Found!", testplanfile);
-               
+                       throw new ConfigError.TESTPLAN ("Test Plan %s Not Found!", testplanfile);
+
                try {
-                       module = new Module(binary);
-                       module.load_module();
-                       load_test_plan(testplanfile);
+                       module = new Module (binary);
+                       module.load_module ();
+                       load_test_plan (testplanfile);
                } catch (ModuleError e) {
-                       throw new ConfigError.MODULE(e.message);
+                       throw new ConfigError.MODULE (e.message);
                }
        }
 
-       internal void load_test_plan(string path) throws ConfigError {
-               setup_context();
+       internal void load_test_plan (string path) throws ConfigError {
+               setup_context ();
                context.add_source_file (new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, path));
                var parser = new Vala.Parser ();
                parser.parse (context);
-               context.accept(this);
+               context.accept (this);
        }
        
-       private void setup_context() {
+       private void setup_context () {
                context = new Vala.CodeContext ();
                Vala.CodeContext.push (context);
                context.report.enable_warnings = false;
@@ -74,57 +74,54 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
                context.verbose_mode = false;
        }
 
-       public override void visit_class(Vala.Class class) {
-               
+       public override void visit_class (Vala.Class class) {
                try {
-                       if (is_subtype_of(class, "Valadate.TestCase") &&
+                       if (is_subtype_of (class, "Valadate.TestCase") &&
                                class.is_abstract != true)
-                               current.add_test(visit_testcase(class));
-                       
-                       else if (is_subtype_of(class, "Valadate.TestSuite") &&
-                               class.is_abstract != true)                      
-                               current.add_test(visit_testsuite(class));
+                               current.add_test (visit_testcase (class));
+                       else if (is_subtype_of (class, "Valadate.TestSuite") &&
+                               class.is_abstract != true)
+                               current.add_test (visit_testsuite (class));
 
                } catch (ModuleError e) {
-                       error(e.message);
+                       error (e.message);
                }
-               class.accept_children(this);
+               class.accept_children (this);
        }
 
-       private bool is_subtype_of(Vala.Class class, string typename) {
-               foreach(var basetype in class.get_base_types())
-                       if(((Vala.UnresolvedType)basetype).to_qualified_string() == typename)
+       private bool is_subtype_of (Vala.Class class, string typename) {
+               foreach (var basetype in class.get_base_types ())
+                       if (((Vala.UnresolvedType)basetype).to_qualified_string () == typename)
                                return true;
                return false;
        }
 
-       private unowned Constructor get_constructor(Vala.Class class) throws ModuleError {
+       private unowned Constructor get_constructor (Vala.Class class) throws ModuleError {
                var attr = new Vala.CCodeAttribute (class.default_construction_method);
-               return (Constructor)module.get_method(attr.name);
+               return (Constructor)module.get_method (attr.name);
        }
 
-       public TestCase visit_testcase(Vala.Class testclass) throws ModuleError {
-               
-               unowned Constructor meth = get_constructor(testclass); 
-               var current_test = meth() as TestCase;          
+       public TestCase visit_testcase (Vala.Class testclass) throws ModuleError {
+               unowned Constructor meth = get_constructor(testclass);
+               var current_test = meth () as TestCase;
                current_test.name = testclass.name;
                
-               foreach(var method in testclass.get_methods()) {
-                       if( method.name.has_prefix("test_") &&
+               foreach (var method in testclass.get_methods ()) {
+                       if (method.name.has_prefix ("test_") &&
                                method.has_result != true &&
-                               method.get_parameters().size == 0) {
+                               method.get_parameters ().size == 0) {
 
                                if (running != null &&
-                                       running != "/" + method.get_full_name().replace(".","/"))
+                                       running != "/" + method.get_full_name ().replace (".","/"))
                                        continue;
 
                                unowned TestMethod testmethod = null;
-                               var attr = new Vala.CCodeAttribute(method);
-                               testmethod = (TestMethod)module.get_method(attr.name);
+                               var attr = new Vala.CCodeAttribute (method);
+                               testmethod = (TestMethod)module.get_method (attr.name);
 
                                if (testmethod != null) {
-                                       current_test.add_test(method.name, ()=> {
-                                               testmethod(current_test);
+                                       current_test.add_test (method.name, ()=> {
+                                               testmethod (current_test);
                                        });
                                }
                        }
@@ -132,20 +129,19 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
                return current_test;
        }
 
-       public TestSuite visit_testsuite(Vala.Class testclass) throws ModuleError {
-               unowned Constructor meth = get_constructor(testclass); 
-               var current_test = meth() as TestSuite;
+       public TestSuite visit_testsuite (Vala.Class testclass) throws ModuleError {
+               unowned Constructor meth = get_constructor (testclass);
+               var current_test = meth () as TestSuite;
                current_test.name = testclass.name;
                return current_test;
        }
 
-       public override void visit_namespace(Vala.Namespace ns) {
-
+       public override void visit_namespace (Vala.Namespace ns) {
                if (ns.name != null) {
-                       var testsuite = new TestSuite(ns.name);
-                       current.add_test(testsuite);
+                       var testsuite = new TestSuite (ns.name);
+                       current.add_test (testsuite);
                        current = testsuite;
                }
-               ns.accept_children(this);
+               ns.accept_children (this);
        }
 }
diff --git a/valadate/testfixture.vala b/valadate/testfixture.vala
index 29b75ae..bdeb2a4 100644
--- a/valadate/testfixture.vala
+++ b/valadate/testfixture.vala
@@ -25,5 +25,4 @@ public interface Valadate.TestFixture : Object {
        public abstract void set_up ();
 
        public abstract void tear_down ();
-
 }
diff --git a/valadate/testiterator.vala b/valadate/testiterator.vala
index 4f4ef4a..54073eb 100644
--- a/valadate/testiterator.vala
+++ b/valadate/testiterator.vala
@@ -19,6 +19,7 @@
  * Authors:
  *     Chris Daley <chebizarro gmail com>
  */
+
 /**
  * The Test iterator
  */
diff --git a/valadate/testresult.vala b/valadate/testresult.vala
index 0795ce1..e95b703 100644
--- a/valadate/testresult.vala
+++ b/valadate/testresult.vala
@@ -19,6 +19,7 @@
  * Authors:
  *     Chris Daley <chebizarro gmail com>
  */
+
 public class Valadate.TestResult : Object {
 
        private enum TestStatus {
@@ -29,20 +30,20 @@ public class Valadate.TestResult : Object {
                ERROR,
                FAILED
        }
-       
+
        private class TestReport {
 
-               public signal void report(TestStatus status);
-               
-               public Test test {get;set;}
-               
-               public TestStatus status {get;set;}
-               
-               public int index {get;set;}
-               
-               public string message {get;set;}
-               
-               public TestReport(Test test, TestStatus status, int index, string? message = null) {
+               public signal void report (TestStatus status);
+
+               public Test test { get; set; }
+
+               public TestStatus status { get; set; }
+
+               public int index { get; set; }
+
+               public string message { get; set; }
+
+               public TestReport (Test test, TestStatus status, int index, string? message = null) {
                        this.test = test;
                        this.status = status;
                        this.index = index;
@@ -50,134 +51,133 @@ public class Valadate.TestResult : Object {
                }
        }
 
-       private Queue<TestReport> reports = new Queue<TestReport>();
-       private HashTable<Test, TestReport> tests = new HashTable<Test, TestReport>(direct_hash, 
direct_equal);
+       private Queue<TestReport> reports = new Queue<TestReport> ();
+       private HashTable<Test, TestReport> tests = new HashTable<Test, TestReport> (direct_hash, 
direct_equal);
        
        private TestConfig config;
-       private TestRunner runner;
        private MainLoop loop;
 
-       public int testcount {get;private set;default=0;}
-
-       public TestResult(TestConfig config) {
+       public TestResult (TestConfig config) {
                this.config = config;
        }
        
-       public void report() {
+       public void report () {
 
-               if (reports.is_empty()) {
-                       loop.quit();
+               if (reports.is_empty ()) {
+                       loop.quit ();
                        return;
                }
                
-               var rpt = reports.peek_head();
+               var rpt = reports.peek_head ();
 
                if (rpt.status == TestStatus.PASSED ||
                        rpt.status == TestStatus.SKIPPED ||
                        rpt.status == TestStatus.FAILED ||
                        rpt.status == TestStatus.ERROR) {
                        if (rpt.message != null)
-                               stdout.puts(rpt.message);
-                       stdout.flush();
-                       rpt.report(rpt.status);
-                       reports.pop_head();
-                       report();
+                               stdout.puts (rpt.message);
+                       stdout.flush ();
+                       rpt.report (rpt.status);
+                       reports.pop_head ();
+                       report ();
                }
        }
        
-       public void add_error(Test test, string error) {
-               update_test(test, TestStatus.ERROR,"# %s\nnot ok %s %s\n".printf(error, "%d", test.name));
+       public void add_error (Test test, string error) {
+               update_test (test, TestStatus.ERROR, "# %s\nnot ok %s %s\n".printf (error, "%d", test.name));
        }
 
-       public void add_failure(Test test, string failure) {
-               update_test(test, TestStatus.FAILED,"# %s\nnot ok %s %s\n".printf(failure, "%d", test.name));
+       public void add_failure (Test test, string failure) {
+               update_test (test, TestStatus.FAILED, "# %s\nnot ok %s %s\n".printf (failure, "%d", 
test.name));
        }
 
-       public void add_success(Test test, string message) {
-               update_test(test, TestStatus.PASSED,"# %s\nok %s %s\n".printf(message, "%d", test.name));
+       public void add_success (Test test, string message) {
+               update_test (test, TestStatus.PASSED, "# %s\nok %s %s\n".printf (message, "%d", test.name));
        }
        
-       public void add_skip(Test test, string reason, string message) {
-               update_test(test, TestStatus.SKIPPED,"# %s\nok %s %s # %s\n".printf(message, "%d", test.name, 
reason));
+       public void add_skip (Test test, string reason, string message) {
+               update_test (test, TestStatus.SKIPPED, "# %s\nok %s %s # %s\n".printf (message, "%d", 
test.name, reason));
        }
 
-       private void update_test(Test test, TestStatus status, string message) {
-               var rept = tests.get(test);
+       private void update_test (Test test, TestStatus status, string message) {
+               var rept = tests.get (test);
                rept.status = status;
-               rept.message = message.printf(rept.index);
+               rept.message = message.printf (rept.index);
        }
-       
+
        /**
         * Runs a the {@link Valadate.Test}s using the supplied
         * {@link Valadate.TestRunner}.
-        * 
+        *
         * @param runner
         */
-       public void run(TestRunner runner) {
-
-               this.runner = runner;
+       public void run (TestRunner runner) {
 
-               count_tests(config.root);
+               var testcount = count_tests (config.root);
 
                if (!config.list_only && config.runtest == null) {
-                       stdout.printf("# random seed: %s\n", config.seed);
-                       stdout.printf("1..%d\n", testcount);
+                       stdout.printf ("# random seed: %s\n", config.seed);
+                       stdout.printf ("1..%d\n", testcount);
                }
 
-               run_test(config.root, "");
+               run_test (runner, config.root, "");
 
                if (config.runtest == null) {
-                       loop = new MainLoop();
+                       loop = new MainLoop ();
                        var time = new TimeoutSource (15);
                        time.set_callback (() => {
-                               report();
+                               report ();
                                return true;
                        });
                        time.attach (loop.get_context ());
-                       loop.run();
+                       loop.run ();
                }
        }
 
-       private void count_tests(Test test) {
-               if(test is TestSuite)
-                       foreach(var subtest in test)
-                               count_tests(subtest);
+       private int count_tests (Test test) {
+               var testcount = 0;
+
+               if (test is TestSuite)
+                       foreach (var subtest in test)
+                               testcount += count_tests (subtest);
                else
                        testcount += test.count;
+
+               return testcount;
        }
 
        private int testno = 0;
 
-       private void run_test(Test test, string path) {
-               foreach(var subtest in test) {
-                       string testpath = "%s/%s".printf(path, subtest.name);
-                       if(subtest is TestCase) {
-                               if(config.runtest == null && !config.list_only) {
-                                       reports.push_tail(new TestReport(subtest, TestStatus.PASSED,-1,"# 
Start of %s tests\n".printf(testpath)));
-                                       run_test(subtest, testpath);
-                                       reports.push_tail(new TestReport(subtest, TestStatus.PASSED,-1,"# End 
of %s tests\n".printf(testpath)));
+       private void run_test (TestRunner runner, Test test, string path) {
+               foreach (var subtest in test) {
+                       string testpath = "%s/%s".printf (path, subtest.name);
+                       if (subtest is TestCase) {
+                               if (config.runtest == null && !config.list_only) {
+                                       reports.push_tail (new TestReport (subtest, TestStatus.PASSED, -1, "# 
Start of %s tests\n".printf (testpath)));
+                                       run_test (runner, subtest, testpath);
+                                       reports.push_tail (new TestReport (subtest, TestStatus.PASSED, -1, "# 
End of %s tests\n".printf (testpath)));
                                } else {
-                                       run_test(subtest, testpath);
+                                       run_test (runner, subtest, testpath);
                                }
                        } else if (subtest is TestSuite) {
-                               run_test(subtest, testpath);
-                               if(config.runtest == null) {
-                                       var rpt = new TestReport(subtest, TestStatus.PASSED,-1);
-                                       rpt.report.connect((s)=> ((TestSuite)subtest).tear_down());
-                                       reports.push_tail(rpt);
+                               run_test (runner, subtest, testpath);
+                               if (config.runtest == null) {
+                                       var rpt = new TestReport (subtest, TestStatus.PASSED, -1);
+                                       rpt.report.connect ((s)=> ((TestSuite)subtest).tear_down ());
+                                       reports.push_tail (rpt);
                                }
                        } else if (config.list_only) {
-                               stdout.printf("%s\n", testpath);
+                               stdout.printf ("%s\n", testpath);
                        } else if (config.runtest != null) {
-                               if(config.runtest == testpath)
-                                       runner.run_test(subtest, this);
+                               if (config.runtest == testpath)
+                                       runner.run_test (subtest, this);
                        } else {
                                testno++;
                                subtest.name = testpath;
-                               var rept = new TestReport(subtest, TestStatus.RUNNING, testno);
-                               reports.push_tail(rept);
-                               tests.insert(subtest, rept);
-                               runner.run.begin(subtest, this);
+                               var rept = new TestReport (subtest, TestStatus.RUNNING, testno);
+                               reports.push_tail (rept);
+                               tests.insert (subtest, rept);
+                               runner.run.begin (subtest, this);
                        }
                }
        }
diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
index 6d7d78b..205966b 100644
--- a/valadate/testrunner.vala
+++ b/valadate/testrunner.vala
@@ -26,18 +26,18 @@ public class Valadate.TestRunner : Object {
        private Queue<DelegateWrapper> _pending_tests = new Queue<DelegateWrapper> ();
 
        /* Change this to change the cap on the number of concurrent operations. */
-       private const uint _max_n_ongoing_tests = 15;
+       private static uint _max_n_ongoing_tests = GLib.get_num_processors ();
 
        private class DelegateWrapper {
                public SourceFunc cb;
        }
 
        private SubprocessLauncher launcher =
-               new SubprocessLauncher(GLib.SubprocessFlags.STDOUT_PIPE | GLib.SubprocessFlags.STDERR_MERGE);
+               new SubprocessLauncher (GLib.SubprocessFlags.STDOUT_PIPE | GLib.SubprocessFlags.STDERR_MERGE);
 
        private string binary;
        
-       public TestRunner(string binary) {
+       public TestRunner (string binary) {
                this.binary = binary;
                this.launcher.setenv("G_MESSAGES_DEBUG","all", true);
                this.launcher.setenv("G_DEBUG","fatal-criticals fatal-warnings gc-friendly", true);
@@ -70,11 +70,11 @@ public class Valadate.TestRunner : Object {
                }
        }
 
-       public void run_test(Test test, TestResult result) {
-               test.run(result);
+       public void run_test (Test test, TestResult result) {
+               test.run (result);
        }
 
-       public async void run(Test test, TestResult result) {
+       public async void run (Test test, TestResult result) {
                
                string command = "%s -r %s".printf(binary, test.name);
                string[] args;
@@ -107,7 +107,7 @@ public class Valadate.TestRunner : Object {
                }
        }
 
-       public void process_buffer(Test test, TestResult result, string buffer, bool failed = false) {
+       public void process_buffer (Test test, TestResult result, string buffer, bool failed = false) {
                string skip = null;
                string[] message = {};
                
@@ -127,7 +127,6 @@ public class Valadate.TestRunner : Object {
        }
 
        public static int main (string[] args) {
-               
                var bin = args[0];
                var config = new TestConfig();
                int result = config.parse(args);
diff --git a/valadate/testsuite.vala b/valadate/testsuite.vala
index 94c19d3..ee75ea3 100644
--- a/valadate/testsuite.vala
+++ b/valadate/testsuite.vala
@@ -22,8 +22,6 @@
 
 public class Valadate.TestSuite : Object, Test {
 
-       private List<Test> _tests = new List<Test>();
-       
        /**
         * the name of the TestSuite
         */
@@ -35,7 +33,7 @@ public class Valadate.TestSuite : Object, Test {
         */
        public int count {
                get {
-                       return (int)_tests.length();
+                       return (int) _tests.length ();
                }
        }
 
@@ -43,36 +41,45 @@ public class Valadate.TestSuite : Object, Test {
         * Returns a {@link GLib.List} of {@link Valadate.Test}s that will be
         * run by this TestSuite
         */
-       public List<Test> tests {
+       public GLib.List<Test> tests {
                get {
                        return _tests;
                }
        }
 
+       private GLib.List<Test> _tests = new GLib.List<Test> ();
+
        /**
         * The public constructor takes an optional string parameter for the
         * TestSuite's name
         */
-       public TestSuite(string? name = null) {
-               this.name = name ?? this.get_type().name();
+       public TestSuite (string? name = null) {
+               Object (name : name);
+       }
+
+       construct {
+               if (name == null)
+                       name = get_type ().name ();
        }
 
        /**
         * Adds a test to the suite.
         */
-       public void add_test(Test test) {
-               _tests.append(test);
+       public void add_test (Test test) {
+               _tests.append (test);
        }
 
-       public void run(TestResult result) {
-               _tests.foreach((t) => { t.run(result); });
+       public void run (TestResult result) {
+               _tests.foreach ((t) => { t.run (result); });
        }
 
-       public Test get_test(int index) {
+       public Test get_test (int index) {
                return _tests.nth_data((uint)index);
        }
 
-       public virtual void set_up() {}
-       public virtual void tear_down() {}
-       
+       public virtual void set_up () {
+       }
+
+       public virtual void tear_down () {
+       }
 }


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