summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchebizarro@gmail.com <chebizarro@gmail.com>2017-04-27 02:01:25 -0700
committerRico Tzschichholz <ricotz@ubuntu.com>2017-11-19 12:35:04 +0100
commitfa18d8b28b247fb499acb4aa7ad3272dc576f56b (patch)
tree9350a27eed12124876580b9222c2007acce3073b
parente0dd2d7bdbbe7831e54430c5ecdda41550428724 (diff)
downloadvala-fa18d8b28b247fb499acb4aa7ad3272dc576f56b.tar.gz
ported tests to new Valadate version
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/valatests.vala15
-rw-r--r--valadate/Makefile.am12
-rw-r--r--valadate/testadapter.vala2
-rw-r--r--valadate/testconfig.vala6
-rw-r--r--valadate/testgatherer.vala2
-rw-r--r--valadate/testoptions.vala181
-rw-r--r--valadate/testplan.vala9
-rw-r--r--valadate/testrunner.vala3
-rw-r--r--valadate/valadate.deps.in3
10 files changed, 131 insertions, 109 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 978bc17bd..02cfcea6d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
include $(top_srcdir)/Makefile.common
include $(top_srcdir)/build-aux/glib-tap.mk
-test_programs = valadatetests #valactests@PACKAGE_SUFFIX@
+test_programs = valadatetests valactests@PACKAGE_SUFFIX@
# Valadate tests
valadatetests_VALAFLAGS = \
@@ -49,8 +49,8 @@ valadatetests_CFLAGS = \
valactests@PACKAGE_SUFFIX@_VALAFLAGS = \
--vapidir $(top_srcdir)/valadate \
--vapidir $(top_srcdir)/vapi \
+ --vapidir $(top_srcdir)/gee \
--pkg valadate \
- --pkg gio-2.0 \
--pkg config \
--library valactests@PACKAGE_SUFFIX@ \
-g \
@@ -72,6 +72,7 @@ valactests@PACKAGE_SUFFIX@_LDADD = \
valactests@PACKAGE_SUFFIX@_CPPFLAGS = \
-I$(top_srcdir)/valadate \
-I$(top_srcdir)/vala \
+ -I$(top_srcdir)/gee \
$(GLIB_CPPFLAGS) \
$(GIO_CFLAGS) \
$(GMODULE_CPPFLAGS) \
@@ -90,6 +91,8 @@ valactests@PACKAGE_SUFFIX@_CFLAGS = \
CLEANFILES += \
*.gir \
*.stamp \
+ *.log \
+ *.trs \
$(valadatetests_SOURCES:.vala=.c) \
$(valactests@PACKAGE_SUFFIX@_SOURCES:.vala=.c) \
*.vapi \
diff --git a/tests/valatests.vala b/tests/valatests.vala
index 22322ab77..0fec7fa1c 100644
--- a/tests/valatests.vala
+++ b/tests/valatests.vala
@@ -24,7 +24,7 @@ public class Vala.Tests : Valadate.TestSuite {
construct {
try {
var testdir = File.new_for_path (GLib.Environment.get_current_dir ());
- var testpath = Valadate.get_current_test_path ();
+ var testpath = Valadate.TestOptions.get_current_test_path ();
if (testpath != null) {
var testpaths = testpath.split ("/");
@@ -56,9 +56,10 @@ public class Vala.Tests : Valadate.TestSuite {
public ValaTest (File directory) throws Error {
this.name = directory.get_basename ();
+ this.label = directory.get_path ();
this.bug_base = BUGZILLA_URL;
- string current_test = Valadate.get_current_test_path ();
+ string current_test = Valadate.TestOptions.get_current_test_path();
if (current_test != null) {
var basename = Path.get_basename (current_test);
@@ -82,7 +83,13 @@ public class Vala.Tests : Valadate.TestSuite {
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, () => {
+
+ var adapter = new Valadate.TestAdapter(testname, 1000);
+ adapter.label = "/Vala/Tests/%s/%s".printf(
+ Path.get_basename(testfile.get_parent().get_path()),
+ testname);
+
+ adapter.add_test_method(() => {
try {
if (testname.has_prefix ("bug"))
bug (testname.substring(3));
@@ -93,6 +100,8 @@ public class Vala.Tests : Valadate.TestSuite {
fail (e.message);
}
});
+
+ add_test(adapter);
}
}
}
diff --git a/valadate/Makefile.am b/valadate/Makefile.am
index 2a73a4aef..6f4e94801 100644
--- a/valadate/Makefile.am
+++ b/valadate/Makefile.am
@@ -15,7 +15,7 @@ AM_CPPFLAGS = \
-g \
$(NULL)
-BUILT_SOURCES = valadate.vala.stamp
+BUILT_SOURCES = valadate.vala.stamp valadate.deps
lib_LTLIBRARIES = \
libvaladate.la \
@@ -67,6 +67,9 @@ valadate.vapi valadate.vala.stamp: $(libvaladate_la_VALASOURCES)
$^
@touch $@
+valadate.deps : valadate.deps.in
+ $(SED) -e 's,[@]PACKAGE_SUFFIX[@],$(PACKAGE_SUFFIX),g' < valadate.deps.in > valadate.deps
+
libvaladate_la_LDFLAGS = -no-undefined
libvaladate_la_LIBADD = \
@@ -78,10 +81,15 @@ libvaladate_la_LIBADD = \
$(LIBXML_LIBS) \
$(NULL)
-EXTRA_DIST = $(libvaladate_la_VALASOURCES) valadate.vapi valadate.vala.stamp
+EXTRA_DIST = \
+ $(libvaladate_la_VALASOURCES) \
+ valadate.vapi \
+ valadate.deps.in \
+ valadate.vala.stamp
MAINTAINERCLEANFILES = \
valadate.vapi \
+ valadate.deps \
valadate.h \
$(libvaladate_la_SOURCES:.vala=.c) \
$(NULL)
diff --git a/valadate/testadapter.vala b/valadate/testadapter.vala
index 195d1a27a..930830810 100644
--- a/valadate/testadapter.vala
+++ b/valadate/testadapter.vala
@@ -20,7 +20,7 @@
* Chris Daley <chebizarro@gmail.com>
*/
-private class Valadate.TestAdapter : Object, Test {
+public class Valadate.TestAdapter : Object, Test {
public string name {get;set;}
public string label {get;set;}
diff --git a/valadate/testconfig.vala b/valadate/testconfig.vala
index 0c772a41a..6ed1d35f6 100644
--- a/valadate/testconfig.vala
+++ b/valadate/testconfig.vala
@@ -27,9 +27,9 @@ public errordomain Valadate.TestConfigError {
TEST_PRINTER
}
-public class Valadate.TestConfig : Object {
+public class Valadate.TestConfig {
- public TestOptions options {get;construct set;}
+ public TestOptions options {get;set;}
public virtual string format {
get {
@@ -86,6 +86,6 @@ public class Valadate.TestConfig : Object {
}
public TestConfig(TestOptions options) {
- Object(options : options);
+ this.options = options;
}
}
diff --git a/valadate/testgatherer.vala b/valadate/testgatherer.vala
index 3d139346f..a9049f30e 100644
--- a/valadate/testgatherer.vala
+++ b/valadate/testgatherer.vala
@@ -38,7 +38,7 @@ public class Valadate.TestGatherer : Vala.CodeVisitor {
public override void visit_class(Vala.Class cls) {
try {
var classtype = find_type(cls);
- if (classtype.is_a(typeof(TestCase)))
+ if (classtype.is_a(typeof(TestCase)) || classtype.is_a(typeof(TestSuite)))
classes.insert(classtype, cls);
} catch (Error e) {
warning(e.message);
diff --git a/valadate/testoptions.vala b/valadate/testoptions.vala
index 39e8abe03..c627c69b1 100644
--- a/valadate/testoptions.vala
+++ b/valadate/testoptions.vala
@@ -19,117 +19,114 @@
* Authors:
* Chris Daley <chebizarro@gmail.com>
*/
-namespace Valadate {
-
- public class TestOptions {
-
- private static bool _async = true;
- private static bool _tap;
- private static string _format = "tap";
- private static bool _keepgoing = false;
- private static bool _list;
- private static bool _quiet;
- private static string _runtest = null;
- [CCode (array_length = false, array_null_terminated = true)]
- private static string[] _skip;
- private static int _timeout = 60000;
- private static string _seed;
- private static bool _timed = true;
- private static string _testplan;
- private static bool _verbose;
- private static bool _version;
- [CCode (array_length = false, array_null_terminated = true)]
- private static string[] _paths;
-
- public const OptionEntry[] options = {
- { "async", 'a', 0, OptionArg.NONE, ref _async, "Run tests asynchronously in a separate subprocess [Experimental]", null },
- { "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 },
- { "quiet", 'q', 0, OptionArg.NONE, ref _quiet, "Run tests quietly", null },
- { "", 'r', 0, OptionArg.STRING, ref _runtest, null, null },
- { "skip", 's', 0, OptionArg.STRING_ARRAY, ref _skip, "Skip all tests matching", "TESTPATH..." },
- { "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" },
- { "timed", 0, 0, OptionArg.NONE, ref _timed, "Run timed tests", null }, { "tap", 0, 0, OptionArg.NONE, ref _tap, "Output test results using TAP format" },
- { "tap", 0, 0, OptionArg.NONE, ref _tap, "Output test results using TAP format" },
- { "testplan", 0, 0, OptionArg.STRING, ref _testplan, "Run the specified TestPlan", "FILE" },
- { "verbose", 0, 0, OptionArg.NONE, ref _verbose, "Run tests verbosely", null },
- { "version", 0, 0, OptionArg.NONE, ref _version, "Display version number", null },
- { "", 0, 0, OptionArg.STRING_ARRAY, ref _paths, "Only start test cases matching", "TESTPATH..." },
- { null }
- };
-
- public OptionContext opt_context;
-
- public static string? get_current_test_path() {
- return _runtest;
- }
+public class Valadate.TestOptions {
+
+ private static bool _async = true;
+ private static bool _tap;
+ private static string _format = "tap";
+ private static bool _keepgoing = false;
+ private static bool _list;
+ private static bool _quiet;
+ private static string _runtest = null;
+ [CCode (array_length = false, array_null_terminated = true)]
+ private static string[] _skip;
+ private static int _timeout = 60000;
+ private static string _seed;
+ private static bool _timed = true;
+ private static string _testplan;
+ private static bool _verbose;
+ private static bool _version;
+ [CCode (array_length = false, array_null_terminated = true)]
+ private static string[] _paths;
+
+ public const OptionEntry[] options = {
+ { "async", 'a', 0, OptionArg.NONE, ref _async, "Run tests asynchronously in a separate subprocess [Experimental]", null },
+ { "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 },
+ { "quiet", 'q', 0, OptionArg.NONE, ref _quiet, "Run tests quietly", null },
+ { "", 'r', 0, OptionArg.STRING, ref _runtest, null, null },
+ { "skip", 's', 0, OptionArg.STRING_ARRAY, ref _skip, "Skip all tests matching", "TESTPATH..." },
+ { "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" },
+ { "timed", 0, 0, OptionArg.NONE, ref _timed, "Run timed tests", null }, { "tap", 0, 0, OptionArg.NONE, ref _tap, "Output test results using TAP format" },
+ { "tap", 0, 0, OptionArg.NONE, ref _tap, "Output test results using TAP format" },
+ { "testplan", 0, 0, OptionArg.STRING, ref _testplan, "Run the specified TestPlan", "FILE" },
+ { "verbose", 0, 0, OptionArg.NONE, ref _verbose, "Run tests verbosely", null },
+ { "version", 0, 0, OptionArg.NONE, ref _version, "Display version number", null },
+ { "", 0, 0, OptionArg.STRING_ARRAY, ref _paths, "Only start test cases matching", "TESTPATH..." },
+ { null }
+ };
+
+ public OptionContext opt_context;
+
+ public static string? get_current_test_path() {
+ return _runtest;
+ }
- public string format {
- get {
- return _format;
- }
+ public string format {
+ get {
+ return _format;
}
+ }
- public string seed {
- get {
- return _seed;
- }
+ public string seed {
+ get {
+ return _seed;
}
+ }
- public string? running_test {
- get {
- return _runtest;
- }
+ public string? running_test {
+ get {
+ return _runtest;
}
+ }
- public bool run_async {
- get {
- return _async;
- }
+ public bool run_async {
+ get {
+ return _async;
}
+ }
- public bool list {
- get {
- return _list;
- }
+ public bool list {
+ get {
+ return _list;
}
+ }
- public bool keepgoing {
- get {
- return _keepgoing;
- }
+ public bool keepgoing {
+ get {
+ return _keepgoing;
}
+ }
- public int timeout {
- get {
- return _timeout;
- }
+ public int timeout {
+ get {
+ return _timeout;
}
+ }
- public bool timed {
- get {
- return _timed;
- }
+ public bool timed {
+ get {
+ return _timed;
}
+ }
- public TestOptions(string[] args) throws OptionError {
- _runtest = null;
-
- 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);
+ public TestOptions(string[] args) throws OptionError {
+ _runtest = null;
- 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());
+ 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());
}
+
}
diff --git a/valadate/testplan.vala b/valadate/testplan.vala
index fc8928e51..d70158d2b 100644
--- a/valadate/testplan.vala
+++ b/valadate/testplan.vala
@@ -274,10 +274,11 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
return istest;
}
- public TestSuite visit_testsuite(Vala.Class testclass) throws Error {
+ public void visit_testsuite(Vala.Class testclass) throws Error {
unowned Constructor meth = get_constructor(testclass);
- var testcase_test = meth() as TestSuite;
- testcase_test.name = testclass.name;
- return testcase_test;
+ var tsuite = meth() as TestSuite;
+ tsuite.name = testclass.name;
+ testsuite.add_test(tsuite);
+ testsuite = tsuite;
}
}
diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
index b02953932..2576cc3d8 100644
--- a/valadate/testrunner.vala
+++ b/valadate/testrunner.vala
@@ -20,7 +20,8 @@
* Chris Daley <chebizarro@gmail.com>
*/
-public class Valadate.TestRunner : Object {
+public class Valadate.TestRunner {
+
private class DelegateWrapper {
public SourceFunc cb;
}
diff --git a/valadate/valadate.deps.in b/valadate/valadate.deps.in
new file mode 100644
index 000000000..2f1a12474
--- /dev/null
+++ b/valadate/valadate.deps.in
@@ -0,0 +1,3 @@
+libxml-2.0
+gio-2.0
+libvala@PACKAGE_SUFFIX@