[vala/wip/valadate: 714/749] result now uses testrunner to run tests
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/valadate: 714/749] result now uses testrunner to run tests
- Date: Tue, 22 Aug 2017 21:13:14 +0000 (UTC)
commit 8077be78995e31218c4a09d2d07407b1ac112b88
Author: Chris Daley <chebizarro gmail com>
Date: Mon Jul 25 10:16:29 2016 -0700
result now uses testrunner to run tests
valadate/testcase.vala | 2 +-
valadate/testresult.vala | 39 ++++++++++++++++++++++--
valadate/testrunner.vala | 73 +++++++++-------------------------------------
3 files changed, 50 insertions(+), 64 deletions(-)
---
diff --git a/valadate/testcase.vala b/valadate/testcase.vala
index 7f969fd..7a68e7c 100644
--- a/valadate/testcase.vala
+++ b/valadate/testcase.vala
@@ -72,7 +72,7 @@ public abstract class Valadate.TestCase : Object, Test, TestFixture {
public void run(TestResult result) {
- result.run(this);
+ //result.run(this);
}
diff --git a/valadate/testresult.vala b/valadate/testresult.vala
index ba077c7..80e22c0 100644
--- a/valadate/testresult.vala
+++ b/valadate/testresult.vala
@@ -51,6 +51,16 @@ public class Valadate.TestResult : Object {
}
}
+ private TestConfig config;
+ private TestRunner runner;
+
+ public TestResult(TestConfig config) {
+ this.config = config;
+
+
+
+ }
+
public void add_error(Test test, string error) {
errors.append(new TestFailure(test, error));
test_error(test, error);
@@ -69,12 +79,33 @@ public class Valadate.TestResult : Object {
/**
* Runs a {@link Valadate.Test}
*/
- public void run(Test test) {
+ public void run(TestRunner runner) {
+ this.runner = runner;
+ stdout.printf("# random seed: %s\n", config.seed);
+ stdout.printf("%d..%d\n", (config.test_count > 0) ? 1 : 0, config.test_count);
+ run_test(config.root, "");
+ }
- test_start(test);
+ private static int testno = 0;
- test.run(this);
+ private void run_test(Test test, string path) {
+ foreach(var subtest in test) {
+ if(subtest is TestCase) {
+ stdout.printf("# Start of %s/%s tests\n", path, subtest.name);
+
+ run_test(subtest, "%s/%s".printf(path, subtest.name));
+
+ stdout.printf("# End of %s/%s tests\n", path, subtest.name);
+ } else if (subtest is TestSuite) {
+ run_test(subtest, "%s/%s".printf(path, subtest.name));
+ } else {
+ testno++;
+ runner.run(subtest, this);
+ stdout.printf("ok %d %s/%s\n", testno, path, subtest.name);
- test_complete(test);
+ }
+ }
}
+
+
}
diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
index 97b6f4a..49ddc6e 100644
--- a/valadate/testrunner.vala
+++ b/valadate/testrunner.vala
@@ -22,72 +22,27 @@
public class Valadate.TestRunner : Object {
- private TestConfig config;
-
private TestResult result;
private SubprocessLauncher launcher =
new SubprocessLauncher(GLib.SubprocessFlags.STDOUT_PIPE | GLib.SubprocessFlags.STDERR_PIPE);
- public TestRunner(TestConfig config) {
- this.config = config;
- }
-
- public void run(TestResult result) {
-
- this.result = result;
+ public void run(Test test, TestResult result) {
/*
- if (TestConfig.runtest != null && config.root.count == 1) {
- config.root.run(result);
- return;
- }*/
-
- stdout.printf("# random seed: %s\n", config.seed);
- stdout.printf("%d..%d\n", (config.test_count > 0) ? 1 : 0, config.test_count);
-
- run_test(config.root, "");
-
- }
+ string command = "%s -r ".printf(config.binary);
- private static int testno = 0;
+ string[] args;
+ Shell.parse_argv(command, out args);
+
+ var process = launcher.spawnv(args);
+ var stderr_pipe = process.get_stderr_pipe();
+
+ uint8 buffer[1028];
+ var err = stderr_pipe.read(buffer);
+ */
- private void run_test(Test test, string path) {
-
-
-
-
- //if (test.count > 1) {
- //message(test.name);
-
- foreach(var subtest in test) {
- if(subtest is TestCase || subtest is TestSuite) {
- if(subtest is TestCase)
- stdout.printf("# Start of %s/%s tests\n", path, subtest.name);
- run_test(subtest, "%s/%s".printf(path, subtest.name));
- if(subtest is TestCase)
- stdout.printf("# End of %s/%s tests\n", path, subtest.name);
- } else {
- testno++;
- stdout.printf("ok %d %s/%s\n", testno, path, subtest.name);
- }
- }
- //} else {
- // message(test.name);
- // string command = "%s -r ".printf(config.binary);
-
- // string[] args;
- // Shell.parse_argv(command, out args);
-
- /*
- var process = launcher.spawnv(args);
- var stderr_pipe = process.get_stderr_pipe();
-
- uint8 buffer[1028];
- var err = stderr_pipe.read(buffer);
- */
- //}
}
@@ -99,10 +54,10 @@ public class Valadate.TestRunner : Object {
if(result >= 0)
return result;
- var runner = new TestRunner(config);
- var testresult = new TestResult();
+ var runner = new TestRunner();
+ var testresult = new TestResult(config);
- runner.run(testresult);
+ testresult.run(runner);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]