[vala/wip/valadate: 65/101] more mods to runner



commit f43b2d72072a7111cf4f55f6be42beb2885ef7d7
Author: Chris Daley <chebizarro gmail com>
Date:   Tue Jul 26 02:33:22 2016 -0700

    more mods to runner

 tests/asynchronous/testcase.test |   11 -----------
 valadate/testconfig.vala         |   24 ++++++++++++++++++------
 valadate/testresult.vala         |   35 ++++++++++++++++++++++++++++-------
 valadate/testrunner.vala         |   16 ++++++++++++----
 4 files changed, 58 insertions(+), 28 deletions(-)
---
diff --git a/valadate/testconfig.vala b/valadate/testconfig.vala
index 06be074..11990df 100644
--- a/valadate/testconfig.vala
+++ b/valadate/testconfig.vala
@@ -24,7 +24,7 @@ public class Valadate.TestConfig : Object {
 
        private static string _seed;
        private static string testplan;
-       private static string runtest;
+       private static string _runtest;
        private static string format = "tap";
        private static bool fatal_warnings;
        private static bool list;
@@ -46,6 +46,18 @@ public class Valadate.TestConfig : Object {
                }
        }
 
+       public string runtest {
+               get {
+                       return _runtest;
+               }
+       }
+
+       public bool list_only {
+               get {
+                       return list;
+               }
+       }
+
        public string binary {get;set;}
 
        public TestSuite root {get;set;}
@@ -67,7 +79,7 @@ public class Valadate.TestConfig : Object {
                { "quiet", 'q', 0, OptionArg.NONE, ref quiet, "Run tests quietly", null },
                { "timed", 0, 0, OptionArg.NONE, ref timed, "Run timed tests", null },
                { "testplan", 0, 0, OptionArg.STRING, ref testplan, "Run the specified TestPlan", "FILE" },
-               { "", 'r', 0, OptionArg.STRING, ref runtest, null, null },
+               { "", 'r', 0, OptionArg.STRING, ref _runtest, null, null },
                { "verbose", 0, 0, OptionArg.NONE, ref verbose, "Run tests verbosely", null },
                { "version", 0, 0, OptionArg.NONE, ref version, "Display version number", null },
                { "vala-version", 0, 0, OptionArg.NONE, ref vala_version, "Display Vala version number", null 
},
@@ -80,8 +92,6 @@ public class Valadate.TestConfig : Object {
                opt_context = new OptionContext ("- Valadate Testing Framework");
                opt_context.set_help_enabled (true);
                opt_context.add_main_entries (options, null);
-               root = new TestSuite("/");
-               setup_context();
        }
 
        private void setup_context() {
@@ -95,7 +105,6 @@ public class Valadate.TestConfig : Object {
        public int parse(string[] args) {
                binary = args[0];
                GLib.Environment.set_prgname(binary);
-               //root.name = binary;
 
                try {
                        opt_context.parse (ref args);
@@ -120,6 +129,8 @@ public class Valadate.TestConfig : Object {
                                GLib.Random.next_int(),
                                GLib.Random.next_int());
                
+               root = new TestSuite("/");
+               
                try {
                        load();
                } catch (ConfigError e) {
@@ -153,7 +164,8 @@ public class Valadate.TestConfig : Object {
 
 
        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 ();
diff --git a/valadate/testresult.vala b/valadate/testresult.vala
index 80e22c0..f0e162d 100644
--- a/valadate/testresult.vala
+++ b/valadate/testresult.vala
@@ -51,7 +51,7 @@ public class Valadate.TestResult : Object {
                }
        }
        
-       private TestConfig config;
+       internal TestConfig config;
        private TestRunner runner;
        
        public TestResult(TestConfig config) {
@@ -90,19 +90,40 @@ public class Valadate.TestResult : Object {
 
        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) {
-                               stdout.printf("# Start of %s/%s tests\n", path, subtest.name);
+
+                               stdout.printf("# Start of %s tests\n", testpath);
                                
-                               run_test(subtest, "%s/%s".printf(path, subtest.name));
+                               run_test(subtest, testpath);
                                
-                               stdout.printf("# End of %s/%s tests\n", path, subtest.name);
+                               stdout.printf("# End of %s tests\n", testpath);
+
                        } else if (subtest is TestSuite) {
-                               run_test(subtest, "%s/%s".printf(path, subtest.name));
+
+                               run_test(subtest, testpath);
+
                        } else {
+
                                testno++;
-                               runner.run(subtest, this);
-                               stdout.printf("ok %d %s/%s\n", testno, path, subtest.name);
 
+                               if (config.list_only) {
+
+                                       stdout.printf("%s\n", testpath);
+
+                               } else if (config.runtest != null && config.runtest == testpath) {
+
+                                       runner.run(subtest, testpath, this);
+
+                                       stdout.printf("ok %d %s/%s\n", testno, path, subtest.name);
+
+                               } else {
+
+                                       runner.run_test(subtest, testpath, this);
+
+                                       stdout.printf("ok %d %s/%s\n", testno, path, subtest.name);
+
+                               }
                        }
                }
        }
diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
index 49ddc6e..04f279d 100644
--- a/valadate/testrunner.vala
+++ b/valadate/testrunner.vala
@@ -28,10 +28,15 @@ public class Valadate.TestRunner : Object {
                new SubprocessLauncher(GLib.SubprocessFlags.STDOUT_PIPE | GLib.SubprocessFlags.STDERR_PIPE);
        
        
-       public void run(Test test, TestResult result) {
+       public void run_test(Test test, string testpath, TestResult result) {
+
+               test.run(result);
+
+       }
+
+       public void run(Test test, string testpath, TestResult result) {
                
-               /*
-               string command = "%s -r ".printf(config.binary);
+               string command = "%s -r %s".printf(result.config.binary, testpath);
 
                string[] args;
                Shell.parse_argv(command, out args);
@@ -41,7 +46,10 @@ public class Valadate.TestRunner : Object {
 
                uint8 buffer[1028];
                var err = stderr_pipe.read(buffer);
-               */
+               
+               if (err > 0) {
+                       result.add_failure(test, (string)buffer);
+               }               
 
        }
 


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