Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 5fb758a8eddeabb925af4c7f1316ba4b718113a8 Mon Sep 17 00:00:00 2001
- From: Rico Tzschichholz <ricotz@ubuntu.com>
- Date: Fri, 28 Apr 2017 20:12:06 +0200
- Subject: [PATCH 1/2] Space before (
- ---
- tests/valatests.vala | 34 +++---
- tests/valatestsfactory.vala | 46 ++++----
- valadate/assembly.vala | 46 ++++----
- valadate/gnutestreportprinter.vala | 46 ++++----
- valadate/taptestreportprinter.vala | 92 +++++++--------
- valadate/test.vala | 4 +-
- valadate/testadapter.vala | 44 +++----
- valadate/testassembly.vala | 64 +++++-----
- valadate/testcase.vala | 54 ++++-----
- valadate/testconfig.vala | 2 +-
- valadate/testgatherer.vala | 28 ++---
- valadate/testmodule.vala | 26 ++---
- valadate/testoptions.vala | 16 +--
- valadate/testplan.vala | 234 ++++++++++++++++++-------------------
- valadate/testreport.vala | 208 ++++++++++++++++-----------------
- valadate/testreportprinter.vala | 16 +--
- valadate/testresult.vala | 102 ++++++++--------
- valadate/testrunner.vala | 120 +++++++++----------
- valadate/testsuite.vala | 36 +++---
- valadate/xmlfile.vala | 48 ++++----
- valadate/xmltestreportprinter.vala | 32 ++---
- 21 files changed, 649 insertions(+), 649 deletions(-)
- diff --git a/tests/valatests.vala b/tests/valatests.vala
- index 9e4cbd22..b1faf099 100644
- --- a/tests/valatests.vala
- +++ b/tests/valatests.vala
- @@ -23,7 +23,7 @@ public class Vala.Tests : Valadate.TestSuite {
- construct {
- try {
- - var testdir = File.new_for_path (GLib.Environment.get_variable("G_TEST_BUILDDIR"));
- + var testdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
- var testpath = Valadate.TestOptions.get_current_test_path ();
- if (testpath != null) {
- @@ -35,26 +35,26 @@ public class Vala.Tests : Valadate.TestSuite {
- add_test (new ValaTest (runtest));
- } else {
- var tempdir = testdir.get_child (".tests");
- - if (tempdir.query_exists()) {
- + if (tempdir.query_exists ()) {
- var enumerator = tempdir.enumerate_children (FileAttribute.STANDARD_NAME, 0);
- FileInfo file_info;
- while ((file_info = enumerator.next_file ()) != null) {
- - var filename = file_info.get_name();
- - if(filename == "." || filename == "..")
- + var filename = file_info.get_name ();
- + if (filename == "." || filename == "..")
- continue;
- - var tfile = tempdir.get_child(file_info.get_name());
- - tfile.delete();
- + var tfile = tempdir.get_child (file_info.get_name ());
- + tfile.delete ();
- }
- } else {
- - tempdir.make_directory();
- + tempdir.make_directory ();
- }
- var enumerator = testdir.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 &&
- - !file_info.get_name().has_prefix("."))
- - add_test (new ValaTest (testdir.get_child(file_info.get_name())));
- + 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 ())));
- }
- } catch (Error e) {
- stderr.printf ("Error: %s\n", e.message);
- @@ -70,7 +70,7 @@ public class Vala.Tests : Valadate.TestSuite {
- this.label = directory.get_path ();
- this.bug_base = BUGZILLA_URL;
- - string current_test = Valadate.TestOptions.get_current_test_path();
- + string current_test = Valadate.TestOptions.get_current_test_path ();
- if (current_test != null) {
- var basename = Path.get_basename (current_test);
- @@ -95,15 +95,15 @@ public class Vala.Tests : Valadate.TestSuite {
- string basename = testfile.get_basename ();
- string testname = basename.substring (0, basename.last_index_of ("."));
- - var adapter = new Valadate.TestAdapter(testname, 1000);
- - adapter.label = "/Vala/Tests/%s/%s".printf(
- - Path.get_basename(testfile.get_parent().get_path()),
- + 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(() => {
- + adapter.add_test_method (() => {
- try {
- if (testname.has_prefix ("bug"))
- - bug (testname.substring(3));
- + bug (testname.substring (3));
- var prog = factory.get_test_program (testfile);
- prog.run ();
- factory.cleanup ();
- @@ -112,7 +112,7 @@ public class Vala.Tests : Valadate.TestSuite {
- }
- });
- - add_test(adapter);
- + add_test (adapter);
- }
- }
- }
- diff --git a/tests/valatestsfactory.vala b/tests/valatestsfactory.vala
- index 090cb912..7021f938 100644
- --- a/tests/valatestsfactory.vala
- +++ b/tests/valatestsfactory.vala
- @@ -29,18 +29,18 @@ public class Vala.TestsFactory : Object {
- static File vapidir;
- class construct {
- - currdir = File.new_for_path (GLib.Environment.get_variable("G_TEST_BUILDDIR"));
- + currdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
- testdir = currdir.get_child (".tests");
- buildir = currdir.get_parent ();
- var usevalac = Environment.get_variable ("VALAC");
- - if (usevalac != null && File.new_for_path(usevalac).query_exists())
- - valac = File.new_for_path(usevalac);
- + 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");
- + valac = buildir.get_child ("compiler").get_child ("valac");
- var usevapidir = Environment.get_variable ("VAPIDIR");
- - if (usevapidir != null && File.new_for_path (usevapidir).query_exists())
- + if (usevapidir != null && File.new_for_path (usevapidir).query_exists ())
- vapidir = File.new_for_path (usevapidir);
- else
- vapidir = buildir.get_child ("vapi");
- @@ -49,7 +49,7 @@ public class Vala.TestsFactory : Object {
- private static TestsFactory instance;
- - public static unowned TestsFactory get_instance() {
- + public static unowned TestsFactory get_instance () {
- if (instance == null)
- instance = new TestsFactory ();
- return instance;
- @@ -165,7 +165,7 @@ public class Vala.TestsFactory : Object {
- }
- }
- - public virtual void cleanup() throws Error {
- + public virtual void cleanup () throws Error {
- foreach (unowned File file in files)
- if (file.query_exists ())
- file.delete ();
- @@ -210,7 +210,7 @@ public class Vala.TestsFactory : Object {
- public DBusTest (string testname, string packages, DataInputStream stream) throws Error {
- Object (program : testdir.get_child (testname + ".server"));
- - var factory = TestsFactory.get_instance();
- + 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");
- @@ -242,7 +242,7 @@ public class Vala.TestsFactory : Object {
- 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");
- + source = testdir.get_child (testname + ".vala");
- add_file_from_stream (source, stream, null, null);
- compiler = new ValaCompiler (valac);
- compiler.callback = new_callback;
- @@ -259,9 +259,9 @@ public class Vala.TestsFactory : Object {
- testprogam = compiler.compile (program, source, packages);
- }
- - public override void cleanup() throws Error {
- - testprogam.cleanup();
- - base.cleanup();
- + public override void cleanup () throws Error {
- + testprogam.cleanup ();
- + base.cleanup ();
- }
- }
- @@ -291,11 +291,11 @@ public class Vala.TestsFactory : Object {
- private File vapifile;
- public GIRTestProgram (string testname, string packages, DataInputStream stream) throws Error {
- - Object (program : testdir.get_child(testname + ".gir"));
- + 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 (vapifile, stream, null, null, VAPIHEADER.printf (testname), "\n}\n");
- }
- public override void run (string? command = null) throws Error {
- @@ -308,8 +308,8 @@ public class Vala.TestsFactory : Object {
- }
- public class Diff : Program {
- - public Diff() {
- - Object (program : File.new_for_path(Environment.find_program_in_path ("diff")));
- + public Diff () {
- + Object (program : File.new_for_path (Environment.find_program_in_path ("diff")));
- }
- }
- @@ -351,30 +351,30 @@ public class Vala.TestsFactory : Object {
- string command = "--vapidir %s %s %s %s -o %s %s".printf (
- vapidir.get_path (),
- VALA_FLAGS,
- - get_flags(),
- + get_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"));
- + prog.add_file (binary.get_parent ().get_child (binary.get_basename () + ".c"));
- return prog;
- }
- - private string get_flags() throws Error {
- + private string get_flags () throws Error {
- string result = "";
- string[] flags = {"CFLAGS", "CPPFLAGS", "LDFLAGS"};
- - foreach(string key in flags) {
- + foreach (string key in flags) {
- var val = Environment.get_variable (key);
- - if(val == null || val.length == 0)
- + if (val == null || val.length == 0)
- continue;
- string[] args;
- - Shell.parse_argv(val, out args);
- + Shell.parse_argv (val, out args);
- foreach (var item in args)
- - result += "-X %s ".printf(item);
- + result += "-X %s ".printf (item);
- }
- return result;
- diff --git a/valadate/assembly.vala b/valadate/assembly.vala
- index 8536460d..b2e08093 100644
- --- a/valadate/assembly.vala
- +++ b/valadate/assembly.vala
- @@ -24,15 +24,15 @@ public abstract class Valadate.Assembly {
- protected static SubprocessLauncher launcher;
- - private static void init_launcher() {
- + private static void init_launcher () {
- if (launcher == null) {
- - launcher = new SubprocessLauncher(
- + launcher = new SubprocessLauncher (
- GLib.SubprocessFlags.STDIN_PIPE |
- GLib.SubprocessFlags.STDOUT_PIPE |
- GLib.SubprocessFlags.STDERR_PIPE);
- - launcher.setenv("G_MESSAGES_DEBUG","all",true);
- - launcher.setenv("G_DEBUG","fatal-criticals fatal-warnings gc-friendly",true);
- - launcher.setenv("G_SLICE","always-malloc debug-blocks",true);
- + launcher.setenv ("G_MESSAGES_DEBUG","all",true);
- + launcher.setenv ("G_DEBUG","fatal-criticals fatal-warnings gc-friendly",true);
- + launcher.setenv ("G_SLICE","always-malloc debug-blocks",true);
- }
- }
- @@ -43,31 +43,31 @@ public abstract class Valadate.Assembly {
- protected Subprocess process;
- - public Assembly(File binary) throws Error {
- - init_launcher();
- - if(!binary.query_exists())
- - throw new FileError.NOENT("The file %s does not exist", binary.get_path());
- - if(!GLib.FileUtils.test(binary.get_path(), FileTest.IS_EXECUTABLE))
- - throw new FileError.PERM("The file %s is not executable", binary.get_path());
- + public Assembly (File binary) throws Error {
- + init_launcher ();
- + if (!binary.query_exists ())
- + throw new FileError.NOENT ("The file %s does not exist", binary.get_path ());
- + if (!GLib.FileUtils.test (binary.get_path (), FileTest.IS_EXECUTABLE))
- + throw new FileError.PERM ("The file %s is not executable", binary.get_path ());
- this.binary = binary;
- }
- - public abstract Assembly clone() throws Error;
- + public abstract Assembly clone () throws Error;
- - public virtual Assembly run(string? command = null, Cancellable? cancellable = null) throws Error {
- + public virtual Assembly run (string? command = null, Cancellable? cancellable = null) throws Error {
- string[] args;
- - Shell.parse_argv("%s %s".printf(binary.get_path(), command ?? ""), out args);
- - process = launcher.spawnv(args);
- - stdout = new DataInputStream (process.get_stdout_pipe());
- - stderr = new DataInputStream (process.get_stderr_pipe());
- - stdin = new DataOutputStream (process.get_stdin_pipe());
- - process.wait_check(cancellable);
- - cancellable.set_error_if_cancelled();
- + Shell.parse_argv ("%s %s".printf (binary.get_path (), command ?? ""), out args);
- + process = launcher.spawnv (args);
- + stdout = new DataInputStream (process.get_stdout_pipe ());
- + stderr = new DataInputStream (process.get_stderr_pipe ());
- + stdin = new DataOutputStream (process.get_stdin_pipe ());
- + process.wait_check (cancellable);
- + cancellable.set_error_if_cancelled ();
- return this;
- }
- - public virtual void quit() {
- - if(process != null)
- - process.force_exit();
- + public virtual void quit () {
- + if (process != null)
- + process.force_exit ();
- }
- }
- diff --git a/valadate/gnutestreportprinter.vala b/valadate/gnutestreportprinter.vala
- index 87ce5e53..2bc039a5 100644
- --- a/valadate/gnutestreportprinter.vala
- +++ b/valadate/gnutestreportprinter.vala
- @@ -23,53 +23,53 @@ public class Valadate.GnuTestReportPrinter : TestReportPrinter {
- private const string TAP_VERSION = "13";
- - private List<TestCase> testcases = new List<TestCase>();
- + private List<TestCase> testcases = new List<TestCase> ();
- - public GnuTestReportPrinter(TestConfig config) throws Error {
- - base(config);
- + public GnuTestReportPrinter (TestConfig config) throws Error {
- + base (config);
- }
- - public override void print(TestReport report) {
- + public override void print (TestReport report) {
- - if(report.test is TestSuite) {
- - testcases = new List<TestCase>();
- - } else if(report.test is TestCase) {
- - testcases.append(report.test as TestCase);
- - } else if(report.test is TestAdapter) {
- + if (report.test is TestSuite) {
- + testcases = new List<TestCase> ();
- + } else if (report.test is TestCase) {
- + testcases.append (report.test as TestCase);
- + } else if (report.test is TestAdapter) {
- var test = report.test as TestAdapter;
- - var idx = testcases.index(test.parent as TestCase);
- + var idx = testcases.index (test.parent as TestCase);
- int index = 1;
- - if(idx > 0)
- - for(int i=0; i<idx;i++)
- - index += testcases.nth_data(i).count;
- + if (idx > 0)
- + for (int i=0; i<idx;i++)
- + index += testcases.nth_data (i).count;
- - for(int i=0;i<test.parent.count; i++) {
- - if(test.parent[i] == test) {
- + for (int i=0;i<test.parent.count; i++) {
- + if (test.parent[i] == test) {
- index += i;
- }
- }
- - switch(report.test.status) {
- + switch (report.test.status) {
- case TestStatus.PASSED:
- - stdout.printf("PASS: %s %d - %s\n", test.parent.name, index, test.name);
- + stdout.printf ("PASS: %s %d - %s\n", test.parent.name, index, test.name);
- break;
- case TestStatus.SKIPPED:
- - stdout.printf("SKIP: %s %d - %s # SKIP %s \n",
- + stdout.printf ("SKIP: %s %d - %s # SKIP %s \n",
- test.parent.name, index, test.label, test.status_message ?? "");
- break;
- case TestStatus.TODO:
- - var errs = report.xml.eval("//failure | //error");
- - if(errs.size > 0)
- - stdout.printf("XFAIL: %s %d - %s # TODO %s \n",
- + var errs = report.xml.eval ("//failure | //error");
- + if (errs.size > 0)
- + stdout.printf ("XFAIL: %s %d - %s # TODO %s \n",
- test.parent.name, index, test.label, test.status_message ?? "");
- else
- - stdout.printf("PASS: %s %d - %s # TODO %s \n",
- + stdout.printf ("PASS: %s %d - %s # TODO %s \n",
- test.parent.name, index, test.label, test.status_message ?? "");
- break;
- case TestStatus.FAILED:
- case TestStatus.ERROR:
- - stdout.printf("FAIL: %s %d - %s\n", test.parent.name, index, test.label);
- + stdout.printf ("FAIL: %s %d - %s\n", test.parent.name, index, test.label);
- break;
- default:
- break;
- diff --git a/valadate/taptestreportprinter.vala b/valadate/taptestreportprinter.vala
- index c1f9d777..7fa2f026 100644
- --- a/valadate/taptestreportprinter.vala
- +++ b/valadate/taptestreportprinter.vala
- @@ -24,85 +24,85 @@ public class Valadate.TapTestReportPrinter : TestReportPrinter {
- private const string TAP_VERSION = "13";
- - private List<TestCase> testcases = new List<TestCase>();
- + private List<TestCase> testcases = new List<TestCase> ();
- - public TapTestReportPrinter(TestConfig config) throws Error {
- - base(config);
- - if(!config.list_only) {
- - stdout.printf("TAP version %s\n", TAP_VERSION);
- - stdout.printf("# random seed: %s\n", config.seed);
- + public TapTestReportPrinter (TestConfig config) throws Error {
- + base (config);
- + if (!config.list_only) {
- + stdout.printf ("TAP version %s\n", TAP_VERSION);
- + stdout.printf ("# random seed: %s\n", config.seed);
- }
- }
- - public override void print(TestReport report) {
- + public override void print (TestReport report) {
- - if(report.test is TestSuite && report.test.parent.name == "/") {
- - stdout.printf("1..%d\n", report.test.count);
- + if (report.test is TestSuite && report.test.parent.name == "/") {
- + stdout.printf ("1..%d\n", report.test.count);
- - var props = report.xml.eval("//properties/property");
- - stdout.puts("# Environment\n");
- - foreach(Xml.Node* prop in props) {
- - stdout.printf("# %s : %s\n",
- - prop->get_prop("name"), prop->get_prop("value"));
- + var props = report.xml.eval ("//properties/property");
- + stdout.puts ("# Environment\n");
- + foreach (Xml.Node* prop in props) {
- + stdout.printf ("# %s : %s\n",
- + prop->get_prop ("name"), prop->get_prop ("value"));
- }
- - } else if(report.test is TestCase) {
- - testcases.append(report.test as TestCase);
- - stdout.printf("# Start of %s tests\n", report.test.label);
- + } else if (report.test is TestCase) {
- + testcases.append (report.test as TestCase);
- + stdout.printf ("# Start of %s tests\n", report.test.label);
- - } else if(report.test is TestAdapter) {
- + } else if (report.test is TestAdapter) {
- var test = report.test as TestAdapter;
- - var idx = testcases.index(test.parent as TestCase);
- + var idx = testcases.index (test.parent as TestCase);
- int index = 1;
- bool lasttest = false;
- - if(idx > 0)
- - for(int i=0; i<idx;i++)
- - index += testcases.nth_data(i).count;
- + if (idx > 0)
- + for (int i=0; i<idx;i++)
- + index += testcases.nth_data (i).count;
- - for(int i=0;i<test.parent.count; i++) {
- - if(test.parent[i] == test) {
- + for (int i=0;i<test.parent.count; i++) {
- + if (test.parent[i] == test) {
- index += i;
- lasttest = (i == test.parent.count-1);
- }
- }
- - switch(report.test.status) {
- + switch (report.test.status) {
- case TestStatus.PASSED:
- - stdout.printf("ok %d - %s\n", index, test.label);
- + stdout.printf ("ok %d - %s\n", index, test.label);
- break;
- case TestStatus.SKIPPED:
- - stdout.printf("ok %d - %s # SKIP %s \n", index, test.label, test.status_message ?? "Skipping");
- + stdout.printf ("ok %d - %s # SKIP %s \n", index, test.label, test.status_message ?? "Skipping");
- break;
- case TestStatus.TODO:
- - var errs = report.xml.eval("//failure | //error");
- - if(errs.size > 0)
- - stdout.printf("not ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
- + var errs = report.xml.eval ("//failure | //error");
- + if (errs.size > 0)
- + stdout.printf ("not ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
- else
- - stdout.printf("ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
- + stdout.printf ("ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
- break;
- case TestStatus.FAILED:
- case TestStatus.ERROR:
- - stdout.printf("not ok %d - %s\n", index, test.label);
- + stdout.printf ("not ok %d - %s\n", index, test.label);
- break;
- default:
- - stdout.printf("Bail out! %s\n", "There was an unexpected error");
- + stdout.printf ("Bail out! %s\n", "There was an unexpected error");
- break;
- }
- - stdout.puts(" ---\n");
- - stdout.printf(" duration_ms: %.4f\n", test.time);
- - var messages = report.xml.eval("//failure | //error | //info");
- - foreach(Xml.Node* mess in messages) {
- - stdout.printf(" message: >\n %s\n", mess->get_prop("message"));
- - stdout.printf(" severity: %s\n", mess->name);
- + stdout.puts (" ---\n");
- + stdout.printf (" duration_ms: %.4f\n", test.time);
- + var messages = report.xml.eval ("//failure | //error | //info");
- + foreach (Xml.Node* mess in messages) {
- + stdout.printf (" message: >\n %s\n", mess->get_prop ("message"));
- + stdout.printf (" severity: %s\n", mess->name);
- }
- - stdout.puts(" ...\n");
- - messages = report.xml.eval("//system-out | //system-err");
- - foreach(Xml.Node* mess in messages)
- - stdout.printf("# %s\n", string.joinv("\n# ", mess->get_content().split("\n")));
- - if(lasttest)
- - stdout.printf("# End of %s tests\n", test.parent.label);
- - stdout.flush();
- + stdout.puts (" ...\n");
- + messages = report.xml.eval ("//system-out | //system-err");
- + foreach (Xml.Node* mess in messages)
- + stdout.printf ("# %s\n", string.joinv ("\n# ", mess->get_content ().split ("\n")));
- + if (lasttest)
- + stdout.printf ("# End of %s tests\n", test.parent.label);
- + stdout.flush ();
- }
- }
- }
- diff --git a/valadate/test.vala b/valadate/test.vala
- index 0d853eba..310fbd65 100644
- --- a/valadate/test.vala
- +++ b/valadate/test.vala
- @@ -59,7 +59,7 @@ public interface Valadate.Test : Object {
- public abstract Test? parent {get;set;}
- - public abstract Test get(int index);
- + public abstract Test get (int index);
- - public abstract void set(int index, Test test);
- + public abstract void set (int index, Test test);
- }
- diff --git a/valadate/testadapter.vala b/valadate/testadapter.vala
- index 93083081..2b5499f3 100644
- --- a/valadate/testadapter.vala
- +++ b/valadate/testadapter.vala
- @@ -46,18 +46,18 @@ public class Valadate.TestAdapter : Object, Test {
- private TestCase.TestMethod test;
- public Test? parent {get;set;}
- - public new Test get(int index) {
- + public new Test get (int index) {
- return this;
- }
- - public TestAdapter(string name, int timeout) {
- + public TestAdapter (string name, int timeout) {
- this.name = name;
- this.timeout = timeout;
- }
- - public void add_test(owned TestPlan.TestMethod testmethod) {
- + public void add_test (owned TestPlan.TestMethod testmethod) {
- this.test = () => {
- - testmethod(parent as TestCase);
- + testmethod (parent as TestCase);
- };
- }
- @@ -68,40 +68,40 @@ public class Valadate.TestAdapter : Object, Test {
- var p = parent as TestCase;
- this.test = () => {
- AsyncResult? result = null;
- - var loop = new MainLoop();
- - var thread = new Thread<void*>.try(name, () => {
- - async_begin(p, (o, r) => { result = r; loop.quit();});
- + var loop = new MainLoop ();
- + var thread = new Thread<void*>.try (name, () => {
- + async_begin (p, (o, r) => { result = r; loop.quit ();});
- return null;
- });
- - Timeout.add(timeout, () => {
- - loop.quit();
- + Timeout.add (timeout, () => {
- + loop.quit ();
- return false;
- },
- Priority.HIGH);
- - loop.run();
- - if(result == null)
- - throw new IOError.TIMED_OUT(
- + loop.run ();
- + if (result == null)
- + throw new IOError.TIMED_OUT (
- "The test timed out after %d milliseconds",timeout);
- - async_finish(p, result);
- + async_finish (p, result);
- };
- }
- - public void add_test_method(owned TestCase.TestMethod testmethod) {
- + public void add_test_method (owned TestCase.TestMethod testmethod) {
- this.test = (owned)testmethod;
- }
- - public void run(TestResult result) {
- - if(status == TestStatus.SKIPPED)
- + public void run (TestResult result) {
- + if (status == TestStatus.SKIPPED)
- return;
- var p = parent as TestCase;
- - result.add_test(this);
- - p.set_up();
- + result.add_test (this);
- + p.set_up ();
- try {
- - test();
- + test ();
- } catch (Error e) {
- - result.add_failure(this, e.message);
- + result.add_failure (this, e.message);
- }
- - p.tear_down();
- - result.add_success(this);
- + p.tear_down ();
- + result.add_success (this);
- }
- }
- diff --git a/valadate/testassembly.vala b/valadate/testassembly.vala
- index bc8e5aa9..7c2f8038 100644
- --- a/valadate/testassembly.vala
- +++ b/valadate/testassembly.vala
- @@ -27,67 +27,67 @@ public class Valadate.TestAssembly : TestModule {
- public TestOptions options {get;set;}
- - public TestAssembly(string[] args) throws Error {
- - base(File.new_for_path(args[0]));
- - options = new TestOptions(args);
- - setup_dirs();
- + public TestAssembly (string[] args) throws Error {
- + base (File.new_for_path (args[0]));
- + options = new TestOptions (args);
- + setup_dirs ();
- }
- - private TestAssembly.copy(TestAssembly other) throws Error {
- - base(other.binary);
- + private TestAssembly.copy (TestAssembly other) throws Error {
- + base (other.binary);
- options = other.options;
- }
- - private void setup_dirs() throws Error {
- - var buildstr = Environment.get_variable("G_TEST_BUILDDIR");
- + private void setup_dirs () throws Error {
- + var buildstr = Environment.get_variable ("G_TEST_BUILDDIR");
- - if(buildstr == null) {
- - builddir = binary.get_parent();
- - if(builddir.get_basename() == ".libs")
- - builddir = builddir.get_parent();
- + if (buildstr == null) {
- + builddir = binary.get_parent ();
- + if (builddir.get_basename () == ".libs")
- + builddir = builddir.get_parent ();
- } else {
- - builddir = File.new_for_path(buildstr);
- + builddir = File.new_for_path (buildstr);
- }
- - var srcstr = Environment.get_variable("G_TEST_SRCDIR");
- + var srcstr = Environment.get_variable ("G_TEST_SRCDIR");
- - if(srcstr == null) {
- + if (srcstr == null) {
- // we're running outside the test harness
- // check for buildir!=srcdir
- // this currently on checks for autotools
- - if(!builddir.get_child("Makefile.in").query_exists()) {
- + if (!builddir.get_child ("Makefile.in").query_exists ()) {
- // check for Makefile in builddir and extract VPATH
- - var makefile = builddir.get_child("Makefile");
- - if(makefile.query_exists()) {
- - var reader = new DataInputStream(makefile.read());
- - var line = reader.read_line();
- - while(line!= null) {
- - if(line.has_prefix("VPATH = ")) {
- - srcstr = Path.build_path(Path.DIR_SEPARATOR_S, builddir.get_path(), line.split(" = ")[1]);
- + var makefile = builddir.get_child ("Makefile");
- + if (makefile.query_exists ()) {
- + var reader = new DataInputStream (makefile.read ());
- + var line = reader.read_line ();
- + while (line!= null) {
- + if (line.has_prefix ("VPATH = ")) {
- + srcstr = Path.build_path (Path.DIR_SEPARATOR_S, builddir.get_path (), line.split (" = ")[1]);
- break;
- }
- - line = reader.read_line();
- + line = reader.read_line ();
- }
- }
- }
- }
- - if(srcstr == null)
- + if (srcstr == null)
- srcdir = builddir;
- else
- - srcdir = File.new_for_path(srcstr);
- + srcdir = File.new_for_path (srcstr);
- - var mesondir = srcdir.get_child(Path.get_basename(binary.get_path()) + "@exe");
- + var mesondir = srcdir.get_child (Path.get_basename (binary.get_path ()) + "@exe");
- - if(mesondir.query_exists())
- + if (mesondir.query_exists ())
- srcdir = mesondir;
- - Environment.set_variable("G_TEST_BUILDDIR", builddir.get_path(), true);
- - Environment.set_variable("G_TEST_SRCDIR", srcdir.get_path(), true);
- + Environment.set_variable ("G_TEST_BUILDDIR", builddir.get_path (), true);
- + Environment.set_variable ("G_TEST_SRCDIR", srcdir.get_path (), true);
- }
- - public override Assembly clone() throws Error {
- - return new TestAssembly.copy(this);
- + public override Assembly clone () throws Error {
- + return new TestAssembly.copy (this);
- }
- }
- diff --git a/valadate/testcase.vala b/valadate/testcase.vala
- index 717d8798..35207ddb 100644
- --- a/valadate/testcase.vala
- +++ b/valadate/testcase.vala
- @@ -44,7 +44,7 @@ public abstract class Valadate.TestCase : Object, Test {
- public int count {
- get {
- int testcount = 0;
- - _tests.foreach((t) => {
- + _tests.foreach ((t) => {
- testcount += t.count;
- });
- return testcount;
- @@ -54,7 +54,7 @@ public abstract class Valadate.TestCase : Object, Test {
- public int size {
- get {
- int testcount = 0;
- - _tests.foreach((t) => {
- + _tests.foreach ((t) => {
- testcount += t.count;
- });
- return testcount;
- @@ -69,60 +69,60 @@ public abstract class Valadate.TestCase : Object, Test {
- public string bug_base {get;set;}
- - private List<Test> _tests = new List<Test>();
- + private List<Test> _tests = new List<Test> ();
- private Test current_test;
- private TestResult current_result;
- - public new Test get(int index) {
- - return _tests.nth_data((uint)index);
- + public new Test get (int index) {
- + return _tests.nth_data ((uint)index);
- }
- - public new void set(int index, Test test) {
- + public new void set (int index, Test test) {
- test.parent = this;
- - _tests.insert_before(_tests.nth(index), test);
- - var t = _tests.nth_data((uint)index++);
- - _tests.remove(t);
- + _tests.insert_before (_tests.nth (index), test);
- + var t = _tests.nth_data ((uint)index++);
- + _tests.remove (t);
- }
- - public void add_test(Test test) {
- + public void add_test (Test test) {
- test.parent = this;
- - _tests.append(test);
- + _tests.append (test);
- }
- - public void add_test_method(string testname, owned TestMethod test, int timeout, string? label = null) {
- + public void add_test_method (string testname, owned TestMethod test, int timeout, string? label = null) {
- var adapter = new TestAdapter (testname, timeout);
- - adapter.add_test_method((owned)test);
- + adapter.add_test_method ((owned)test);
- adapter.label = label;
- adapter.parent = this;
- - _tests.append(adapter);
- + _tests.append (adapter);
- }
- - public virtual void run(TestResult result) {
- - if(status != TestStatus.NOT_RUN)
- + public virtual void run (TestResult result) {
- + if (status != TestStatus.NOT_RUN)
- return;
- current_result = result;
- - _tests.foreach((t) => {
- + _tests.foreach ((t) => {
- current_test = t;
- - t.run(result);
- + t.run (result);
- });
- }
- - public void bug(string reference)
- - requires(bug_base != null)
- + public void bug (string reference)
- + requires (bug_base != null)
- {
- - info("Bug Reference: %s%s",bug_base, reference);
- + info ("Bug Reference: %s%s",bug_base, reference);
- }
- - public void skip(string message) {
- - current_result.add_skip(current_test, message);
- + public void skip (string message) {
- + current_result.add_skip (current_test, message);
- }
- - public void fail(string? message = null) {
- - current_result.add_failure(current_test, message);
- + public void fail (string? message = null) {
- + current_result.add_failure (current_test, message);
- }
- - public virtual void set_up() {}
- + public virtual void set_up () {}
- - public virtual void tear_down() {}
- + public virtual void tear_down () {}
- }
- diff --git a/valadate/testconfig.vala b/valadate/testconfig.vala
- index a7405dbd..20641913 100644
- --- a/valadate/testconfig.vala
- +++ b/valadate/testconfig.vala
- @@ -91,7 +91,7 @@ public class Valadate.TestConfig {
- }
- }
- - public TestConfig(TestOptions options) {
- + public TestConfig (TestOptions options) {
- this.options = options;
- }
- }
- diff --git a/valadate/testgatherer.vala b/valadate/testgatherer.vala
- index a9049f30..67b5d0f0 100644
- --- a/valadate/testgatherer.vala
- +++ b/valadate/testgatherer.vala
- @@ -23,35 +23,35 @@
- public class Valadate.TestGatherer : Vala.CodeVisitor {
- public HashTable<Type, Vala.Class> classes =
- - new HashTable<Type, Vala.Class>(direct_hash, direct_equal);
- + new HashTable<Type, Vala.Class> (direct_hash, direct_equal);
- private TestAssembly assembly;
- - public TestGatherer(TestAssembly assembly) {
- + public TestGatherer (TestAssembly assembly) {
- this.assembly = assembly;
- }
- - public override void visit_namespace(Vala.Namespace ns) {
- - ns.accept_children(this);
- + public override void visit_namespace (Vala.Namespace ns) {
- + ns.accept_children (this);
- }
- - public override void visit_class(Vala.Class cls) {
- + public override void visit_class (Vala.Class cls) {
- try {
- - var classtype = find_type(cls);
- - if (classtype.is_a(typeof(TestCase)) || classtype.is_a(typeof(TestSuite)))
- - classes.insert(classtype, cls);
- + var classtype = find_type (cls);
- + if (classtype.is_a (typeof (TestCase)) || classtype.is_a (typeof (TestSuite)))
- + classes.insert (classtype, cls);
- } catch (Error e) {
- - warning(e.message);
- + warning (e.message);
- }
- - cls.accept_children(this);
- + cls.accept_children (this);
- }
- - private Type find_type(Vala.Class cls) throws Error {
- + private Type find_type (Vala.Class cls) throws Error {
- var attr = new Vala.CCodeAttribute (cls);
- unowned TestPlan.GetType node_get_type =
- - (TestPlan.GetType)assembly.get_method(
- - "%sget_type".printf(attr.lower_case_prefix));
- - var ctype = node_get_type();
- + (TestPlan.GetType)assembly.get_method (
- + "%sget_type".printf (attr.lower_case_prefix));
- + var ctype = node_get_type ();
- return ctype;
- }
- }
- diff --git a/valadate/testmodule.vala b/valadate/testmodule.vala
- index c06ae655..67122cf0 100644
- --- a/valadate/testmodule.vala
- +++ b/valadate/testmodule.vala
- @@ -27,29 +27,29 @@ public class Valadate.TestModule : Assembly {
- private GLib.Module module;
- - public TestModule(File binary) throws Error {
- - base(binary);
- + public TestModule (File binary) throws Error {
- + base (binary);
- }
- - private void load_module() throws AssemblyError {
- - module = GLib.Module.open (binary.get_path(), ModuleFlags.BIND_LAZY);
- + private void load_module () throws AssemblyError {
- + module = GLib.Module.open (binary.get_path (), ModuleFlags.BIND_LAZY);
- if (module == null)
- - throw new AssemblyError.LOAD(GLib.Module.error());
- - module.make_resident();
- + throw new AssemblyError.LOAD (GLib.Module.error ());
- + module.make_resident ();
- }
- - public virtual void* get_method(string method_name) throws AssemblyError {
- - if(module == null)
- - load_module();
- + public virtual void* get_method (string method_name) throws AssemblyError {
- + if (module == null)
- + load_module ();
- void* function;
- - if(module.symbol (method_name, out function))
- + if (module.symbol (method_name, out function))
- if (function != null)
- return function;
- - throw new AssemblyError.METHOD(GLib.Module.error());
- + throw new AssemblyError.METHOD (GLib.Module.error ());
- }
- - public override Assembly clone() throws Error {
- - return new TestModule(binary);
- + public override Assembly clone () throws Error {
- + return new TestModule (binary);
- }
- }
- diff --git a/valadate/testoptions.vala b/valadate/testoptions.vala
- index 1cffd541..f7a19c2e 100644
- --- a/valadate/testoptions.vala
- +++ b/valadate/testoptions.vala
- @@ -60,7 +60,7 @@ public class Valadate.TestOptions {
- public OptionContext opt_context;
- - public static string? get_current_test_path() {
- + public static string? get_current_test_path () {
- return _runtest;
- }
- @@ -118,7 +118,7 @@ public class Valadate.TestOptions {
- }
- }
- - public TestOptions(string[] args) throws OptionError {
- + public TestOptions (string[] args) throws OptionError {
- _runtest = null;
- opt_context = new OptionContext ("- Valadate Testing Framework");
- @@ -126,12 +126,12 @@ public class Valadate.TestOptions {
- 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());
- + 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 d70158d2..a5dfba9b 100644
- --- a/valadate/testplan.vala
- +++ b/valadate/testplan.vala
- @@ -23,12 +23,12 @@
- public class Valadate.TestPlan : Vala.CodeVisitor {
- [CCode (has_target = false)]
- - public delegate void TestMethod(TestCase self) throws Error;
- + public delegate void TestMethod (TestCase self) throws Error;
- - public delegate void AsyncTestMethod(TestCase self, AsyncReadyCallback cb);
- - public delegate void AsyncTestMethodResult(TestCase self, AsyncResult res) throws Error;
- + public delegate void AsyncTestMethod (TestCase self, AsyncReadyCallback cb);
- + public delegate void AsyncTestMethodResult (TestCase self, AsyncResult res) throws Error;
- - public delegate Type GetType();
- + public delegate Type GetType ();
- public File plan {get;set;}
- @@ -46,40 +46,40 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- private Vala.CodeContext context;
- private TestGatherer gatherer;
- - private delegate TestCase Constructor();
- + private delegate TestCase Constructor ();
- private TestSuite testsuite;
- private TestCase testcase;
- - public TestPlan(TestAssembly assembly) throws Error {
- + public TestPlan (TestAssembly assembly) throws Error {
- this.assembly = assembly;
- options = assembly.options;
- - var plan_name = Path.get_basename(assembly.binary.get_path());
- - if(plan_name.has_prefix("lt-"))
- - plan_name = plan_name.substring(3);
- -
- - plan = assembly.srcdir.get_child(plan_name + ".vapi");
- - if(!plan.query_exists()) {
- - plan = assembly.builddir.get_child(plan_name + ".vapi");
- - 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());
- + var plan_name = Path.get_basename (assembly.binary.get_path ());
- + if (plan_name.has_prefix ("lt-"))
- + plan_name = plan_name.substring (3);
- +
- + plan = assembly.srcdir.get_child (plan_name + ".vapi");
- + if (!plan.query_exists ()) {
- + plan = assembly.builddir.get_child (plan_name + ".vapi");
- + 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("/");
- - setup_context();
- - load_test_plan();
- + config = new TestConfig (options);
- + runner = new TestRunner ();
- + result = new TestResult (config);
- + testsuite = root = new TestSuite ("/");
- + setup_context ();
- + load_test_plan ();
- }
- - public int run() throws Error {
- - return runner.run_all(this);
- + public int run () throws Error {
- + return runner.run_all (this);
- }
- - private void setup_context() {
- + private void setup_context () {
- context = new Vala.CodeContext ();
- Vala.CodeContext.push (context);
- context.report.enable_warnings = false;
- @@ -87,198 +87,198 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- context.verbose_mode = false;
- }
- - public void load_test_plan() throws Error {
- + public void load_test_plan () throws Error {
- context.add_source_file (new Vala.SourceFile (
- - context, Vala.SourceFileType.PACKAGE, plan.get_path()));
- + context, Vala.SourceFileType.PACKAGE, plan.get_path ()));
- var parser = new Vala.Parser ();
- parser.parse (context);
- - gatherer = new TestGatherer(assembly);
- - context.accept(gatherer);
- - context.accept(this);
- + gatherer = new TestGatherer (assembly);
- + context.accept (gatherer);
- + context.accept (this);
- }
- - public override void visit_namespace(Vala.Namespace ns) {
- + public override void visit_namespace (Vala.Namespace ns) {
- if (ns.name != null) {
- - var currpath = "/" + ns.get_full_name().replace(".","/");
- - if(config.in_subprocess)
- - if(!options.running_test.has_prefix(currpath))
- + var currpath = "/" + ns.get_full_name ().replace (".","/");
- + if (config.in_subprocess)
- + if (!options.running_test.has_prefix (currpath))
- return;
- - if(currpath.last_index_of("/") == 0)
- + if (currpath.last_index_of ("/") == 0)
- testsuite = root;
- - var ts = new TestSuite(ns.name);
- - testsuite.add_test(ts);
- + var ts = new TestSuite (ns.name);
- + testsuite.add_test (ts);
- testsuite = ts;
- }
- - ns.accept_children(this);
- + ns.accept_children (this);
- }
- - public override void visit_class(Vala.Class cls) {
- + public override void visit_class (Vala.Class cls) {
- try {
- - if (is_subtype_of(cls, typeof(TestCase)) && !cls.is_abstract) {
- - unowned Constructor ctor = get_constructor(cls);
- - testcase = ctor();
- + if (is_subtype_of (cls, typeof (TestCase)) && !cls.is_abstract) {
- + unowned Constructor ctor = get_constructor (cls);
- + testcase = ctor ();
- testcase.name = cls.name;
- - testcase.label = "/%s".printf(cls.get_full_name().replace(".","/"));
- - testsuite.add_test(testcase);
- - visit_testcase(cls);
- + testcase.label = "/%s".printf (cls.get_full_name ().replace (".","/"));
- + testsuite.add_test (testcase);
- + visit_testcase (cls);
- - } else if (is_subtype_of(cls,typeof(TestSuite))) {
- - visit_testsuite(cls);
- + } else if (is_subtype_of (cls,typeof (TestSuite))) {
- + visit_testsuite (cls);
- }
- } catch (Error e) {
- - error(e.message);
- + error (e.message);
- }
- - cls.accept_children(this);
- + cls.accept_children (this);
- }
- - private bool is_subtype_of(Vala.Class cls, Type type) {
- - var t = Type.from_name(cls.get_full_name().replace(".",""));
- - if(t.is_a(type))
- + private bool is_subtype_of (Vala.Class cls, Type type) {
- + var t = Type.from_name (cls.get_full_name ().replace (".",""));
- + if (t.is_a (type))
- return true;
- return false;
- }
- - private unowned Constructor get_constructor(Vala.Class cls) throws Error {
- + private unowned Constructor get_constructor (Vala.Class cls) throws Error {
- var attr = new Vala.CCodeAttribute (cls.default_construction_method);
- - return (Constructor)assembly.get_method(attr.name);
- + return (Constructor)assembly.get_method (attr.name);
- }
- - public void visit_testcase(Vala.Class cls) {
- + public void visit_testcase (Vala.Class cls) {
- - var t = Type.from_name(cls.get_full_name().replace(".",""));
- - var p = t.parent();
- - if(p != typeof(TestCase)) {
- - var basecls = gatherer.classes.get(p);
- - if(basecls != null)
- - visit_testcase(basecls);
- + var t = Type.from_name (cls.get_full_name ().replace (".",""));
- + var p = t.parent ();
- + if (p != typeof (TestCase)) {
- + var basecls = gatherer.classes.get (p);
- + if (basecls != null)
- + visit_testcase (basecls);
- }
- - foreach(var method in cls.get_methods()) {
- + foreach (var method in cls.get_methods ()) {
- - if(config.in_subprocess)
- - if (options.running_test != "%s/%s".printf(
- + if (config.in_subprocess)
- + if (options.running_test != "%s/%s".printf (
- testcase.label, method.name))
- continue;
- - if(!is_test(method))
- + if (!is_test (method))
- continue;
- var added = false;
- - foreach(var test in testcase)
- - if(test.name == method.name)
- + foreach (var test in testcase)
- + if (test.name == method.name)
- added=true;
- - if(added)
- + if (added)
- continue;
- - var adapter = new TestAdapter(method.name, config.timeout);
- - annotate_label(adapter);
- - annotate(adapter, method);
- + var adapter = new TestAdapter (method.name, config.timeout);
- + annotate_label (adapter);
- + annotate (adapter, method);
- - if(config.in_subprocess && adapter.status != TestStatus.SKIPPED) {
- + if (config.in_subprocess && adapter.status != TestStatus.SKIPPED) {
- var attr = new Vala.CCodeAttribute (method);
- - if(method.coroutine) {
- + if (method.coroutine) {
- try {
- unowned TestPlan.AsyncTestMethod beginmethod =
- - (TestPlan.AsyncTestMethod)assembly.get_method(attr.name);
- + (TestPlan.AsyncTestMethod)assembly.get_method (attr.name);
- unowned TestPlan.AsyncTestMethodResult testmethod =
- - (TestPlan.AsyncTestMethodResult)assembly.get_method(attr.finish_real_name);
- - adapter.add_async_test(beginmethod, testmethod);
- + (TestPlan.AsyncTestMethodResult)assembly.get_method (attr.finish_real_name);
- + adapter.add_async_test (beginmethod, testmethod);
- } catch (Error e) {
- var message = e.message;
- - adapter.add_test_method(()=> {debug(message);});
- + adapter.add_test_method (()=> {debug (message);});
- }
- } else {
- try {
- TestPlan.TestMethod testmethod =
- - (TestPlan.TestMethod)assembly.get_method(attr.name);
- - adapter.add_test((owned)testmethod);
- + (TestPlan.TestMethod)assembly.get_method (attr.name);
- + adapter.add_test ((owned)testmethod);
- } catch (Error e) {
- var message = e.message;
- - adapter.add_test_method(()=> {debug(message);});
- + adapter.add_test_method (()=> {debug (message);});
- }
- }
- } else {
- - adapter.add_test_method(()=> {assert_not_reached();});
- + adapter.add_test_method (()=> {assert_not_reached ();});
- }
- - adapter.label = "%s/%s".printf(
- + adapter.label = "%s/%s".printf (
- testcase.label,
- adapter.label);
- - testcase.add_test(adapter);
- + testcase.add_test (adapter);
- }
- }
- - private void annotate_label(Test test) {
- - if(test.name.has_prefix("test_")) {
- - test.label = test.name.substring(5);
- - } else if(test.name.has_prefix("_test_")) {
- - test.label = test.name.substring(6);
- + private void annotate_label (Test test) {
- + if (test.name.has_prefix ("test_")) {
- + test.label = test.name.substring (5);
- + } else if (test.name.has_prefix ("_test_")) {
- + test.label = test.name.substring (6);
- test.status = TestStatus.SKIPPED;
- - } else if(test.name.has_prefix("todo_test_")) {
- - test.label = test.name.substring(10);
- + } else if (test.name.has_prefix ("todo_test_")) {
- + test.label = test.name.substring (10);
- test.status = TestStatus.TODO;
- } else {
- test.label = test.name;
- }
- - test.label = test.label.replace("_", " ");
- + test.label = test.label.replace ("_", " ");
- }
- - private void annotate(TestAdapter adapter, Vala.Method method) {
- + private void annotate (TestAdapter adapter, Vala.Method method) {
- - foreach(var attr in method.attributes) {
- - if(attr.name == "Test") {
- - if(attr.has_argument("name"))
- - adapter.label = attr.get_string("name");
- - if(attr.has_argument("skip")) {
- + foreach (var attr in method.attributes) {
- + if (attr.name == "Test") {
- + if (attr.has_argument ("name"))
- + adapter.label = attr.get_string ("name");
- + if (attr.has_argument ("skip")) {
- adapter.status = TestStatus.SKIPPED;
- - adapter.status_message = attr.get_string("skip");
- - } else if(attr.has_argument("todo")) {
- + adapter.status_message = attr.get_string ("skip");
- + } else if (attr.has_argument ("todo")) {
- adapter.status = TestStatus.SKIPPED;
- - adapter.status_message = attr.get_string("todo");
- - } else if(attr.has_argument("timeout")) {
- - adapter.timeout = int.parse(attr.get_string("timeout"));
- + adapter.status_message = attr.get_string ("todo");
- + } else if (attr.has_argument ("timeout")) {
- + adapter.timeout = int.parse (attr.get_string ("timeout"));
- }
- }
- }
- }
- - private bool is_test(Vala.Method method) {
- + private bool is_test (Vala.Method method) {
- bool istest = false;
- - if(method.is_virtual)
- - foreach(var test in testcase)
- - if(test.name == method.name)
- + if (method.is_virtual)
- + foreach (var test in testcase)
- + if (test.name == method.name)
- return false;
- - if (method.name.has_prefix("test_") ||
- - method.name.has_prefix("_test_") ||
- - method.name.has_prefix("todo_test_"))
- + if (method.name.has_prefix ("test_") ||
- + method.name.has_prefix ("_test_") ||
- + method.name.has_prefix ("todo_test_"))
- istest = true;
- - foreach(var attr in method.attributes)
- - if(attr.name == "Test")
- + foreach (var attr in method.attributes)
- + if (attr.name == "Test")
- istest = true;
- - if(method.has_result)
- + if (method.has_result)
- istest = false;
- - if(method.get_parameters().size > 0)
- + if (method.get_parameters ().size > 0)
- istest = false;
- return istest;
- }
- - public void visit_testsuite(Vala.Class testclass) throws Error {
- - unowned Constructor meth = get_constructor(testclass);
- - var tsuite = meth() as TestSuite;
- + public void visit_testsuite (Vala.Class testclass) throws Error {
- + unowned Constructor meth = get_constructor (testclass);
- + var tsuite = meth () as TestSuite;
- tsuite.name = testclass.name;
- - testsuite.add_test(tsuite);
- + testsuite.add_test (tsuite);
- testsuite = tsuite;
- }
- }
- diff --git a/valadate/testreport.vala b/valadate/testreport.vala
- index f5e58f6d..d6fc0bef 100644
- --- a/valadate/testreport.vala
- +++ b/valadate/testreport.vala
- @@ -53,120 +53,120 @@ public class Valadate.TestReport {
- private static Regex regex_err;
- private const string regex_err_string =
- - """(\*{2}\n([A-Z]*):([\S]*) ([\S ]*)\n)""";
- + """(\*{2}\n([A-Z]*):([\S]*)([\S ]*)\n)""";
- - public TestReport(Test test, bool subprocess) throws Error {
- + public TestReport (Test test, bool subprocess) throws Error {
- this.test = test;
- this.subprocess = subprocess;
- - if(test.status == TestStatus.NOT_RUN)
- + if (test.status == TestStatus.NOT_RUN)
- test.status = TestStatus.RUNNING;
- - if(subprocess) {
- + if (subprocess) {
- Log.set_default_handler (log_func);
- GLib.set_printerr_handler (printerr_func);
- - regex_err = new Regex(regex_err_string);
- + regex_err = new Regex (regex_err_string);
- }
- - if(test is TestSuite || test is TestCase)
- - new_testsuite();
- + if (test is TestSuite || test is TestCase)
- + new_testsuite ();
- else if (test is TestAdapter)
- - new_testcase();
- + new_testcase ();
- }
- - private void new_testsuite() throws Error {
- - if(subprocess)
- + private void new_testsuite () throws Error {
- + if (subprocess)
- return;
- - var decl = "%s<%s>%s</%s>".printf(XML_DECL, ROOT_TAG, TESTSUITE_XML, ROOT_TAG);
- - var doc = Xml.Parser.read_memory(decl, decl.length);
- - var root = doc->get_root_element()->children;
- - root->set_prop("tests", test.count.to_string());
- - root->set_prop("name",test.label);
- - xml = new XmlFile.from_doc(doc);
- + var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTSUITE_XML, ROOT_TAG);
- + var doc = Xml.Parser.read_memory (decl, decl.length);
- + var root = doc->get_root_element ()->children;
- + root->set_prop ("tests", test.count.to_string ());
- + root->set_prop ("name",test.label);
- + xml = new XmlFile.from_doc (doc);
- }
- - private void new_testcase() throws Error {
- - if(subprocess) {
- - stderr.printf("%s<%s>",XML_DECL,ROOT_TAG);
- - stderr.printf(TESTCASE_START,test.parent.get_type().name(), test.label);
- - start_time = get_monotonic_time();
- + private void new_testcase () throws Error {
- + if (subprocess) {
- + stderr.printf ("%s<%s>",XML_DECL,ROOT_TAG);
- + stderr.printf (TESTCASE_START,test.parent.get_type ().name (), test.label);
- + start_time = get_monotonic_time ();
- } else {
- - var decl = "%s<%s>%s</%s>".printf(XML_DECL, ROOT_TAG, TESTCASE_XML, ROOT_TAG);
- - var doc = Xml.Parser.read_memory(decl, decl.length);
- - var root = doc->get_root_element()->children;
- - root->set_prop("classname",((TestAdapter)test).parent.name);
- - root->set_prop("status",test.status.to_string().substring(21));
- - root->set_prop("name",test.label);
- - xml = new XmlFile.from_doc(doc);
- + var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTCASE_XML, ROOT_TAG);
- + var doc = Xml.Parser.read_memory (decl, decl.length);
- + var root = doc->get_root_element ()->children;
- + root->set_prop ("classname", ((TestAdapter)test).parent.name);
- + root->set_prop ("status",test.status.to_string ().substring (21));
- + root->set_prop ("name",test.label);
- + xml = new XmlFile.from_doc (doc);
- }
- }
- - public void add_error(string message) {
- + public void add_error (string message) {
- if (test.status != TestStatus.SKIPPED &&
- test.status != TestStatus.TODO)
- test.status = TestStatus.ERROR;
- - add_message(ERROR_TAG, message);
- + add_message (ERROR_TAG, message);
- - if(subprocess) {
- - emit_timer();
- - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- - stderr.putc(0);
- + if (subprocess) {
- + emit_timer ();
- + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- + stderr.putc (0);
- }
- - update_status();
- + update_status ();
- }
- - public void add_failure(string message) {
- + public void add_failure (string message) {
- if (test.status != TestStatus.SKIPPED &&
- test.status != TestStatus.TODO)
- test.status = TestStatus.FAILED;
- - add_message(FAILURE_TAG, message);
- + add_message (FAILURE_TAG, message);
- - if(subprocess) {
- - emit_timer();
- - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- - stderr.putc(0);
- + if (subprocess) {
- + emit_timer ();
- + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- + stderr.putc (0);
- }
- - update_status();
- + update_status ();
- }
- - public void add_skip(string message) {
- + public void add_skip (string message) {
- test.status = TestStatus.SKIPPED;
- - add_message(SKIP_TAG, message);
- - update_status();
- + add_message (SKIP_TAG, message);
- + update_status ();
- }
- - public void add_success() {
- + public void add_success () {
- if (test.status != TestStatus.SKIPPED &&
- test.status != TestStatus.TODO)
- test.status = TestStatus.PASSED;
- - if(subprocess) {
- - emit_timer();
- - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- - stderr.putc(0);
- + if (subprocess) {
- + emit_timer ();
- + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- + stderr.putc (0);
- }
- - update_status();
- + update_status ();
- }
- - private void add_message(string tag, string message) {
- - var escaped = Markup.escape_text(message);
- - if(subprocess) {
- - stderr.printf(MESSAGE_XML, tag, escaped, tag.up(), message, tag);
- + private void add_message (string tag, string message) {
- + var escaped = Markup.escape_text (message);
- + if (subprocess) {
- + stderr.printf (MESSAGE_XML, tag, escaped, tag.up (), message, tag);
- } else {
- - Xml.Node* child = new Xml.Node(null, tag);
- - child->set_content(escaped);
- + Xml.Node* child = new Xml.Node (null, tag);
- + child->set_content (escaped);
- string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
- - if(tag in tags) {
- - child->new_prop("message", escaped);
- - child->new_prop("type", tag.up());
- + if (tag in tags) {
- + child->new_prop ("message", escaped);
- + child->new_prop ("type", tag.up ());
- }
- - Xml.Node* root = xml.eval("//testcase | //testsuite")[0];
- - root->add_child(child);
- + Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
- + root->add_child (child);
- }
- }
- /**
- @@ -177,46 +177,46 @@ public class Valadate.TestReport {
- * the text will be escaped before being added.
- * @param tag The tag to use for adding the text
- */
- - public void add_text(string text, string tag) {
- - var markup = Markup.escape_text(text);
- - Xml.Node* child = new Xml.Node(null, tag);
- - child->set_content(markup);
- + public void add_text (string text, string tag) {
- + var markup = Markup.escape_text (text);
- + Xml.Node* child = new Xml.Node (null, tag);
- + child->set_content (markup);
- string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
- - if(tag in tags) {
- - child->new_prop("message", markup);
- - child->new_prop("type", tag.up());
- + if (tag in tags) {
- + child->new_prop ("message", markup);
- + child->new_prop ("type", tag.up ());
- }
- - Xml.Node* root = xml.eval("//testcase | //testsuite")[0];
- - root->add_child(child);
- + Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
- + root->add_child (child);
- }
- - public void update_status() {
- - if(test is TestAdapter && !subprocess) {
- - Xml.Node* root = xml.eval("//testcase")[0];
- - root->set_prop("status",test.status.to_string().substring(21));
- - root->set_prop("time",test.time.to_string());
- + public void update_status () {
- + if (test is TestAdapter && !subprocess) {
- + Xml.Node* root = xml.eval ("//testcase")[0];
- + root->set_prop ("status",test.status.to_string ().substring (21));
- + root->set_prop ("time",test.time.to_string ());
- }
- }
- - private static void emit_timer() {
- - end_time = get_monotonic_time();
- - var ms = "%f".printf(((double)(end_time-start_time))/1000);
- - stderr.printf(MESSAGE_XML, TIMER_TAG, ms, TIMER_TAG, ms, TIMER_TAG);
- + private static void emit_timer () {
- + end_time = get_monotonic_time ();
- + var ms = "%f".printf (((double) (end_time-start_time))/1000);
- + stderr.printf (MESSAGE_XML, TIMER_TAG, ms, TIMER_TAG, ms, TIMER_TAG);
- }
- private static void printerr_func (string? text) {
- - if(text == null)
- + if (text == null)
- return;
- MatchInfo info;
- - if(regex_err.match(text, 0, out info)) {
- - var escaped = Markup.escape_text(info.fetch(4));
- - stderr.printf(MESSAGE_XML, ERROR_TAG, escaped, ERROR_TAG, text, ERROR_TAG);
- - emit_timer();
- - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- - stderr.putc(0);
- + if (regex_err.match (text, 0, out info)) {
- + var escaped = Markup.escape_text (info.fetch (4));
- + stderr.printf (MESSAGE_XML, ERROR_TAG, escaped, ERROR_TAG, text, ERROR_TAG);
- + emit_timer ();
- + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- + stderr.putc (0);
- }
- }
- @@ -226,41 +226,41 @@ public class Valadate.TestReport {
- string? message) {
- if (((log_levels & LogLevelFlags.LEVEL_INFO) != 0) ||
- - ((log_levels & LogLevelFlags.LEVEL_MESSAGE) != 0) ||
- - ((log_levels & LogLevelFlags.LEVEL_DEBUG) != 0)) {
- - add_message(INFO_TAG, message);
- + ((log_levels & LogLevelFlags.LEVEL_MESSAGE) != 0) ||
- + ((log_levels & LogLevelFlags.LEVEL_DEBUG) != 0)) {
- + add_message (INFO_TAG, message);
- } else {
- - add_error(message);
- + add_error (message);
- }
- }
- - public void process_buffer(string buffer) throws Error {
- + public void process_buffer (string buffer) throws Error {
- - xml = new XmlFile.from_string(buffer);
- + xml = new XmlFile.from_string (buffer);
- - var bits = xml.eval("//testcase/text()");
- + var bits = xml.eval ("//testcase/text ()");
- - if(bits.size != 0) {
- + if (bits.size != 0) {
- Xml.Node* textnode = bits[0];
- - add_message(SYSTEM_ERR_TAG, textnode->get_content());
- - textnode->unlink();
- + add_message (SYSTEM_ERR_TAG, textnode->get_content ());
- + textnode->unlink ();
- }
- - var errs = xml.eval("//failure | //error");
- + var errs = xml.eval ("//failure | //error");
- if (errs.size > 0 &&
- test.status != TestStatus.SKIPPED &&
- test.status != TestStatus.TODO)
- test.status = TestStatus.FAILED;
- - bits = xml.eval("//timer");
- + bits = xml.eval ("//timer");
- Xml.Node* timer = bits[0];
- - test.time = double.parse(timer->get_content());
- - timer->unlink();
- + test.time = double.parse (timer->get_content ());
- + timer->unlink ();
- - update_status();
- + update_status ();
- }
- - public void add_stdout(string text) {
- - add_message(SYSTEM_OUT_TAG, text);
- + public void add_stdout (string text) {
- + add_message (SYSTEM_OUT_TAG, text);
- }
- }
- diff --git a/valadate/testreportprinter.vala b/valadate/testreportprinter.vala
- index 71c8ed81..2c09c2ee 100644
- --- a/valadate/testreportprinter.vala
- +++ b/valadate/testreportprinter.vala
- @@ -23,25 +23,25 @@
- public abstract class Valadate.TestReportPrinter {
- - public static TestReportPrinter @new(TestConfig config) throws Error {
- - switch(config.format) {
- + public static TestReportPrinter @new (TestConfig config) throws Error {
- + switch (config.format) {
- case "tap" :
- - return new TapTestReportPrinter(config);
- + return new TapTestReportPrinter (config);
- case "xml" :
- - return new XmlTestReportPrinter(config);
- + return new XmlTestReportPrinter (config);
- case "gnu" :
- - return new GnuTestReportPrinter(config);
- + return new GnuTestReportPrinter (config);
- default:
- - throw new TestConfigError.TEST_PRINTER("TestReportPrinter %s does not exist", config.format);
- + throw new TestConfigError.TEST_PRINTER ("TestReportPrinter %s does not exist", config.format);
- }
- }
- public TestConfig config {get; set;}
- - public TestReportPrinter(TestConfig config) throws Error {
- + public TestReportPrinter (TestConfig config) throws Error {
- this.config = config;
- }
- - public abstract void print(TestReport report);
- + public abstract void print (TestReport report);
- }
- diff --git a/valadate/testresult.vala b/valadate/testresult.vala
- index d04660d6..1dc3bdec 100644
- --- a/valadate/testresult.vala
- +++ b/valadate/testresult.vala
- @@ -25,20 +25,20 @@ public class Valadate.TestResult {
- public TestConfig config {get;set;}
- public TestReportPrinter printer {get;set;}
- - 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);
- - public TestResult(TestConfig config) throws Error {
- + public TestResult (TestConfig config) throws Error {
- this.config = config;
- - if(!config.in_subprocess)
- - printer = TestReportPrinter.new(config);
- + if (!config.in_subprocess)
- + printer = TestReportPrinter.new (config);
- }
- - public bool report() {
- - if (reports.is_empty())
- + public bool report () {
- + if (reports.is_empty ())
- return false;
- - var rpt = reports.peek_head();
- + var rpt = reports.peek_head ();
- if (rpt.test.status == TestStatus.PASSED ||
- rpt.test.status == TestStatus.SKIPPED ||
- @@ -46,91 +46,91 @@ public class Valadate.TestResult {
- rpt.test.status == TestStatus.FAILED ||
- rpt.test.status == TestStatus.ERROR) {
- - printer.print(rpt);
- - reports.pop_head();
- - report();
- + printer.print (rpt);
- + reports.pop_head ();
- + report ();
- }
- return true;
- }
- - private void update_status(Test test) {
- - var rept = tests.get(test);
- - if(rept == null)
- + private void update_status (Test test) {
- + var rept = tests.get (test);
- + if (rept == null)
- return;
- var parent = test.parent;
- - if(parent == null)
- + if (parent == null)
- return;
- TestStatus status = TestStatus.PASSED;
- - foreach(var t in parent) {
- - if(t.status == TestStatus.RUNNING)
- + foreach (var t in parent) {
- + if (t.status == TestStatus.RUNNING)
- return;
- - else if(t.status == TestStatus.ERROR)
- + else if (t.status == TestStatus.ERROR)
- status = TestStatus.ERROR;
- - else if(t.status == TestStatus.FAILED)
- + else if (t.status == TestStatus.FAILED)
- status = TestStatus.FAILED;
- }
- parent.status = status;
- - update_status(parent);
- + update_status (parent);
- }
- - public void add_test(Test test) {
- + public void add_test (Test test) {
- try {
- - reports.push_tail(new TestReport(test, config.in_subprocess));
- - tests.insert(test, reports.peek_tail());
- + reports.push_tail (new TestReport (test, config.in_subprocess));
- + tests.insert (test, reports.peek_tail ());
- } catch (Error e) {
- - error(e.message);
- + error (e.message);
- }
- }
- - public void add_error(Test test, string error) {
- - tests.get(test).add_error(error);
- - update_status(test);
- + public void add_error (Test test, string error) {
- + tests.get (test).add_error (error);
- + update_status (test);
- }
- - public void add_failure(Test test, string failure) {
- - tests.get(test).add_failure(failure);
- - update_status(test);
- + public void add_failure (Test test, string failure) {
- + tests.get (test).add_failure (failure);
- + update_status (test);
- }
- - public void add_success(Test test) {
- - tests.get(test).add_success();
- - update_status(test);
- + public void add_success (Test test) {
- + tests.get (test).add_success ();
- + update_status (test);
- }
- - public void add_skip(Test test, string message) {
- - tests.get(test).add_skip(message);
- - update_status(test);
- + public void add_skip (Test test, string message) {
- + tests.get (test).add_skip (message);
- + update_status (test);
- }
- - public void process_buffers(Test test, Assembly assembly) throws Error {
- + public void process_buffers (Test test, Assembly assembly) throws Error {
- - var rept = tests.get(test);
- - if(rept == null)
- + var rept = tests.get (test);
- + if (rept == null)
- return;
- var bis = new BufferedInputStream (assembly.stderr);
- - bis.fill(-1);
- - var xml = (string)bis.peek_buffer();
- - if(xml.length < 8)
- + bis.fill (-1);
- + var xml = (string)bis.peek_buffer ();
- + if (xml.length < 8)
- return;
- - rept.process_buffer(xml);
- + rept.process_buffer (xml);
- - update_status(test);
- + update_status (test);
- uint8 outbuffer[4096] = {};
- - assembly.stdout.read_all(outbuffer, null);
- - xml = ((string)outbuffer).strip();
- + assembly.stdout.read_all (outbuffer, null);
- + xml = ((string)outbuffer).strip ();
- int i;
- - for(i=xml.length-1;i==0;i--)
- - if(xml.get_char(i).isgraph())
- + for (i=xml.length-1;i==0;i--)
- + if (xml.get_char (i).isgraph ())
- break;
- - xml = xml.substring(0, i+1);
- - if(xml.length < 1 || xml == "\n")
- + xml = xml.substring (0, i+1);
- + if (xml.length < 1 || xml == "\n")
- return;
- - rept.add_stdout(xml);
- + rept.add_stdout (xml);
- }
- }
- diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
- index 2576cc3d..91d17fc4 100644
- --- a/valadate/testrunner.vala
- +++ b/valadate/testrunner.vala
- @@ -28,90 +28,90 @@ public class Valadate.TestRunner {
- private uint _n_ongoing_tests = 0;
- private Queue<DelegateWrapper> _pending_tests = new Queue<DelegateWrapper> ();
- - private static uint _max_n_ongoing_tests = GLib.get_num_processors();
- + private static uint _max_n_ongoing_tests = GLib.get_num_processors ();
- private MainLoop loop;
- private TestPlan plan;
- - public void run(Test test, TestResult result) {
- - result.add_test(test);
- - test.run(result);
- - result.report();
- + public void run (Test test, TestResult result) {
- + result.add_test (test);
- + test.run (result);
- + result.report ();
- }
- - public int run_all(TestPlan plan) throws Error {
- + public int run_all (TestPlan plan) throws Error {
- this.plan = plan;
- if (plan.config.list_only) {
- - list_tests(plan.root, "");
- + list_tests (plan.root, "");
- return 0;
- } else if (plan.root.count == 0) {
- return 0;
- } else if (!plan.config.in_subprocess) {
- - loop = new MainLoop();
- - Timeout.add(
- + loop = new MainLoop ();
- + Timeout.add (
- 10,
- - () => {
- - bool res = plan.result.report();
- - if(!res)
- - loop.quit();
- + () => {
- + bool res = plan.result.report ();
- + if (!res)
- + loop.quit ();
- return res;
- },
- Priority.HIGH_IDLE);
- - run_test_internal(plan.root, plan.result, "");
- - loop.run();
- + run_test_internal (plan.root, plan.result, "");
- + loop.run ();
- } else {
- - run_test_internal(plan.root, plan.result, "");
- + run_test_internal (plan.root, plan.result, "");
- }
- return 0;
- }
- - private void list_tests(Test test, string path) {
- - foreach(var subtest in test) {
- - string testpath = "%s/%s".printf(path, subtest.name);
- - if(subtest is TestAdapter)
- - stdout.printf("%s\n", testpath);
- + private void list_tests (Test test, string path) {
- + foreach (var subtest in test) {
- + string testpath = "%s/%s".printf (path, subtest.name);
- + if (subtest is TestAdapter)
- + stdout.printf ("%s\n", testpath);
- else
- - list_tests(subtest, testpath);
- + list_tests (subtest, testpath);
- }
- }
- - public void run_test(Test test, TestResult result) {
- - test.run(result);
- + public void run_test (Test test, TestResult result) {
- + test.run (result);
- }
- - private void run_test_internal(Test test, TestResult result, string path) throws Error {
- + private void run_test_internal (Test test, TestResult result, string path) throws Error {
- - foreach(var subtest in test) {
- + foreach (var subtest in test) {
- - var testpath = "%s/%s".printf(path, subtest.name);
- + var testpath = "%s/%s".printf (path, subtest.name);
- - if(subtest is TestCase) {
- - if(!plan.config.in_subprocess)
- - result.add_test(subtest);
- - run_test_internal(subtest, result, testpath);
- + if (subtest is TestCase) {
- + if (!plan.config.in_subprocess)
- + result.add_test (subtest);
- + run_test_internal (subtest, result, testpath);
- } else if (subtest is TestSuite) {
- - result.add_test(subtest);
- - run_test_internal(subtest, result, testpath);
- + result.add_test (subtest);
- + run_test_internal (subtest, result, testpath);
- } else if (plan.config.in_subprocess) {
- - if(plan.config.running_test == testpath)
- - test.run(result);
- + if (plan.config.running_test == testpath)
- + test.run (result);
- } else if (subtest is TestAdapter) {
- subtest.name = testpath;
- - result.add_test(subtest);
- - run_async.begin(subtest, result);
- + result.add_test (subtest);
- + run_async.begin (subtest, result);
- }
- }
- }
- - private async void run_async(Test test, TestResult result) throws Error
- - requires(plan.config.in_subprocess != true) {
- + private async void run_async (Test test, TestResult result) throws Error
- + requires (plan.config.in_subprocess != true) {
- var timeout = plan.config.timeout;
- - var testprog = plan.assembly.clone();
- + var testprog = plan.assembly.clone ();
- if (_n_ongoing_tests > _max_n_ongoing_tests) {
- - var wrapper = new DelegateWrapper();
- + var wrapper = new DelegateWrapper ();
- wrapper.cb = run_async.callback;
- - _pending_tests.push_tail((owned)wrapper);
- + _pending_tests.push_tail ((owned)wrapper);
- yield;
- }
- @@ -119,47 +119,47 @@ public class Valadate.TestRunner {
- _n_ongoing_tests++;
- var cancellable = new Cancellable ();
- var tcase = test as TestAdapter;
- - if(timeout != tcase.timeout)
- + if (timeout != tcase.timeout)
- timeout = tcase.timeout;
- var time = new TimeoutSource (timeout);
- cancellable.cancelled.connect (() => {
- - testprog.quit();
- + testprog.quit ();
- });
- time.set_callback (() => {
- if (tcase.status == TestStatus.RUNNING)
- - cancellable.cancel();
- + cancellable.cancel ();
- return false;
- });
- - time.attach (loop.get_context());
- + time.attach (loop.get_context ());
- - testprog.run("-r %s".printf(test.name), cancellable);
- - result.add_success(test);
- - result.process_buffers(test, testprog);
- + testprog.run ("-r %s".printf (test.name), cancellable);
- + result.add_success (test);
- + result.process_buffers (test, testprog);
- } catch (IOError e) {
- - result.add_error(test, "The test timed out after %d milliseconds".printf(timeout));
- - result.process_buffers(test, testprog);
- + result.add_error (test, "The test timed out after %d milliseconds".printf (timeout));
- + result.process_buffers (test, testprog);
- } catch (Error e) {
- - result.add_error(test, e.message);
- - result.process_buffers(test, testprog);
- + result.add_error (test, e.message);
- + result.process_buffers (test, testprog);
- } finally {
- - result.report();
- + result.report ();
- _n_ongoing_tests--;
- var wrapper = _pending_tests.pop_head ();
- - if(wrapper != null)
- - wrapper.cb();
- + if (wrapper != null)
- + wrapper.cb ();
- }
- }
- public static int main (string[] args) {
- try {
- - var assembly = new TestAssembly(args);
- - var testplan = new TestPlan(assembly);
- - return testplan.run();
- + var assembly = new TestAssembly (args);
- + var testplan = new TestPlan (assembly);
- + return testplan.run ();
- } catch (Error e) {
- - error(e.message);
- + error (e.message);
- }
- }
- diff --git a/valadate/testsuite.vala b/valadate/testsuite.vala
- index 6b0239cb..1009f661 100644
- --- a/valadate/testsuite.vala
- +++ b/valadate/testsuite.vala
- @@ -22,7 +22,7 @@
- public class Valadate.TestSuite : Object, Test {
- - private List<Test> _tests = new List<Test>();
- + private List<Test> _tests = new List<Test> ();
- /**
- * the name of the TestSuite
- */
- @@ -36,7 +36,7 @@ public class Valadate.TestSuite : Object, Test {
- */
- public int size {
- get {
- - return (int)_tests.length();
- + return (int)_tests.length ();
- }
- }
- /**
- @@ -46,7 +46,7 @@ public class Valadate.TestSuite : Object, Test {
- public int count {
- get {
- int testcount = 0;
- - _tests.foreach((t) => {
- + _tests.foreach ((t) => {
- testcount += t.count;
- });
- return testcount;
- @@ -71,41 +71,41 @@ public class Valadate.TestSuite : Object, 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) {
- + this.name = name ?? this.get_type ().name ();
- this.label = name;
- }
- /**
- * Adds a test to the suite.
- */
- - public void add_test(Test test) {
- + public void add_test (Test test) {
- test.parent = this;
- - _tests.append(test);
- + _tests.append (test);
- }
- /**
- * Runs all of the tests in the Suite
- */
- public void run (TestResult result) {
- - if(status != TestStatus.NOT_RUN)
- + if (status != TestStatus.NOT_RUN)
- return;
- - _tests.foreach((t) => {
- - t.run(result);
- + _tests.foreach ((t) => {
- + t.run (result);
- });
- }
- - public new Test get(int index) {
- - return _tests.nth_data((uint)index);
- + public new Test get (int index) {
- + return _tests.nth_data ((uint)index);
- }
- - public new void set(int index, Test test) {
- + public new void set (int index, Test test) {
- test.parent = this;
- - _tests.insert_before(_tests.nth(index), test);
- - var t = _tests.nth_data((uint)index++);
- - _tests.remove(t);
- + _tests.insert_before (_tests.nth (index), test);
- + var t = _tests.nth_data ((uint)index++);
- + _tests.remove (t);
- }
- - public virtual void set_up() {}
- - public virtual void tear_down() {}
- + public virtual void set_up () {}
- + public virtual void tear_down () {}
- }
- diff --git a/valadate/xmlfile.vala b/valadate/xmlfile.vala
- index 682f6a29..ab0a6d8c 100644
- --- a/valadate/xmlfile.vala
- +++ b/valadate/xmlfile.vala
- @@ -30,27 +30,27 @@ public class Valadate.XmlSearchResults {
- public int size {
- get {
- - if(result == null || result->type != Xml.XPath.ObjectType.NODESET || result->nodesetval == null)
- + if (result == null || result->type != Xml.XPath.ObjectType.NODESET || result->nodesetval == null)
- return 0;
- - return result->nodesetval->length();
- + return result->nodesetval->length ();
- }
- }
- - public void* get(int i)
- - requires(size > 0)
- - requires(i < size)
- - requires(i >= 0)
- + public void* get (int i)
- + requires (size > 0)
- + requires (i < size)
- + requires (i >= 0)
- {
- return result->nodesetval->item (i);
- }
- - internal XmlSearchResults(Xml.XPath.Object* result) {
- + internal XmlSearchResults (Xml.XPath.Object* result) {
- this.result = result;
- }
- - ~XmlSearchResults() {
- - if(result != null) delete result;
- + ~XmlSearchResults () {
- + if (result != null) delete result;
- }
- }
- @@ -61,49 +61,49 @@ public class Valadate.XmlFile {
- private Xml.XPath.Context context;
- private bool owns_doc = false;
- - public XmlFile(File path) throws Error {
- - this.from_doc(Xml.Parser.parse_file(path.get_path()));
- + public XmlFile (File path) throws Error {
- + this.from_doc (Xml.Parser.parse_file (path.get_path ()));
- owns_doc = true;
- }
- - internal XmlFile.from_doc(Xml.Doc* xmldoc) throws Error {
- + internal XmlFile.from_doc (Xml.Doc* xmldoc) throws Error {
- document = xmldoc;
- owns_doc = true;
- if (document == null)
- - throw new XmlFileError.ERROR(
- + throw new XmlFileError.ERROR (
- "There was an error parsing the Xml.Doc");
- - set_context();
- + set_context ();
- }
- - public XmlFile.from_string(string xml) throws Error {
- - document = Xml.Parser.read_memory(xml, xml.length, null, null,
- + public XmlFile.from_string (string xml) throws Error {
- + document = Xml.Parser.read_memory (xml, xml.length, null, null,
- Xml.ParserOption.RECOVER | Xml.ParserOption.NOERROR |
- Xml.ParserOption.NOWARNING | Xml.ParserOption.NOBLANKS);
- owns_doc = true;
- if (document == null)
- - throw new XmlFileError.ERROR(
- + throw new XmlFileError.ERROR (
- "There was an error parsing the string %s", xml);
- - set_context();
- + set_context ();
- }
- - private void set_context() {
- + private void set_context () {
- context = new Xml.XPath.Context (document);
- }
- - ~XmlFile() {
- + ~XmlFile () {
- if (owns_doc)
- delete document;
- }
- - public void register_ns(string prefix, string ns) {
- - context.register_ns(prefix, ns);
- + public void register_ns (string prefix, string ns) {
- + context.register_ns (prefix, ns);
- }
- - public XmlSearchResults eval(string expression) {
- - return new XmlSearchResults(context.eval_expression (expression));
- + public XmlSearchResults eval (string expression) {
- + return new XmlSearchResults (context.eval_expression (expression));
- }
- }
- diff --git a/valadate/xmltestreportprinter.vala b/valadate/xmltestreportprinter.vala
- index e389c7d1..47b1757a 100644
- --- a/valadate/xmltestreportprinter.vala
- +++ b/valadate/xmltestreportprinter.vala
- @@ -35,36 +35,36 @@ public class Valadate.XmlTestReportPrinter : TestReportPrinter {
- private int testcount = -1;
- private int casecount = -1;
- - public XmlTestReportPrinter(TestConfig config) throws Error {
- - base(config);
- + public XmlTestReportPrinter (TestConfig config) throws Error {
- + base (config);
- this.config = config;
- - xml = new XmlFile.from_string(XML_DECL + TESTSUITES_XML);
- + xml = new XmlFile.from_string (XML_DECL + TESTSUITES_XML);
- }
- - public override void print(TestReport report) {
- - Xml.Node* root = xml.eval("//testsuites")[0];
- - Xml.Node* node = report.xml.eval("//testsuite | //testcase")[0];
- + public override void print (TestReport report) {
- + Xml.Node* root = xml.eval ("//testsuites")[0];
- + Xml.Node* node = report.xml.eval ("//testsuite | //testcase")[0];
- - if(report.test is TestSuite) {
- - if(testsuite == null) {
- + if (report.test is TestSuite) {
- + if (testsuite == null) {
- testcount = report.test.count;
- - testsuite = root->add_child(node->copy_list());
- + testsuite = root->add_child (node->copy_list ());
- } else {
- oldtestsuite = testsuite;
- - testsuite = testsuite->add_child(node->copy_list());
- + testsuite = testsuite->add_child (node->copy_list ());
- }
- } else if (report.test is TestCase) {
- oldtestsuite = testsuite;
- - testsuite = testsuite->add_child(node->copy_list());
- + testsuite = testsuite->add_child (node->copy_list ());
- casecount = report.test.count;
- - } else if(report.test is TestAdapter) {
- - testsuite->add_child(node->copy_list());
- + } else if (report.test is TestAdapter) {
- + testsuite->add_child (node->copy_list ());
- testcount--;
- casecount--;
- - if(casecount == 0)
- + if (casecount == 0)
- testsuite = oldtestsuite;
- }
- - if(testcount == 0)
- - root->doc->dump_format(stdout);
- + if (testcount == 0)
- + root->doc->dump_format (stdout);
- }
- }
- --
- 2.11.0
- From be8dcc9e974b1787d9bdfc7aca586457ea673d6b Mon Sep 17 00:00:00 2001
- From: Rico Tzschichholz <ricotz@ubuntu.com>
- Date: Fri, 28 Apr 2017 20:13:15 +0200
- Subject: [PATCH 2/2] Trailing spaces
- ---
- tests/valatests.vala | 16 ++++++++--------
- tests/valatestsfactory.vala | 18 +++++++++---------
- valadate/assembly.vala | 8 ++++----
- valadate/assemblyerror.vala | 2 +-
- valadate/gnutestreportprinter.vala | 14 +++++++-------
- valadate/taptestreportprinter.vala | 18 +++++++++---------
- valadate/test.vala | 2 +-
- valadate/testadapter.vala | 2 +-
- valadate/testassembly.vala | 12 ++++++------
- valadate/testcase.vala | 6 +++---
- valadate/testerror.vala | 10 +++++-----
- valadate/testexplorer.vala | 6 +++---
- valadate/testgatherer.vala | 12 ++++++------
- valadate/testmodule.vala | 6 +++---
- valadate/testplan.vala | 32 ++++++++++++++++----------------
- valadate/testreport.vala | 32 ++++++++++++++++----------------
- valadate/testreportprinter.vala | 14 +++++++-------
- valadate/testresult.vala | 12 ++++++------
- valadate/testrunner.vala | 20 ++++++++++----------
- valadate/testsuite.vala | 2 +-
- valadate/xmlfile.vala | 18 +++++++++---------
- valadate/xmltestreportprinter.vala | 14 +++++++-------
- 22 files changed, 138 insertions(+), 138 deletions(-)
- diff --git a/tests/valatests.vala b/tests/valatests.vala
- index b1faf099..7a90d659 100644
- --- a/tests/valatests.vala
- +++ b/tests/valatests.vala
- @@ -1,31 +1,31 @@
- /**
- * Vala.Tests
- - *
- + *
- * Searchs all of the sub directories in the current directory for
- * *.vala or *.test files, compiles and runs them.
- - *
- + *
- * If the test is a self contained application (has its own main entry
- * point), it will compile and run it. The test is deemed succesful if
- * it compiles and runs without error.
- - *
- + *
- * If the test is a .test file it will be parsed, the components
- * assembled, compiled and run. The test is deemed succesful if
- * it compiles and runs without error.
- - *
- + *
- * The tests can be run against the system compiler or the one in the
- * source tree. This can be used to verify if a patch or other change
- * to the compiler either fixes a bug or causes a regression (or both)
- */
- public class Vala.Tests : Valadate.TestSuite {
- -
- +
- private const string BUGZILLA_URL = "http://bugzilla.gnome.org/";
- construct {
- try {
- var testdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
- var testpath = Valadate.TestOptions.get_current_test_path ();
- -
- +
- if (testpath != null) {
- var testpaths = testpath.split ("/");
- if (testpaths.length < 4)
- @@ -64,7 +64,7 @@ public class Vala.Tests : Valadate.TestSuite {
- private class ValaTest : Valadate.TestCase {
- private TestsFactory factory = TestsFactory.get_instance ();
- -
- +
- public ValaTest (File directory) throws Error {
- this.name = directory.get_basename ();
- this.label = directory.get_path ();
- @@ -99,7 +99,7 @@ public class Vala.Tests : Valadate.TestSuite {
- 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"))
- diff --git a/tests/valatestsfactory.vala b/tests/valatestsfactory.vala
- index 7021f938..3f42758d 100644
- --- a/tests/valatestsfactory.vala
- +++ b/tests/valatestsfactory.vala
- @@ -44,7 +44,7 @@ public class Vala.TestsFactory : Object {
- vapidir = File.new_for_path (usevapidir);
- else
- vapidir = buildir.get_child ("vapi");
- -
- +
- }
- private static TestsFactory instance;
- @@ -78,9 +78,9 @@ public class Vala.TestsFactory : Object {
- 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 (basename.has_suffix (".vala") || basename.has_suffix (".gs")) {
- program = compiler.compile (testdir.get_child (testname), testfile, "--main main");
- } else if (basename.has_suffix (".test")) {
- @@ -282,7 +282,7 @@ public class Vala.TestsFactory : Object {
- private const string GIRFOOTER = "\n</namespace>\n</repository>";
- - private const string VAPIHEADER =
- + private const string VAPIHEADER =
- """/* %s.vapi generated by lt-vapigen, do not modify. */
- [CCode (cprefix = "Test", gir_namespace = "Test", gir_version = "1.2", lower_case_cprefix = "test_")]
- namespace Test {""";
- @@ -359,12 +359,12 @@ public class Vala.TestsFactory : Object {
- prog.add_file (binary.get_parent ().get_child (binary.get_basename () + ".c"));
- return prog;
- }
- -
- +
- private string get_flags () throws Error {
- -
- +
- string result = "";
- string[] flags = {"CFLAGS", "CPPFLAGS", "LDFLAGS"};
- -
- +
- foreach (string key in flags) {
- var val = Environment.get_variable (key);
- if (val == null || val.length == 0)
- @@ -376,9 +376,9 @@ public class Vala.TestsFactory : Object {
- foreach (var item in args)
- result += "-X %s ".printf (item);
- }
- -
- +
- return result;
- }
- -
- +
- }
- }
- diff --git a/valadate/assembly.vala b/valadate/assembly.vala
- index b2e08093..aa48c7cf 100644
- --- a/valadate/assembly.vala
- +++ b/valadate/assembly.vala
- @@ -15,15 +15,15 @@
- * 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 abstract class Valadate.Assembly {
- protected static SubprocessLauncher launcher;
- -
- +
- private static void init_launcher () {
- if (launcher == null) {
- launcher = new SubprocessLauncher (
- @@ -35,7 +35,7 @@ public abstract class Valadate.Assembly {
- launcher.setenv ("G_SLICE","always-malloc debug-blocks",true);
- }
- }
- -
- +
- public File binary {get;set;}
- public InputStream stderr {get;set;}
- public OutputStream stdin {get;set;}
- diff --git a/valadate/assemblyerror.vala b/valadate/assemblyerror.vala
- index aa1b57e8..4c7f2f24 100644
- --- a/valadate/assemblyerror.vala
- +++ b/valadate/assemblyerror.vala
- @@ -15,7 +15,7 @@
- * 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>
- */
- diff --git a/valadate/gnutestreportprinter.vala b/valadate/gnutestreportprinter.vala
- index 2bc039a5..5de3199b 100644
- --- a/valadate/gnutestreportprinter.vala
- +++ b/valadate/gnutestreportprinter.vala
- @@ -15,20 +15,20 @@
- * 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.GnuTestReportPrinter : TestReportPrinter {
- -
- +
- private const string TAP_VERSION = "13";
- -
- +
- private List<TestCase> testcases = new List<TestCase> ();
- -
- +
- public GnuTestReportPrinter (TestConfig config) throws Error {
- base (config);
- }
- -
- +
- public override void print (TestReport report) {
- if (report.test is TestSuite) {
- @@ -39,11 +39,11 @@ public class Valadate.GnuTestReportPrinter : TestReportPrinter {
- var test = report.test as TestAdapter;
- var idx = testcases.index (test.parent as TestCase);
- int index = 1;
- -
- +
- if (idx > 0)
- for (int i=0; i<idx;i++)
- index += testcases.nth_data (i).count;
- -
- +
- for (int i=0;i<test.parent.count; i++) {
- if (test.parent[i] == test) {
- index += i;
- diff --git a/valadate/taptestreportprinter.vala b/valadate/taptestreportprinter.vala
- index 7fa2f026..92fb4273 100644
- --- a/valadate/taptestreportprinter.vala
- +++ b/valadate/taptestreportprinter.vala
- @@ -15,17 +15,17 @@
- * 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.TapTestReportPrinter : TestReportPrinter {
- -
- +
- private const string TAP_VERSION = "13";
- -
- +
- private List<TestCase> testcases = new List<TestCase> ();
- -
- +
- public TapTestReportPrinter (TestConfig config) throws Error {
- base (config);
- if (!config.list_only) {
- @@ -33,12 +33,12 @@ public class Valadate.TapTestReportPrinter : TestReportPrinter {
- stdout.printf ("# random seed: %s\n", config.seed);
- }
- }
- -
- +
- public override void print (TestReport report) {
- if (report.test is TestSuite && report.test.parent.name == "/") {
- stdout.printf ("1..%d\n", report.test.count);
- -
- +
- var props = report.xml.eval ("//properties/property");
- stdout.puts ("# Environment\n");
- foreach (Xml.Node* prop in props) {
- @@ -55,11 +55,11 @@ public class Valadate.TapTestReportPrinter : TestReportPrinter {
- var idx = testcases.index (test.parent as TestCase);
- int index = 1;
- bool lasttest = false;
- -
- +
- if (idx > 0)
- for (int i=0; i<idx;i++)
- index += testcases.nth_data (i).count;
- -
- +
- for (int i=0;i<test.parent.count; i++) {
- if (test.parent[i] == test) {
- index += i;
- diff --git a/valadate/test.vala b/valadate/test.vala
- index 310fbd65..f6350d64 100644
- --- a/valadate/test.vala
- +++ b/valadate/test.vala
- @@ -26,7 +26,7 @@
- */
- public interface Valadate.Test : Object {
- /**
- - * Runs the Tests and collects the results in a TestResult
- + * Runs the Tests and collects the results in a TestResult
- *
- * @param result the TestResult object used to store the results of the Test
- */
- diff --git a/valadate/testadapter.vala b/valadate/testadapter.vala
- index 2b5499f3..e3849f47 100644
- --- a/valadate/testadapter.vala
- +++ b/valadate/testadapter.vala
- @@ -25,7 +25,7 @@ public class Valadate.TestAdapter : Object, Test {
- public string name {get;set;}
- public string label {get;set;}
- public double time {get;set;}
- -
- +
- public int timeout {get;set;}
- public TestStatus status {get;set;default=TestStatus.NOT_RUN;}
- diff --git a/valadate/testassembly.vala b/valadate/testassembly.vala
- index 7c2f8038..18199878 100644
- --- a/valadate/testassembly.vala
- +++ b/valadate/testassembly.vala
- @@ -15,7 +15,7 @@
- * 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>
- */
- @@ -32,12 +32,12 @@ public class Valadate.TestAssembly : TestModule {
- options = new TestOptions (args);
- setup_dirs ();
- }
- -
- +
- private TestAssembly.copy (TestAssembly other) throws Error {
- base (other.binary);
- options = other.options;
- }
- -
- +
- private void setup_dirs () throws Error {
- var buildstr = Environment.get_variable ("G_TEST_BUILDDIR");
- @@ -50,7 +50,7 @@ public class Valadate.TestAssembly : TestModule {
- }
- var srcstr = Environment.get_variable ("G_TEST_SRCDIR");
- -
- +
- if (srcstr == null) {
- // we're running outside the test harness
- // check for buildir!=srcdir
- @@ -71,7 +71,7 @@ public class Valadate.TestAssembly : TestModule {
- }
- }
- }
- -
- +
- if (srcstr == null)
- srcdir = builddir;
- else
- @@ -81,7 +81,7 @@ public class Valadate.TestAssembly : TestModule {
- if (mesondir.query_exists ())
- srcdir = mesondir;
- -
- +
- Environment.set_variable ("G_TEST_BUILDDIR", builddir.get_path (), true);
- Environment.set_variable ("G_TEST_SRCDIR", srcdir.get_path (), true);
- diff --git a/valadate/testcase.vala b/valadate/testcase.vala
- index 35207ddb..713bec60 100644
- --- a/valadate/testcase.vala
- +++ b/valadate/testcase.vala
- @@ -1,4 +1,4 @@
- -/*
- +/*
- * Valadate - Unit testing library for GObject-based libraries.
- *
- * testcase.vala
- @@ -68,7 +68,7 @@ public abstract class Valadate.TestCase : Object, Test {
- public double time {get;set;}
- public string bug_base {get;set;}
- -
- +
- private List<Test> _tests = new List<Test> ();
- private Test current_test;
- @@ -97,7 +97,7 @@ public abstract class Valadate.TestCase : Object, Test {
- adapter.parent = this;
- _tests.append (adapter);
- }
- -
- +
- public virtual void run (TestResult result) {
- if (status != TestStatus.NOT_RUN)
- return;
- diff --git a/valadate/testerror.vala b/valadate/testerror.vala
- index b173f71a..8262442c 100644
- --- a/valadate/testerror.vala
- +++ b/valadate/testerror.vala
- @@ -1,23 +1,23 @@
- /*
- * Valadate - Unit testing library for GObject-based libraries.
- * Copyright 2017 Chris Daley <bizarro@localhost.localdomain>
- - *
- + *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- - *
- + *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- - *
- + *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- - *
- - *
- + *
- + *
- */
- public errordomain Valadate.TestError {
- diff --git a/valadate/testexplorer.vala b/valadate/testexplorer.vala
- index df7a0b89..e2f81d97 100644
- --- a/valadate/testexplorer.vala
- +++ b/valadate/testexplorer.vala
- @@ -45,7 +45,7 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
- testplan = testplan.substring (3);
- string testplanfile = testdir + GLib.Path.DIR_SEPARATOR_S + testplan + ".vapi";
- -
- +
- if (!FileUtils.test (testplanfile, FileTest.EXISTS))
- throw new TestConfigError.TESTPLAN ("Test Plan %s Not Found!", testplanfile);
- @@ -65,7 +65,7 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
- parser.parse (context);
- context.accept (this);
- }
- -
- +
- private void setup_context () {
- context = new Vala.CodeContext ();
- Vala.CodeContext.push (context);
- @@ -105,7 +105,7 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
- unowned Constructor meth = get_constructor (cl);
- var current_test = meth () as TestCase;
- current_test.name = cl.name;
- -
- +
- foreach (var method in cl.get_methods ()) {
- if (method.name.has_prefix ("test_") &&
- method.has_result != true &&
- diff --git a/valadate/testgatherer.vala b/valadate/testgatherer.vala
- index 67b5d0f0..e61a817a 100644
- --- a/valadate/testgatherer.vala
- +++ b/valadate/testgatherer.vala
- @@ -19,12 +19,12 @@
- * Authors:
- * Chris Daley <chebizarro@gmail.com>
- */
- -
- +
- public class Valadate.TestGatherer : Vala.CodeVisitor {
- -
- - public HashTable<Type, Vala.Class> classes =
- +
- + public HashTable<Type, Vala.Class> classes =
- new HashTable<Type, Vala.Class> (direct_hash, direct_equal);
- -
- +
- private TestAssembly assembly;
- public TestGatherer (TestAssembly assembly) {
- @@ -34,7 +34,7 @@ public class Valadate.TestGatherer : Vala.CodeVisitor {
- public override void visit_namespace (Vala.Namespace ns) {
- ns.accept_children (this);
- }
- -
- +
- public override void visit_class (Vala.Class cls) {
- try {
- var classtype = find_type (cls);
- @@ -45,7 +45,7 @@ public class Valadate.TestGatherer : Vala.CodeVisitor {
- }
- cls.accept_children (this);
- }
- -
- +
- private Type find_type (Vala.Class cls) throws Error {
- var attr = new Vala.CCodeAttribute (cls);
- unowned TestPlan.GetType node_get_type =
- diff --git a/valadate/testmodule.vala b/valadate/testmodule.vala
- index 67122cf0..a0da7bfb 100644
- --- a/valadate/testmodule.vala
- +++ b/valadate/testmodule.vala
- @@ -24,9 +24,9 @@
- * Represents a loadable module containing {@link Valadate.Test}s
- */
- public class Valadate.TestModule : Assembly {
- -
- +
- private GLib.Module module;
- -
- +
- public TestModule (File binary) throws Error {
- base (binary);
- }
- @@ -37,7 +37,7 @@ public class Valadate.TestModule : Assembly {
- throw new AssemblyError.LOAD (GLib.Module.error ());
- module.make_resident ();
- }
- -
- +
- public virtual void* get_method (string method_name) throws AssemblyError {
- if (module == null)
- load_module ();
- diff --git a/valadate/testplan.vala b/valadate/testplan.vala
- index a5dfba9b..9c32b1da 100644
- --- a/valadate/testplan.vala
- +++ b/valadate/testplan.vala
- @@ -15,11 +15,11 @@
- * 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.TestPlan : Vala.CodeVisitor {
- [CCode (has_target = false)]
- @@ -28,8 +28,8 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- public delegate void AsyncTestMethod (TestCase self, AsyncReadyCallback cb);
- public delegate void AsyncTestMethodResult (TestCase self, AsyncResult res) throws Error;
- - public delegate Type GetType ();
- -
- + public delegate Type GetType ();
- +
- public File plan {get;set;}
- public TestAssembly assembly {get;set;}
- @@ -39,14 +39,14 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- public TestConfig config {get;set;}
- public TestResult result {get;set;}
- -
- +
- public TestRunner runner {get;set;}
- public TestSuite root {get;protected set;}
- private Vala.CodeContext context;
- private TestGatherer gatherer;
- - private delegate TestCase Constructor ();
- + private delegate TestCase Constructor ();
- private TestSuite testsuite;
- private TestCase testcase;
- @@ -54,7 +54,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- this.assembly = assembly;
- options = assembly.options;
- -
- +
- var plan_name = Path.get_basename (assembly.binary.get_path ());
- if (plan_name.has_prefix ("lt-"))
- plan_name = plan_name.substring (3);
- @@ -113,7 +113,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- }
- ns.accept_children (this);
- }
- -
- +
- public override void visit_class (Vala.Class cls) {
- try {
- @@ -182,9 +182,9 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- if (method.coroutine) {
- try {
- - unowned TestPlan.AsyncTestMethod beginmethod =
- + unowned TestPlan.AsyncTestMethod beginmethod =
- (TestPlan.AsyncTestMethod)assembly.get_method (attr.name);
- - unowned TestPlan.AsyncTestMethodResult testmethod =
- + unowned TestPlan.AsyncTestMethodResult testmethod =
- (TestPlan.AsyncTestMethodResult)assembly.get_method (attr.finish_real_name);
- adapter.add_async_test (beginmethod, testmethod);
- } catch (Error e) {
- @@ -250,12 +250,12 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- private bool is_test (Vala.Method method) {
- bool istest = false;
- -
- +
- if (method.is_virtual)
- foreach (var test in testcase)
- if (test.name == method.name)
- return false;
- -
- +
- if (method.name.has_prefix ("test_") ||
- method.name.has_prefix ("_test_") ||
- method.name.has_prefix ("todo_test_"))
- @@ -267,18 +267,18 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
- if (method.has_result)
- istest = false;
- -
- +
- if (method.get_parameters ().size > 0)
- istest = false;
- -
- +
- return istest;
- }
- public void visit_testsuite (Vala.Class testclass) throws Error {
- - unowned Constructor meth = get_constructor (testclass);
- + unowned Constructor meth = get_constructor (testclass);
- var tsuite = meth () as TestSuite;
- tsuite.name = testclass.name;
- testsuite.add_test (tsuite);
- testsuite = tsuite;
- - }
- + }
- }
- diff --git a/valadate/testreport.vala b/valadate/testreport.vala
- index d6fc0bef..d54d982f 100644
- --- a/valadate/testreport.vala
- +++ b/valadate/testreport.vala
- @@ -19,7 +19,7 @@
- * Authors:
- * Chris Daley <chebizarro@gmail.com>
- */
- -
- +
- public class Valadate.TestReport {
- private const string XML_DECL ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- @@ -45,7 +45,7 @@ public class Valadate.TestReport {
- public Test test {get;set;}
- public bool subprocess {get;set;}
- -
- +
- public XmlFile xml {get;set;}
- private static int64 start_time;
- @@ -54,7 +54,7 @@ public class Valadate.TestReport {
- private static Regex regex_err;
- private const string regex_err_string =
- """(\*{2}\n([A-Z]*):([\S]*)([\S ]*)\n)""";
- -
- +
- public TestReport (Test test, bool subprocess) throws Error {
- this.test = test;
- this.subprocess = subprocess;
- @@ -73,11 +73,11 @@ public class Valadate.TestReport {
- else if (test is TestAdapter)
- new_testcase ();
- }
- -
- +
- private void new_testsuite () throws Error {
- if (subprocess)
- return;
- -
- +
- var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTSUITE_XML, ROOT_TAG);
- var doc = Xml.Parser.read_memory (decl, decl.length);
- var root = doc->get_root_element ()->children;
- @@ -123,7 +123,7 @@ public class Valadate.TestReport {
- test.status = TestStatus.FAILED;
- add_message (FAILURE_TAG, message);
- -
- +
- if (subprocess) {
- emit_timer ();
- stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
- @@ -157,14 +157,14 @@ public class Valadate.TestReport {
- } else {
- Xml.Node* child = new Xml.Node (null, tag);
- child->set_content (escaped);
- -
- +
- string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
- -
- +
- if (tag in tags) {
- child->new_prop ("message", escaped);
- child->new_prop ("type", tag.up ());
- }
- -
- +
- Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
- root->add_child (child);
- }
- @@ -172,27 +172,27 @@ public class Valadate.TestReport {
- /**
- * Adds arbitrary text to the TestReport. In the xml output this
- * text will be encapsulated in <system-out/> or <system-err/> tag
- - *
- + *
- * @param text The text to be added to the {@link TestReport}.
- * the text will be escaped before being added.
- * @param tag The tag to use for adding the text
- - */
- + */
- public void add_text (string text, string tag) {
- var markup = Markup.escape_text (text);
- Xml.Node* child = new Xml.Node (null, tag);
- child->set_content (markup);
- -
- +
- string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
- -
- +
- if (tag in tags) {
- child->new_prop ("message", markup);
- child->new_prop ("type", tag.up ());
- }
- -
- +
- Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
- root->add_child (child);
- }
- -
- +
- public void update_status () {
- if (test is TestAdapter && !subprocess) {
- Xml.Node* root = xml.eval ("//testcase")[0];
- @@ -235,7 +235,7 @@ public class Valadate.TestReport {
- }
- public void process_buffer (string buffer) throws Error {
- -
- +
- xml = new XmlFile.from_string (buffer);
- var bits = xml.eval ("//testcase/text ()");
- diff --git a/valadate/testreportprinter.vala b/valadate/testreportprinter.vala
- index 2c09c2ee..ab9015a6 100644
- --- a/valadate/testreportprinter.vala
- +++ b/valadate/testreportprinter.vala
- @@ -1,22 +1,22 @@
- /*
- * Valadate - Unit testing library for GObject-based libraries.
- * Copyright (C) 2017 Chris Daley <chebizarro@gmail.com>
- - *
- + *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- - *
- + *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- - *
- + *
- * You should have received a copy of the GNU General Public License
- * along with this program; 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>
- */
- @@ -35,13 +35,13 @@ public abstract class Valadate.TestReportPrinter {
- throw new TestConfigError.TEST_PRINTER ("TestReportPrinter %s does not exist", config.format);
- }
- }
- -
- +
- public TestConfig config {get; set;}
- -
- +
- public TestReportPrinter (TestConfig config) throws Error {
- this.config = config;
- }
- public abstract void print (TestReport report);
- -
- +
- }
- diff --git a/valadate/testresult.vala b/valadate/testresult.vala
- index 1dc3bdec..cf917112 100644
- --- a/valadate/testresult.vala
- +++ b/valadate/testresult.vala
- @@ -37,15 +37,15 @@ public class Valadate.TestResult {
- public bool report () {
- if (reports.is_empty ())
- return false;
- -
- +
- var rpt = reports.peek_head ();
- -
- +
- if (rpt.test.status == TestStatus.PASSED ||
- rpt.test.status == TestStatus.SKIPPED ||
- rpt.test.status == TestStatus.TODO ||
- rpt.test.status == TestStatus.FAILED ||
- rpt.test.status == TestStatus.ERROR) {
- -
- +
- printer.print (rpt);
- reports.pop_head ();
- report ();
- @@ -73,7 +73,7 @@ public class Valadate.TestResult {
- }
- parent.status = status;
- update_status (parent);
- - }
- + }
- public void add_test (Test test) {
- try {
- @@ -93,7 +93,7 @@ public class Valadate.TestResult {
- tests.get (test).add_failure (failure);
- update_status (test);
- }
- -
- +
- public void add_success (Test test) {
- tests.get (test).add_success ();
- update_status (test);
- @@ -105,7 +105,7 @@ public class Valadate.TestResult {
- }
- public void process_buffers (Test test, Assembly assembly) throws Error {
- -
- +
- var rept = tests.get (test);
- if (rept == null)
- return;
- diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
- index 91d17fc4..af9968b6 100644
- --- a/valadate/testrunner.vala
- +++ b/valadate/testrunner.vala
- @@ -15,7 +15,7 @@
- * 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>
- */
- @@ -31,7 +31,7 @@ public class Valadate.TestRunner {
- private static uint _max_n_ongoing_tests = GLib.get_num_processors ();
- private MainLoop loop;
- private TestPlan plan;
- -
- +
- public void run (Test test, TestResult result) {
- result.add_test (test);
- test.run (result);
- @@ -40,7 +40,7 @@ public class Valadate.TestRunner {
- public int run_all (TestPlan plan) throws Error {
- this.plan = plan;
- -
- +
- if (plan.config.list_only) {
- list_tests (plan.root, "");
- return 0;
- @@ -55,7 +55,7 @@ public class Valadate.TestRunner {
- if (!res)
- loop.quit ();
- return res;
- -
- +
- },
- Priority.HIGH_IDLE);
- run_test_internal (plan.root, plan.result, "");
- @@ -65,7 +65,7 @@ public class Valadate.TestRunner {
- }
- return 0;
- }
- -
- +
- private void list_tests (Test test, string path) {
- foreach (var subtest in test) {
- string testpath = "%s/%s".printf (path, subtest.name);
- @@ -114,16 +114,16 @@ public class Valadate.TestRunner {
- _pending_tests.push_tail ((owned)wrapper);
- yield;
- }
- -
- +
- try {
- _n_ongoing_tests++;
- var cancellable = new Cancellable ();
- var tcase = test as TestAdapter;
- if (timeout != tcase.timeout)
- timeout = tcase.timeout;
- -
- +
- var time = new TimeoutSource (timeout);
- -
- +
- cancellable.cancelled.connect (() => {
- testprog.quit ();
- });
- @@ -152,7 +152,7 @@ public class Valadate.TestRunner {
- wrapper.cb ();
- }
- }
- -
- +
- public static int main (string[] args) {
- try {
- var assembly = new TestAssembly (args);
- @@ -162,5 +162,5 @@ public class Valadate.TestRunner {
- error (e.message);
- }
- }
- -
- +
- }
- diff --git a/valadate/testsuite.vala b/valadate/testsuite.vala
- index 1009f661..bb4541e3 100644
- --- a/valadate/testsuite.vala
- +++ b/valadate/testsuite.vala
- @@ -40,7 +40,7 @@ public class Valadate.TestSuite : Object, Test {
- }
- }
- /**
- - * Returns the number of {@link Valadate.Test}s that will be run by
- + * Returns the number of {@link Valadate.Test}s that will be run by
- * this TestSuite
- */
- public int count {
- diff --git a/valadate/xmlfile.vala b/valadate/xmlfile.vala
- index ab0a6d8c..28bb3f77 100644
- --- a/valadate/xmlfile.vala
- +++ b/valadate/xmlfile.vala
- @@ -1,17 +1,17 @@
- /*
- * Valadate - Unit testing library for GObject-based libraries.
- * Copyright 2016 Chris Daley <chebizarro@gmail.com>
- - *
- + *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- - *
- + *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- - *
- + *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- @@ -25,7 +25,7 @@ public errordomain Valadate.XmlFileError {
- }
- public class Valadate.XmlSearchResults {
- -
- +
- private Xml.XPath.Object* result;
- public int size {
- @@ -43,8 +43,8 @@ public class Valadate.XmlSearchResults {
- {
- return result->nodesetval->item (i);
- }
- -
- -
- +
- +
- internal XmlSearchResults (Xml.XPath.Object* result) {
- this.result = result;
- }
- @@ -56,11 +56,11 @@ public class Valadate.XmlSearchResults {
- }
- public class Valadate.XmlFile {
- -
- +
- private Xml.Doc* document;
- private Xml.XPath.Context context;
- private bool owns_doc = false;
- -
- +
- public XmlFile (File path) throws Error {
- this.from_doc (Xml.Parser.parse_file (path.get_path ()));
- owns_doc = true;
- @@ -105,5 +105,5 @@ public class Valadate.XmlFile {
- public XmlSearchResults eval (string expression) {
- return new XmlSearchResults (context.eval_expression (expression));
- }
- -
- +
- }
- diff --git a/valadate/xmltestreportprinter.vala b/valadate/xmltestreportprinter.vala
- index 47b1757a..dc6e7540 100644
- --- a/valadate/xmltestreportprinter.vala
- +++ b/valadate/xmltestreportprinter.vala
- @@ -1,33 +1,33 @@
- /*
- * Valadate - Unit testing library for GObject-based libraries.
- * Copyright (C) 2017 Chris Daley <chebizarro@gmail.com>
- - *
- + *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- - *
- + *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- - *
- + *
- * You should have received a copy of the GNU General Public License
- * along with this program; 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.XmlTestReportPrinter : TestReportPrinter {
- -
- +
- private const string XML_DECL ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- private const string TESTSUITES_XML =
- """<testsuites disabled="" errors="" failures="" name="" """ +
- """tests="" time=""></testsuites>""";
- -
- +
- public XmlFile xml {get;set;}
- private Xml.Node* testsuite;
- @@ -63,7 +63,7 @@ public class Valadate.XmlTestReportPrinter : TestReportPrinter {
- casecount--;
- if (casecount == 0)
- testsuite = oldtestsuite;
- - }
- + }
- if (testcount == 0)
- root->doc->dump_format (stdout);
- }
- --
- 2.11.0
Add Comment
Please, Sign In to add comment