[vala/wip/valadate: 96/101] merged TestConfig and TestOptions
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/valadate: 96/101] merged TestConfig and TestOptions
- Date: Sat, 7 Oct 2017 10:58:03 +0000 (UTC)
commit c888b084b5197bb4395c6c81334b9be882c19251
Author: Chris Daley <chebizarro gmail com>
Date: Mon May 1 07:33:18 2017 -0700
merged TestConfig and TestOptions
tests/valadatetests.vala | 1 -
valadate/Makefile.am | 1 -
valadate/testassembly.vala | 14 +++---
valadate/testconfig.vala | 64 +++++++++++++++++++----
valadate/testoptions.vala | 122 --------------------------------------------
valadate/testplan.vala | 9 +--
6 files changed, 62 insertions(+), 149 deletions(-)
---
diff --git a/tests/valadatetests.vala b/tests/valadatetests.vala
index 1756601..5578b4a 100644
--- a/tests/valadatetests.vala
+++ b/tests/valadatetests.vala
@@ -33,7 +33,6 @@ public class Valadate.Tests.TestFixture : Valadate.TestCase {
}
public void test_testcase_2 () {
- message (TestOptions.get_current_test_path ());
skip ("No reason");
debug ("This is a second test of the system");
}
diff --git a/valadate/Makefile.am b/valadate/Makefile.am
index 6d0744a..fe5b764 100644
--- a/valadate/Makefile.am
+++ b/valadate/Makefile.am
@@ -33,7 +33,6 @@ libvaladate_la_VALASOURCES = \
testcase.vala \
testconfig.vala \
testmodule.vala \
- testoptions.vala \
testgatherer.vala \
testplan.vala \
testresult.vala \
diff --git a/valadate/testassembly.vala b/valadate/testassembly.vala
index 7985a80..13779cb 100644
--- a/valadate/testassembly.vala
+++ b/valadate/testassembly.vala
@@ -25,23 +25,23 @@ public class Valadate.TestAssembly : TestModule {
public File srcdir { get; private set; }
public File builddir { get; private set; }
- public TestOptions options { get; private set; }
+ public TestConfig config { get; private set; }
public TestAssembly (string[] args) throws Error {
base (File.new_for_path (args[0]));
- options = new TestOptions (args);
+ config = new TestConfig (args);
- if (options.testpath != null)
- Environment.set_variable ("V_TESTPATH", options.testpath, true);
- if (options.running_test != null)
- Environment.set_variable ("V_RUNNING_TEST", options.running_test, true);
+ if (config.testpath != null)
+ Environment.set_variable ("V_TESTPATH", config.testpath, true);
+ if (config.running_test != null)
+ Environment.set_variable ("V_RUNNING_TEST", config.running_test, true);
setup_dirs ();
}
private TestAssembly.copy (TestAssembly other) throws Error {
base (other.binary);
- options = other.options;
+ config = other.config;
}
private void setup_dirs () throws Error {
diff --git a/valadate/testconfig.vala b/valadate/testconfig.vala
index 34faa13..d6dcadc 100644
--- a/valadate/testconfig.vala
+++ b/valadate/testconfig.vala
@@ -35,63 +35,103 @@ public enum Valadate.TestFormat {
public class Valadate.TestConfig {
- public TestOptions options {get;set;}
+ private static string _format = "tap";
+ private static bool _keepgoing = false;
+ private static bool _list;
+ private static string _running_test = null;
+ private static int _timeout = 60000;
+ private static string _seed;
+ private static bool _timed = true;
+ private static bool _version;
+ private static string _path = null;
+
+ public const OptionEntry[] options = {
+ { "format", 'f', 0, OptionArg.STRING, ref _format, "Output test results using format",
"FORMAT" },
+ { "", 'k', 0, OptionArg.NONE, ref _keepgoing, "Skip failed tests and continue running", null
},
+ { "list", 'l', 0, OptionArg.NONE, ref _list, "List test cases available in a test
executable", null },
+ { "", 'r', 0, OptionArg.STRING, ref _running_test, null, null },
+ { "timeout", 't', 0, OptionArg.INT, ref _timeout, "Default timeout for tests", "MILLISECONDS"
},
+ { "seed", 0, 0, OptionArg.STRING, ref _seed, "Start tests with random seed", "SEEDSTRING" },
+ { "version", 0, 0, OptionArg.NONE, ref _version, "Display version number", null },
+ { "path", 'p', 0, OptionArg.STRING, ref _path, "Only start test cases matching",
"TESTPATH..." },
+ { null }
+ };
+
+ public OptionContext opt_context;
public virtual string format {
get {
- return options.format;
+ return _format;
}
}
public virtual string seed {
get {
- return options.seed;
+ return _seed;
}
}
public string? testpath {
get {
- return options.testpath;
+ return _path;
}
}
public string? running_test {
get {
- return options.running_test;
+ return _running_test;
}
}
public bool in_subprocess {
get {
- return options.running_test != null;
+ return _running_test != null;
}
}
public virtual bool list_only {
get {
- return options.list;
+ return _list;
}
}
public virtual bool keep_going {
get {
- return options.keepgoing;
+ return _keepgoing;
}
}
public virtual int timeout {
get {
- return options.timeout;
+ return _timeout;
}
}
public virtual bool timed {
get {
- return options.timed;
+ return _timed;
}
}
- public TestConfig (TestOptions options) {
- this.options = options;
+ public TestConfig (string[] args) {
+ _running_test = null;
+
+ try {
+ opt_context = new OptionContext ("- Valadate Testing Framework");
+ opt_context.set_help_enabled (true);
+ opt_context.add_main_entries (options, null);
+ opt_context.parse (ref args);
+
+ if (_seed == null)
+ _seed = "R02S%08x%08x%08x%08x".printf (
+ GLib.Random.next_int (),
+ GLib.Random.next_int (),
+ GLib.Random.next_int (),
+ GLib.Random.next_int ());
+
+ } catch (OptionError e) {
+ stdout.printf ("%s\n", e.message);
+ stdout.printf ("Run '%s --help' to see a full list of available command line
options.\n", args[0]);
+ }
}
}
diff --git a/valadate/testplan.vala b/valadate/testplan.vala
index dd28657..1f2e095 100644
--- a/valadate/testplan.vala
+++ b/valadate/testplan.vala
@@ -34,8 +34,6 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
public TestAssembly assembly { get; set; }
- public TestOptions options { get; set; }
-
public TestConfig config { get; set; }
public TestResult result { get; set; }
@@ -53,7 +51,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
public TestPlan (TestAssembly assembly) throws Error {
this.assembly = assembly;
- options = assembly.options;
+ config = assembly.config;
var plan_name = Path.get_basename (assembly.binary.get_path ());
if (plan_name.has_prefix ("lt-"))
@@ -65,7 +63,6 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
if (!plan.query_exists ())
throw new TestConfigError.TESTPLAN ("Test Plan %s Not Found in %s or %s",
plan_name, assembly.srcdir.get_path (), assembly.builddir.get_path ());
}
- config = new TestConfig (options);
runner = new TestRunner ();
result = new TestResult (config);
testsuite = root = new TestSuite ("/");
@@ -99,7 +96,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
if (ns.name != null) {
var currpath = "/" + ns.get_full_name ().replace (".","/");
if (config.in_subprocess)
- if (!options.running_test.has_prefix (currpath))
+ if (!config.running_test.has_prefix (currpath))
return;
if (currpath.last_index_of ("/") == 0)
@@ -181,7 +178,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
var currpath = "%s/%s".printf (testcase.label, method.name);
if (config.in_subprocess)
- if (options.running_test != currpath)
+ if (config.running_test != currpath)
continue;
if (!is_test (method))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]