Guest User

Untitled

a guest
Apr 28th, 2017
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 112.32 KB | None | 0 0
  1. From 5fb758a8eddeabb925af4c7f1316ba4b718113a8 Mon Sep 17 00:00:00 2001
  2. From: Rico Tzschichholz <ricotz@ubuntu.com>
  3. Date: Fri, 28 Apr 2017 20:12:06 +0200
  4. Subject: [PATCH 1/2] Space before (
  5.  
  6. ---
  7. tests/valatests.vala | 34 +++---
  8. tests/valatestsfactory.vala | 46 ++++----
  9. valadate/assembly.vala | 46 ++++----
  10. valadate/gnutestreportprinter.vala | 46 ++++----
  11. valadate/taptestreportprinter.vala | 92 +++++++--------
  12. valadate/test.vala | 4 +-
  13. valadate/testadapter.vala | 44 +++----
  14. valadate/testassembly.vala | 64 +++++-----
  15. valadate/testcase.vala | 54 ++++-----
  16. valadate/testconfig.vala | 2 +-
  17. valadate/testgatherer.vala | 28 ++---
  18. valadate/testmodule.vala | 26 ++---
  19. valadate/testoptions.vala | 16 +--
  20. valadate/testplan.vala | 234 ++++++++++++++++++-------------------
  21. valadate/testreport.vala | 208 ++++++++++++++++-----------------
  22. valadate/testreportprinter.vala | 16 +--
  23. valadate/testresult.vala | 102 ++++++++--------
  24. valadate/testrunner.vala | 120 +++++++++----------
  25. valadate/testsuite.vala | 36 +++---
  26. valadate/xmlfile.vala | 48 ++++----
  27. valadate/xmltestreportprinter.vala | 32 ++---
  28. 21 files changed, 649 insertions(+), 649 deletions(-)
  29.  
  30. diff --git a/tests/valatests.vala b/tests/valatests.vala
  31. index 9e4cbd22..b1faf099 100644
  32. --- a/tests/valatests.vala
  33. +++ b/tests/valatests.vala
  34. @@ -23,7 +23,7 @@ public class Vala.Tests : Valadate.TestSuite {
  35.  
  36. construct {
  37. try {
  38. - var testdir = File.new_for_path (GLib.Environment.get_variable("G_TEST_BUILDDIR"));
  39. + var testdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
  40. var testpath = Valadate.TestOptions.get_current_test_path ();
  41.  
  42. if (testpath != null) {
  43. @@ -35,26 +35,26 @@ public class Vala.Tests : Valadate.TestSuite {
  44. add_test (new ValaTest (runtest));
  45. } else {
  46. var tempdir = testdir.get_child (".tests");
  47. - if (tempdir.query_exists()) {
  48. + if (tempdir.query_exists ()) {
  49. var enumerator = tempdir.enumerate_children (FileAttribute.STANDARD_NAME, 0);
  50. FileInfo file_info;
  51. while ((file_info = enumerator.next_file ()) != null) {
  52. - var filename = file_info.get_name();
  53. - if(filename == "." || filename == "..")
  54. + var filename = file_info.get_name ();
  55. + if (filename == "." || filename == "..")
  56. continue;
  57. - var tfile = tempdir.get_child(file_info.get_name());
  58. - tfile.delete();
  59. + var tfile = tempdir.get_child (file_info.get_name ());
  60. + tfile.delete ();
  61. }
  62. } else {
  63. - tempdir.make_directory();
  64. + tempdir.make_directory ();
  65. }
  66.  
  67. var enumerator = testdir.enumerate_children (FileAttribute.STANDARD_NAME, 0);
  68. FileInfo file_info;
  69. while ((file_info = enumerator.next_file ()) != null)
  70. - if (file_info.get_file_type() == GLib.FileType.DIRECTORY &&
  71. - !file_info.get_name().has_prefix("."))
  72. - add_test (new ValaTest (testdir.get_child(file_info.get_name())));
  73. + if (file_info.get_file_type () == GLib.FileType.DIRECTORY &&
  74. + !file_info.get_name ().has_prefix ("."))
  75. + add_test (new ValaTest (testdir.get_child (file_info.get_name ())));
  76. }
  77. } catch (Error e) {
  78. stderr.printf ("Error: %s\n", e.message);
  79. @@ -70,7 +70,7 @@ public class Vala.Tests : Valadate.TestSuite {
  80. this.label = directory.get_path ();
  81. this.bug_base = BUGZILLA_URL;
  82.  
  83. - string current_test = Valadate.TestOptions.get_current_test_path();
  84. + string current_test = Valadate.TestOptions.get_current_test_path ();
  85.  
  86. if (current_test != null) {
  87. var basename = Path.get_basename (current_test);
  88. @@ -95,15 +95,15 @@ public class Vala.Tests : Valadate.TestSuite {
  89. string basename = testfile.get_basename ();
  90. string testname = basename.substring (0, basename.last_index_of ("."));
  91.  
  92. - var adapter = new Valadate.TestAdapter(testname, 1000);
  93. - adapter.label = "/Vala/Tests/%s/%s".printf(
  94. - Path.get_basename(testfile.get_parent().get_path()),
  95. + var adapter = new Valadate.TestAdapter (testname, 1000);
  96. + adapter.label = "/Vala/Tests/%s/%s".printf (
  97. + Path.get_basename (testfile.get_parent ().get_path ()),
  98. testname);
  99.  
  100. - adapter.add_test_method(() => {
  101. + adapter.add_test_method (() => {
  102. try {
  103. if (testname.has_prefix ("bug"))
  104. - bug (testname.substring(3));
  105. + bug (testname.substring (3));
  106. var prog = factory.get_test_program (testfile);
  107. prog.run ();
  108. factory.cleanup ();
  109. @@ -112,7 +112,7 @@ public class Vala.Tests : Valadate.TestSuite {
  110. }
  111. });
  112.  
  113. - add_test(adapter);
  114. + add_test (adapter);
  115. }
  116. }
  117. }
  118. diff --git a/tests/valatestsfactory.vala b/tests/valatestsfactory.vala
  119. index 090cb912..7021f938 100644
  120. --- a/tests/valatestsfactory.vala
  121. +++ b/tests/valatestsfactory.vala
  122. @@ -29,18 +29,18 @@ public class Vala.TestsFactory : Object {
  123. static File vapidir;
  124.  
  125. class construct {
  126. - currdir = File.new_for_path (GLib.Environment.get_variable("G_TEST_BUILDDIR"));
  127. + currdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
  128. testdir = currdir.get_child (".tests");
  129. buildir = currdir.get_parent ();
  130.  
  131. var usevalac = Environment.get_variable ("VALAC");
  132. - if (usevalac != null && File.new_for_path(usevalac).query_exists())
  133. - valac = File.new_for_path(usevalac);
  134. + if (usevalac != null && File.new_for_path (usevalac).query_exists ())
  135. + valac = File.new_for_path (usevalac);
  136. else
  137. - valac = buildir.get_child("compiler").get_child("valac");
  138. + valac = buildir.get_child ("compiler").get_child ("valac");
  139.  
  140. var usevapidir = Environment.get_variable ("VAPIDIR");
  141. - if (usevapidir != null && File.new_for_path (usevapidir).query_exists())
  142. + if (usevapidir != null && File.new_for_path (usevapidir).query_exists ())
  143. vapidir = File.new_for_path (usevapidir);
  144. else
  145. vapidir = buildir.get_child ("vapi");
  146. @@ -49,7 +49,7 @@ public class Vala.TestsFactory : Object {
  147.  
  148. private static TestsFactory instance;
  149.  
  150. - public static unowned TestsFactory get_instance() {
  151. + public static unowned TestsFactory get_instance () {
  152. if (instance == null)
  153. instance = new TestsFactory ();
  154. return instance;
  155. @@ -165,7 +165,7 @@ public class Vala.TestsFactory : Object {
  156. }
  157. }
  158.  
  159. - public virtual void cleanup() throws Error {
  160. + public virtual void cleanup () throws Error {
  161. foreach (unowned File file in files)
  162. if (file.query_exists ())
  163. file.delete ();
  164. @@ -210,7 +210,7 @@ public class Vala.TestsFactory : Object {
  165. public DBusTest (string testname, string packages, DataInputStream stream) throws Error {
  166. Object (program : testdir.get_child (testname + ".server"));
  167.  
  168. - var factory = TestsFactory.get_instance();
  169. + var factory = TestsFactory.get_instance ();
  170. var clientfile = testdir.get_child (testname + ".client.vala");
  171. var serverfile = testdir.get_child (testname + ".server.vala");
  172. add_file_from_stream (clientfile, stream, "Program: client", "Program: server");
  173. @@ -242,7 +242,7 @@ public class Vala.TestsFactory : Object {
  174. public InvalidCode (string testname, string packages, DataInputStream stream) throws Error {
  175. Object (program : testdir.get_child (testname));
  176. this.packages = packages;
  177. - source = testdir.get_child(testname + ".vala");
  178. + source = testdir.get_child (testname + ".vala");
  179. add_file_from_stream (source, stream, null, null);
  180. compiler = new ValaCompiler (valac);
  181. compiler.callback = new_callback;
  182. @@ -259,9 +259,9 @@ public class Vala.TestsFactory : Object {
  183. testprogam = compiler.compile (program, source, packages);
  184. }
  185.  
  186. - public override void cleanup() throws Error {
  187. - testprogam.cleanup();
  188. - base.cleanup();
  189. + public override void cleanup () throws Error {
  190. + testprogam.cleanup ();
  191. + base.cleanup ();
  192. }
  193. }
  194.  
  195. @@ -291,11 +291,11 @@ public class Vala.TestsFactory : Object {
  196. private File vapifile;
  197.  
  198. public GIRTestProgram (string testname, string packages, DataInputStream stream) throws Error {
  199. - Object (program : testdir.get_child(testname + ".gir"));
  200. + Object (program : testdir.get_child (testname + ".gir"));
  201. this.testname = testname;
  202. add_file_from_stream (program, stream, "Input:", "Output:", GIRHEADER, GIRFOOTER);
  203. vapifile = testdir.get_child (testname + ".vapi.ref");
  204. - add_file_from_stream (vapifile, stream, null, null, VAPIHEADER.printf(testname), "\n}\n");
  205. + add_file_from_stream (vapifile, stream, null, null, VAPIHEADER.printf (testname), "\n}\n");
  206. }
  207.  
  208. public override void run (string? command = null) throws Error {
  209. @@ -308,8 +308,8 @@ public class Vala.TestsFactory : Object {
  210. }
  211.  
  212. public class Diff : Program {
  213. - public Diff() {
  214. - Object (program : File.new_for_path(Environment.find_program_in_path ("diff")));
  215. + public Diff () {
  216. + Object (program : File.new_for_path (Environment.find_program_in_path ("diff")));
  217. }
  218. }
  219.  
  220. @@ -351,30 +351,30 @@ public class Vala.TestsFactory : Object {
  221. string command = "--vapidir %s %s %s %s -o %s %s".printf (
  222. vapidir.get_path (),
  223. VALA_FLAGS,
  224. - get_flags(),
  225. + get_flags (),
  226. parameters ?? "", binary.get_path (),
  227. sourcefile.get_path ());
  228. run (command);
  229. var prog = new TestProgram (binary);
  230. - prog.add_file (binary.get_parent().get_child (binary.get_basename () + ".c"));
  231. + prog.add_file (binary.get_parent ().get_child (binary.get_basename () + ".c"));
  232. return prog;
  233. }
  234.  
  235. - private string get_flags() throws Error {
  236. + private string get_flags () throws Error {
  237.  
  238. string result = "";
  239. string[] flags = {"CFLAGS", "CPPFLAGS", "LDFLAGS"};
  240.  
  241. - foreach(string key in flags) {
  242. + foreach (string key in flags) {
  243. var val = Environment.get_variable (key);
  244. - if(val == null || val.length == 0)
  245. + if (val == null || val.length == 0)
  246. continue;
  247.  
  248. string[] args;
  249. - Shell.parse_argv(val, out args);
  250. + Shell.parse_argv (val, out args);
  251.  
  252. foreach (var item in args)
  253. - result += "-X %s ".printf(item);
  254. + result += "-X %s ".printf (item);
  255. }
  256.  
  257. return result;
  258. diff --git a/valadate/assembly.vala b/valadate/assembly.vala
  259. index 8536460d..b2e08093 100644
  260. --- a/valadate/assembly.vala
  261. +++ b/valadate/assembly.vala
  262. @@ -24,15 +24,15 @@ public abstract class Valadate.Assembly {
  263.  
  264. protected static SubprocessLauncher launcher;
  265.  
  266. - private static void init_launcher() {
  267. + private static void init_launcher () {
  268. if (launcher == null) {
  269. - launcher = new SubprocessLauncher(
  270. + launcher = new SubprocessLauncher (
  271. GLib.SubprocessFlags.STDIN_PIPE |
  272. GLib.SubprocessFlags.STDOUT_PIPE |
  273. GLib.SubprocessFlags.STDERR_PIPE);
  274. - launcher.setenv("G_MESSAGES_DEBUG","all",true);
  275. - launcher.setenv("G_DEBUG","fatal-criticals fatal-warnings gc-friendly",true);
  276. - launcher.setenv("G_SLICE","always-malloc debug-blocks",true);
  277. + launcher.setenv ("G_MESSAGES_DEBUG","all",true);
  278. + launcher.setenv ("G_DEBUG","fatal-criticals fatal-warnings gc-friendly",true);
  279. + launcher.setenv ("G_SLICE","always-malloc debug-blocks",true);
  280. }
  281. }
  282.  
  283. @@ -43,31 +43,31 @@ public abstract class Valadate.Assembly {
  284.  
  285. protected Subprocess process;
  286.  
  287. - public Assembly(File binary) throws Error {
  288. - init_launcher();
  289. - if(!binary.query_exists())
  290. - throw new FileError.NOENT("The file %s does not exist", binary.get_path());
  291. - if(!GLib.FileUtils.test(binary.get_path(), FileTest.IS_EXECUTABLE))
  292. - throw new FileError.PERM("The file %s is not executable", binary.get_path());
  293. + public Assembly (File binary) throws Error {
  294. + init_launcher ();
  295. + if (!binary.query_exists ())
  296. + throw new FileError.NOENT ("The file %s does not exist", binary.get_path ());
  297. + if (!GLib.FileUtils.test (binary.get_path (), FileTest.IS_EXECUTABLE))
  298. + throw new FileError.PERM ("The file %s is not executable", binary.get_path ());
  299. this.binary = binary;
  300. }
  301.  
  302. - public abstract Assembly clone() throws Error;
  303. + public abstract Assembly clone () throws Error;
  304.  
  305. - public virtual Assembly run(string? command = null, Cancellable? cancellable = null) throws Error {
  306. + public virtual Assembly run (string? command = null, Cancellable? cancellable = null) throws Error {
  307. string[] args;
  308. - Shell.parse_argv("%s %s".printf(binary.get_path(), command ?? ""), out args);
  309. - process = launcher.spawnv(args);
  310. - stdout = new DataInputStream (process.get_stdout_pipe());
  311. - stderr = new DataInputStream (process.get_stderr_pipe());
  312. - stdin = new DataOutputStream (process.get_stdin_pipe());
  313. - process.wait_check(cancellable);
  314. - cancellable.set_error_if_cancelled();
  315. + Shell.parse_argv ("%s %s".printf (binary.get_path (), command ?? ""), out args);
  316. + process = launcher.spawnv (args);
  317. + stdout = new DataInputStream (process.get_stdout_pipe ());
  318. + stderr = new DataInputStream (process.get_stderr_pipe ());
  319. + stdin = new DataOutputStream (process.get_stdin_pipe ());
  320. + process.wait_check (cancellable);
  321. + cancellable.set_error_if_cancelled ();
  322. return this;
  323. }
  324.  
  325. - public virtual void quit() {
  326. - if(process != null)
  327. - process.force_exit();
  328. + public virtual void quit () {
  329. + if (process != null)
  330. + process.force_exit ();
  331. }
  332. }
  333. diff --git a/valadate/gnutestreportprinter.vala b/valadate/gnutestreportprinter.vala
  334. index 87ce5e53..2bc039a5 100644
  335. --- a/valadate/gnutestreportprinter.vala
  336. +++ b/valadate/gnutestreportprinter.vala
  337. @@ -23,53 +23,53 @@ public class Valadate.GnuTestReportPrinter : TestReportPrinter {
  338.  
  339. private const string TAP_VERSION = "13";
  340.  
  341. - private List<TestCase> testcases = new List<TestCase>();
  342. + private List<TestCase> testcases = new List<TestCase> ();
  343.  
  344. - public GnuTestReportPrinter(TestConfig config) throws Error {
  345. - base(config);
  346. + public GnuTestReportPrinter (TestConfig config) throws Error {
  347. + base (config);
  348. }
  349.  
  350. - public override void print(TestReport report) {
  351. + public override void print (TestReport report) {
  352.  
  353. - if(report.test is TestSuite) {
  354. - testcases = new List<TestCase>();
  355. - } else if(report.test is TestCase) {
  356. - testcases.append(report.test as TestCase);
  357. - } else if(report.test is TestAdapter) {
  358. + if (report.test is TestSuite) {
  359. + testcases = new List<TestCase> ();
  360. + } else if (report.test is TestCase) {
  361. + testcases.append (report.test as TestCase);
  362. + } else if (report.test is TestAdapter) {
  363. var test = report.test as TestAdapter;
  364. - var idx = testcases.index(test.parent as TestCase);
  365. + var idx = testcases.index (test.parent as TestCase);
  366. int index = 1;
  367.  
  368. - if(idx > 0)
  369. - for(int i=0; i<idx;i++)
  370. - index += testcases.nth_data(i).count;
  371. + if (idx > 0)
  372. + for (int i=0; i<idx;i++)
  373. + index += testcases.nth_data (i).count;
  374.  
  375. - for(int i=0;i<test.parent.count; i++) {
  376. - if(test.parent[i] == test) {
  377. + for (int i=0;i<test.parent.count; i++) {
  378. + if (test.parent[i] == test) {
  379. index += i;
  380. }
  381. }
  382.  
  383. - switch(report.test.status) {
  384. + switch (report.test.status) {
  385. case TestStatus.PASSED:
  386. - stdout.printf("PASS: %s %d - %s\n", test.parent.name, index, test.name);
  387. + stdout.printf ("PASS: %s %d - %s\n", test.parent.name, index, test.name);
  388. break;
  389. case TestStatus.SKIPPED:
  390. - stdout.printf("SKIP: %s %d - %s # SKIP %s \n",
  391. + stdout.printf ("SKIP: %s %d - %s # SKIP %s \n",
  392. test.parent.name, index, test.label, test.status_message ?? "");
  393. break;
  394. case TestStatus.TODO:
  395. - var errs = report.xml.eval("//failure | //error");
  396. - if(errs.size > 0)
  397. - stdout.printf("XFAIL: %s %d - %s # TODO %s \n",
  398. + var errs = report.xml.eval ("//failure | //error");
  399. + if (errs.size > 0)
  400. + stdout.printf ("XFAIL: %s %d - %s # TODO %s \n",
  401. test.parent.name, index, test.label, test.status_message ?? "");
  402. else
  403. - stdout.printf("PASS: %s %d - %s # TODO %s \n",
  404. + stdout.printf ("PASS: %s %d - %s # TODO %s \n",
  405. test.parent.name, index, test.label, test.status_message ?? "");
  406. break;
  407. case TestStatus.FAILED:
  408. case TestStatus.ERROR:
  409. - stdout.printf("FAIL: %s %d - %s\n", test.parent.name, index, test.label);
  410. + stdout.printf ("FAIL: %s %d - %s\n", test.parent.name, index, test.label);
  411. break;
  412. default:
  413. break;
  414. diff --git a/valadate/taptestreportprinter.vala b/valadate/taptestreportprinter.vala
  415. index c1f9d777..7fa2f026 100644
  416. --- a/valadate/taptestreportprinter.vala
  417. +++ b/valadate/taptestreportprinter.vala
  418. @@ -24,85 +24,85 @@ public class Valadate.TapTestReportPrinter : TestReportPrinter {
  419.  
  420. private const string TAP_VERSION = "13";
  421.  
  422. - private List<TestCase> testcases = new List<TestCase>();
  423. + private List<TestCase> testcases = new List<TestCase> ();
  424.  
  425. - public TapTestReportPrinter(TestConfig config) throws Error {
  426. - base(config);
  427. - if(!config.list_only) {
  428. - stdout.printf("TAP version %s\n", TAP_VERSION);
  429. - stdout.printf("# random seed: %s\n", config.seed);
  430. + public TapTestReportPrinter (TestConfig config) throws Error {
  431. + base (config);
  432. + if (!config.list_only) {
  433. + stdout.printf ("TAP version %s\n", TAP_VERSION);
  434. + stdout.printf ("# random seed: %s\n", config.seed);
  435. }
  436. }
  437.  
  438. - public override void print(TestReport report) {
  439. + public override void print (TestReport report) {
  440.  
  441. - if(report.test is TestSuite && report.test.parent.name == "/") {
  442. - stdout.printf("1..%d\n", report.test.count);
  443. + if (report.test is TestSuite && report.test.parent.name == "/") {
  444. + stdout.printf ("1..%d\n", report.test.count);
  445.  
  446. - var props = report.xml.eval("//properties/property");
  447. - stdout.puts("# Environment\n");
  448. - foreach(Xml.Node* prop in props) {
  449. - stdout.printf("# %s : %s\n",
  450. - prop->get_prop("name"), prop->get_prop("value"));
  451. + var props = report.xml.eval ("//properties/property");
  452. + stdout.puts ("# Environment\n");
  453. + foreach (Xml.Node* prop in props) {
  454. + stdout.printf ("# %s : %s\n",
  455. + prop->get_prop ("name"), prop->get_prop ("value"));
  456. }
  457.  
  458. - } else if(report.test is TestCase) {
  459. - testcases.append(report.test as TestCase);
  460. - stdout.printf("# Start of %s tests\n", report.test.label);
  461. + } else if (report.test is TestCase) {
  462. + testcases.append (report.test as TestCase);
  463. + stdout.printf ("# Start of %s tests\n", report.test.label);
  464.  
  465. - } else if(report.test is TestAdapter) {
  466. + } else if (report.test is TestAdapter) {
  467. var test = report.test as TestAdapter;
  468. - var idx = testcases.index(test.parent as TestCase);
  469. + var idx = testcases.index (test.parent as TestCase);
  470. int index = 1;
  471. bool lasttest = false;
  472.  
  473. - if(idx > 0)
  474. - for(int i=0; i<idx;i++)
  475. - index += testcases.nth_data(i).count;
  476. + if (idx > 0)
  477. + for (int i=0; i<idx;i++)
  478. + index += testcases.nth_data (i).count;
  479.  
  480. - for(int i=0;i<test.parent.count; i++) {
  481. - if(test.parent[i] == test) {
  482. + for (int i=0;i<test.parent.count; i++) {
  483. + if (test.parent[i] == test) {
  484. index += i;
  485. lasttest = (i == test.parent.count-1);
  486. }
  487. }
  488.  
  489. - switch(report.test.status) {
  490. + switch (report.test.status) {
  491. case TestStatus.PASSED:
  492. - stdout.printf("ok %d - %s\n", index, test.label);
  493. + stdout.printf ("ok %d - %s\n", index, test.label);
  494. break;
  495. case TestStatus.SKIPPED:
  496. - stdout.printf("ok %d - %s # SKIP %s \n", index, test.label, test.status_message ?? "Skipping");
  497. + stdout.printf ("ok %d - %s # SKIP %s \n", index, test.label, test.status_message ?? "Skipping");
  498. break;
  499. case TestStatus.TODO:
  500. - var errs = report.xml.eval("//failure | //error");
  501. - if(errs.size > 0)
  502. - stdout.printf("not ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
  503. + var errs = report.xml.eval ("//failure | //error");
  504. + if (errs.size > 0)
  505. + stdout.printf ("not ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
  506. else
  507. - stdout.printf("ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
  508. + stdout.printf ("ok %d - %s # TODO %s \n", index, test.label, test.status_message ?? "Todo");
  509. break;
  510. case TestStatus.FAILED:
  511. case TestStatus.ERROR:
  512. - stdout.printf("not ok %d - %s\n", index, test.label);
  513. + stdout.printf ("not ok %d - %s\n", index, test.label);
  514. break;
  515. default:
  516. - stdout.printf("Bail out! %s\n", "There was an unexpected error");
  517. + stdout.printf ("Bail out! %s\n", "There was an unexpected error");
  518. break;
  519. }
  520. - stdout.puts(" ---\n");
  521. - stdout.printf(" duration_ms: %.4f\n", test.time);
  522. - var messages = report.xml.eval("//failure | //error | //info");
  523. - foreach(Xml.Node* mess in messages) {
  524. - stdout.printf(" message: >\n %s\n", mess->get_prop("message"));
  525. - stdout.printf(" severity: %s\n", mess->name);
  526. + stdout.puts (" ---\n");
  527. + stdout.printf (" duration_ms: %.4f\n", test.time);
  528. + var messages = report.xml.eval ("//failure | //error | //info");
  529. + foreach (Xml.Node* mess in messages) {
  530. + stdout.printf (" message: >\n %s\n", mess->get_prop ("message"));
  531. + stdout.printf (" severity: %s\n", mess->name);
  532. }
  533. - stdout.puts(" ...\n");
  534. - messages = report.xml.eval("//system-out | //system-err");
  535. - foreach(Xml.Node* mess in messages)
  536. - stdout.printf("# %s\n", string.joinv("\n# ", mess->get_content().split("\n")));
  537. - if(lasttest)
  538. - stdout.printf("# End of %s tests\n", test.parent.label);
  539. - stdout.flush();
  540. + stdout.puts (" ...\n");
  541. + messages = report.xml.eval ("//system-out | //system-err");
  542. + foreach (Xml.Node* mess in messages)
  543. + stdout.printf ("# %s\n", string.joinv ("\n# ", mess->get_content ().split ("\n")));
  544. + if (lasttest)
  545. + stdout.printf ("# End of %s tests\n", test.parent.label);
  546. + stdout.flush ();
  547. }
  548. }
  549. }
  550. diff --git a/valadate/test.vala b/valadate/test.vala
  551. index 0d853eba..310fbd65 100644
  552. --- a/valadate/test.vala
  553. +++ b/valadate/test.vala
  554. @@ -59,7 +59,7 @@ public interface Valadate.Test : Object {
  555.  
  556. public abstract Test? parent {get;set;}
  557.  
  558. - public abstract Test get(int index);
  559. + public abstract Test get (int index);
  560.  
  561. - public abstract void set(int index, Test test);
  562. + public abstract void set (int index, Test test);
  563. }
  564. diff --git a/valadate/testadapter.vala b/valadate/testadapter.vala
  565. index 93083081..2b5499f3 100644
  566. --- a/valadate/testadapter.vala
  567. +++ b/valadate/testadapter.vala
  568. @@ -46,18 +46,18 @@ public class Valadate.TestAdapter : Object, Test {
  569. private TestCase.TestMethod test;
  570. public Test? parent {get;set;}
  571.  
  572. - public new Test get(int index) {
  573. + public new Test get (int index) {
  574. return this;
  575. }
  576.  
  577. - public TestAdapter(string name, int timeout) {
  578. + public TestAdapter (string name, int timeout) {
  579. this.name = name;
  580. this.timeout = timeout;
  581. }
  582.  
  583. - public void add_test(owned TestPlan.TestMethod testmethod) {
  584. + public void add_test (owned TestPlan.TestMethod testmethod) {
  585. this.test = () => {
  586. - testmethod(parent as TestCase);
  587. + testmethod (parent as TestCase);
  588. };
  589. }
  590.  
  591. @@ -68,40 +68,40 @@ public class Valadate.TestAdapter : Object, Test {
  592. var p = parent as TestCase;
  593. this.test = () => {
  594. AsyncResult? result = null;
  595. - var loop = new MainLoop();
  596. - var thread = new Thread<void*>.try(name, () => {
  597. - async_begin(p, (o, r) => { result = r; loop.quit();});
  598. + var loop = new MainLoop ();
  599. + var thread = new Thread<void*>.try (name, () => {
  600. + async_begin (p, (o, r) => { result = r; loop.quit ();});
  601. return null;
  602. });
  603. - Timeout.add(timeout, () => {
  604. - loop.quit();
  605. + Timeout.add (timeout, () => {
  606. + loop.quit ();
  607. return false;
  608. },
  609. Priority.HIGH);
  610. - loop.run();
  611. - if(result == null)
  612. - throw new IOError.TIMED_OUT(
  613. + loop.run ();
  614. + if (result == null)
  615. + throw new IOError.TIMED_OUT (
  616. "The test timed out after %d milliseconds",timeout);
  617. - async_finish(p, result);
  618. + async_finish (p, result);
  619. };
  620. }
  621.  
  622. - public void add_test_method(owned TestCase.TestMethod testmethod) {
  623. + public void add_test_method (owned TestCase.TestMethod testmethod) {
  624. this.test = (owned)testmethod;
  625. }
  626.  
  627. - public void run(TestResult result) {
  628. - if(status == TestStatus.SKIPPED)
  629. + public void run (TestResult result) {
  630. + if (status == TestStatus.SKIPPED)
  631. return;
  632. var p = parent as TestCase;
  633. - result.add_test(this);
  634. - p.set_up();
  635. + result.add_test (this);
  636. + p.set_up ();
  637. try {
  638. - test();
  639. + test ();
  640. } catch (Error e) {
  641. - result.add_failure(this, e.message);
  642. + result.add_failure (this, e.message);
  643. }
  644. - p.tear_down();
  645. - result.add_success(this);
  646. + p.tear_down ();
  647. + result.add_success (this);
  648. }
  649. }
  650. diff --git a/valadate/testassembly.vala b/valadate/testassembly.vala
  651. index bc8e5aa9..7c2f8038 100644
  652. --- a/valadate/testassembly.vala
  653. +++ b/valadate/testassembly.vala
  654. @@ -27,67 +27,67 @@ public class Valadate.TestAssembly : TestModule {
  655.  
  656. public TestOptions options {get;set;}
  657.  
  658. - public TestAssembly(string[] args) throws Error {
  659. - base(File.new_for_path(args[0]));
  660. - options = new TestOptions(args);
  661. - setup_dirs();
  662. + public TestAssembly (string[] args) throws Error {
  663. + base (File.new_for_path (args[0]));
  664. + options = new TestOptions (args);
  665. + setup_dirs ();
  666. }
  667.  
  668. - private TestAssembly.copy(TestAssembly other) throws Error {
  669. - base(other.binary);
  670. + private TestAssembly.copy (TestAssembly other) throws Error {
  671. + base (other.binary);
  672. options = other.options;
  673. }
  674.  
  675. - private void setup_dirs() throws Error {
  676. - var buildstr = Environment.get_variable("G_TEST_BUILDDIR");
  677. + private void setup_dirs () throws Error {
  678. + var buildstr = Environment.get_variable ("G_TEST_BUILDDIR");
  679.  
  680. - if(buildstr == null) {
  681. - builddir = binary.get_parent();
  682. - if(builddir.get_basename() == ".libs")
  683. - builddir = builddir.get_parent();
  684. + if (buildstr == null) {
  685. + builddir = binary.get_parent ();
  686. + if (builddir.get_basename () == ".libs")
  687. + builddir = builddir.get_parent ();
  688. } else {
  689. - builddir = File.new_for_path(buildstr);
  690. + builddir = File.new_for_path (buildstr);
  691. }
  692.  
  693. - var srcstr = Environment.get_variable("G_TEST_SRCDIR");
  694. + var srcstr = Environment.get_variable ("G_TEST_SRCDIR");
  695.  
  696. - if(srcstr == null) {
  697. + if (srcstr == null) {
  698. // we're running outside the test harness
  699. // check for buildir!=srcdir
  700. // this currently on checks for autotools
  701. - if(!builddir.get_child("Makefile.in").query_exists()) {
  702. + if (!builddir.get_child ("Makefile.in").query_exists ()) {
  703. // check for Makefile in builddir and extract VPATH
  704. - var makefile = builddir.get_child("Makefile");
  705. - if(makefile.query_exists()) {
  706. - var reader = new DataInputStream(makefile.read());
  707. - var line = reader.read_line();
  708. - while(line!= null) {
  709. - if(line.has_prefix("VPATH = ")) {
  710. - srcstr = Path.build_path(Path.DIR_SEPARATOR_S, builddir.get_path(), line.split(" = ")[1]);
  711. + var makefile = builddir.get_child ("Makefile");
  712. + if (makefile.query_exists ()) {
  713. + var reader = new DataInputStream (makefile.read ());
  714. + var line = reader.read_line ();
  715. + while (line!= null) {
  716. + if (line.has_prefix ("VPATH = ")) {
  717. + srcstr = Path.build_path (Path.DIR_SEPARATOR_S, builddir.get_path (), line.split (" = ")[1]);
  718. break;
  719. }
  720. - line = reader.read_line();
  721. + line = reader.read_line ();
  722. }
  723. }
  724. }
  725. }
  726.  
  727. - if(srcstr == null)
  728. + if (srcstr == null)
  729. srcdir = builddir;
  730. else
  731. - srcdir = File.new_for_path(srcstr);
  732. + srcdir = File.new_for_path (srcstr);
  733.  
  734. - var mesondir = srcdir.get_child(Path.get_basename(binary.get_path()) + "@exe");
  735. + var mesondir = srcdir.get_child (Path.get_basename (binary.get_path ()) + "@exe");
  736.  
  737. - if(mesondir.query_exists())
  738. + if (mesondir.query_exists ())
  739. srcdir = mesondir;
  740.  
  741. - Environment.set_variable("G_TEST_BUILDDIR", builddir.get_path(), true);
  742. - Environment.set_variable("G_TEST_SRCDIR", srcdir.get_path(), true);
  743. + Environment.set_variable ("G_TEST_BUILDDIR", builddir.get_path (), true);
  744. + Environment.set_variable ("G_TEST_SRCDIR", srcdir.get_path (), true);
  745.  
  746. }
  747.  
  748. - public override Assembly clone() throws Error {
  749. - return new TestAssembly.copy(this);
  750. + public override Assembly clone () throws Error {
  751. + return new TestAssembly.copy (this);
  752. }
  753. }
  754. diff --git a/valadate/testcase.vala b/valadate/testcase.vala
  755. index 717d8798..35207ddb 100644
  756. --- a/valadate/testcase.vala
  757. +++ b/valadate/testcase.vala
  758. @@ -44,7 +44,7 @@ public abstract class Valadate.TestCase : Object, Test {
  759. public int count {
  760. get {
  761. int testcount = 0;
  762. - _tests.foreach((t) => {
  763. + _tests.foreach ((t) => {
  764. testcount += t.count;
  765. });
  766. return testcount;
  767. @@ -54,7 +54,7 @@ public abstract class Valadate.TestCase : Object, Test {
  768. public int size {
  769. get {
  770. int testcount = 0;
  771. - _tests.foreach((t) => {
  772. + _tests.foreach ((t) => {
  773. testcount += t.count;
  774. });
  775. return testcount;
  776. @@ -69,60 +69,60 @@ public abstract class Valadate.TestCase : Object, Test {
  777.  
  778. public string bug_base {get;set;}
  779.  
  780. - private List<Test> _tests = new List<Test>();
  781. + private List<Test> _tests = new List<Test> ();
  782.  
  783. private Test current_test;
  784. private TestResult current_result;
  785.  
  786. - public new Test get(int index) {
  787. - return _tests.nth_data((uint)index);
  788. + public new Test get (int index) {
  789. + return _tests.nth_data ((uint)index);
  790. }
  791.  
  792. - public new void set(int index, Test test) {
  793. + public new void set (int index, Test test) {
  794. test.parent = this;
  795. - _tests.insert_before(_tests.nth(index), test);
  796. - var t = _tests.nth_data((uint)index++);
  797. - _tests.remove(t);
  798. + _tests.insert_before (_tests.nth (index), test);
  799. + var t = _tests.nth_data ((uint)index++);
  800. + _tests.remove (t);
  801. }
  802.  
  803. - public void add_test(Test test) {
  804. + public void add_test (Test test) {
  805. test.parent = this;
  806. - _tests.append(test);
  807. + _tests.append (test);
  808. }
  809.  
  810. - public void add_test_method(string testname, owned TestMethod test, int timeout, string? label = null) {
  811. + public void add_test_method (string testname, owned TestMethod test, int timeout, string? label = null) {
  812. var adapter = new TestAdapter (testname, timeout);
  813. - adapter.add_test_method((owned)test);
  814. + adapter.add_test_method ((owned)test);
  815. adapter.label = label;
  816. adapter.parent = this;
  817. - _tests.append(adapter);
  818. + _tests.append (adapter);
  819. }
  820.  
  821. - public virtual void run(TestResult result) {
  822. - if(status != TestStatus.NOT_RUN)
  823. + public virtual void run (TestResult result) {
  824. + if (status != TestStatus.NOT_RUN)
  825. return;
  826. current_result = result;
  827. - _tests.foreach((t) => {
  828. + _tests.foreach ((t) => {
  829. current_test = t;
  830. - t.run(result);
  831. + t.run (result);
  832. });
  833. }
  834.  
  835. - public void bug(string reference)
  836. - requires(bug_base != null)
  837. + public void bug (string reference)
  838. + requires (bug_base != null)
  839. {
  840. - info("Bug Reference: %s%s",bug_base, reference);
  841. + info ("Bug Reference: %s%s",bug_base, reference);
  842. }
  843.  
  844. - public void skip(string message) {
  845. - current_result.add_skip(current_test, message);
  846. + public void skip (string message) {
  847. + current_result.add_skip (current_test, message);
  848. }
  849.  
  850. - public void fail(string? message = null) {
  851. - current_result.add_failure(current_test, message);
  852. + public void fail (string? message = null) {
  853. + current_result.add_failure (current_test, message);
  854. }
  855.  
  856. - public virtual void set_up() {}
  857. + public virtual void set_up () {}
  858.  
  859. - public virtual void tear_down() {}
  860. + public virtual void tear_down () {}
  861. }
  862. diff --git a/valadate/testconfig.vala b/valadate/testconfig.vala
  863. index a7405dbd..20641913 100644
  864. --- a/valadate/testconfig.vala
  865. +++ b/valadate/testconfig.vala
  866. @@ -91,7 +91,7 @@ public class Valadate.TestConfig {
  867. }
  868. }
  869.  
  870. - public TestConfig(TestOptions options) {
  871. + public TestConfig (TestOptions options) {
  872. this.options = options;
  873. }
  874. }
  875. diff --git a/valadate/testgatherer.vala b/valadate/testgatherer.vala
  876. index a9049f30..67b5d0f0 100644
  877. --- a/valadate/testgatherer.vala
  878. +++ b/valadate/testgatherer.vala
  879. @@ -23,35 +23,35 @@
  880. public class Valadate.TestGatherer : Vala.CodeVisitor {
  881.  
  882. public HashTable<Type, Vala.Class> classes =
  883. - new HashTable<Type, Vala.Class>(direct_hash, direct_equal);
  884. + new HashTable<Type, Vala.Class> (direct_hash, direct_equal);
  885.  
  886. private TestAssembly assembly;
  887.  
  888. - public TestGatherer(TestAssembly assembly) {
  889. + public TestGatherer (TestAssembly assembly) {
  890. this.assembly = assembly;
  891. }
  892.  
  893. - public override void visit_namespace(Vala.Namespace ns) {
  894. - ns.accept_children(this);
  895. + public override void visit_namespace (Vala.Namespace ns) {
  896. + ns.accept_children (this);
  897. }
  898.  
  899. - public override void visit_class(Vala.Class cls) {
  900. + public override void visit_class (Vala.Class cls) {
  901. try {
  902. - var classtype = find_type(cls);
  903. - if (classtype.is_a(typeof(TestCase)) || classtype.is_a(typeof(TestSuite)))
  904. - classes.insert(classtype, cls);
  905. + var classtype = find_type (cls);
  906. + if (classtype.is_a (typeof (TestCase)) || classtype.is_a (typeof (TestSuite)))
  907. + classes.insert (classtype, cls);
  908. } catch (Error e) {
  909. - warning(e.message);
  910. + warning (e.message);
  911. }
  912. - cls.accept_children(this);
  913. + cls.accept_children (this);
  914. }
  915.  
  916. - private Type find_type(Vala.Class cls) throws Error {
  917. + private Type find_type (Vala.Class cls) throws Error {
  918. var attr = new Vala.CCodeAttribute (cls);
  919. unowned TestPlan.GetType node_get_type =
  920. - (TestPlan.GetType)assembly.get_method(
  921. - "%sget_type".printf(attr.lower_case_prefix));
  922. - var ctype = node_get_type();
  923. + (TestPlan.GetType)assembly.get_method (
  924. + "%sget_type".printf (attr.lower_case_prefix));
  925. + var ctype = node_get_type ();
  926. return ctype;
  927. }
  928. }
  929. diff --git a/valadate/testmodule.vala b/valadate/testmodule.vala
  930. index c06ae655..67122cf0 100644
  931. --- a/valadate/testmodule.vala
  932. +++ b/valadate/testmodule.vala
  933. @@ -27,29 +27,29 @@ public class Valadate.TestModule : Assembly {
  934.  
  935. private GLib.Module module;
  936.  
  937. - public TestModule(File binary) throws Error {
  938. - base(binary);
  939. + public TestModule (File binary) throws Error {
  940. + base (binary);
  941. }
  942.  
  943. - private void load_module() throws AssemblyError {
  944. - module = GLib.Module.open (binary.get_path(), ModuleFlags.BIND_LAZY);
  945. + private void load_module () throws AssemblyError {
  946. + module = GLib.Module.open (binary.get_path (), ModuleFlags.BIND_LAZY);
  947. if (module == null)
  948. - throw new AssemblyError.LOAD(GLib.Module.error());
  949. - module.make_resident();
  950. + throw new AssemblyError.LOAD (GLib.Module.error ());
  951. + module.make_resident ();
  952. }
  953.  
  954. - public virtual void* get_method(string method_name) throws AssemblyError {
  955. - if(module == null)
  956. - load_module();
  957. + public virtual void* get_method (string method_name) throws AssemblyError {
  958. + if (module == null)
  959. + load_module ();
  960. void* function;
  961. - if(module.symbol (method_name, out function))
  962. + if (module.symbol (method_name, out function))
  963. if (function != null)
  964. return function;
  965. - throw new AssemblyError.METHOD(GLib.Module.error());
  966. + throw new AssemblyError.METHOD (GLib.Module.error ());
  967. }
  968.  
  969. - public override Assembly clone() throws Error {
  970. - return new TestModule(binary);
  971. + public override Assembly clone () throws Error {
  972. + return new TestModule (binary);
  973. }
  974.  
  975. }
  976. diff --git a/valadate/testoptions.vala b/valadate/testoptions.vala
  977. index 1cffd541..f7a19c2e 100644
  978. --- a/valadate/testoptions.vala
  979. +++ b/valadate/testoptions.vala
  980. @@ -60,7 +60,7 @@ public class Valadate.TestOptions {
  981.  
  982. public OptionContext opt_context;
  983.  
  984. - public static string? get_current_test_path() {
  985. + public static string? get_current_test_path () {
  986. return _runtest;
  987. }
  988.  
  989. @@ -118,7 +118,7 @@ public class Valadate.TestOptions {
  990. }
  991. }
  992.  
  993. - public TestOptions(string[] args) throws OptionError {
  994. + public TestOptions (string[] args) throws OptionError {
  995. _runtest = null;
  996.  
  997. opt_context = new OptionContext ("- Valadate Testing Framework");
  998. @@ -126,12 +126,12 @@ public class Valadate.TestOptions {
  999. opt_context.add_main_entries (options, null);
  1000. opt_context.parse (ref args);
  1001.  
  1002. - if(_seed == null)
  1003. - _seed = "R02S%08x%08x%08x%08x".printf(
  1004. - GLib.Random.next_int(),
  1005. - GLib.Random.next_int(),
  1006. - GLib.Random.next_int(),
  1007. - GLib.Random.next_int());
  1008. + if (_seed == null)
  1009. + _seed = "R02S%08x%08x%08x%08x".printf (
  1010. + GLib.Random.next_int (),
  1011. + GLib.Random.next_int (),
  1012. + GLib.Random.next_int (),
  1013. + GLib.Random.next_int ());
  1014.  
  1015. }
  1016.  
  1017. diff --git a/valadate/testplan.vala b/valadate/testplan.vala
  1018. index d70158d2..a5dfba9b 100644
  1019. --- a/valadate/testplan.vala
  1020. +++ b/valadate/testplan.vala
  1021. @@ -23,12 +23,12 @@
  1022. public class Valadate.TestPlan : Vala.CodeVisitor {
  1023.  
  1024. [CCode (has_target = false)]
  1025. - public delegate void TestMethod(TestCase self) throws Error;
  1026. + public delegate void TestMethod (TestCase self) throws Error;
  1027.  
  1028. - public delegate void AsyncTestMethod(TestCase self, AsyncReadyCallback cb);
  1029. - public delegate void AsyncTestMethodResult(TestCase self, AsyncResult res) throws Error;
  1030. + public delegate void AsyncTestMethod (TestCase self, AsyncReadyCallback cb);
  1031. + public delegate void AsyncTestMethodResult (TestCase self, AsyncResult res) throws Error;
  1032.  
  1033. - public delegate Type GetType();
  1034. + public delegate Type GetType ();
  1035.  
  1036. public File plan {get;set;}
  1037.  
  1038. @@ -46,40 +46,40 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  1039.  
  1040. private Vala.CodeContext context;
  1041. private TestGatherer gatherer;
  1042. - private delegate TestCase Constructor();
  1043. + private delegate TestCase Constructor ();
  1044. private TestSuite testsuite;
  1045. private TestCase testcase;
  1046.  
  1047. - public TestPlan(TestAssembly assembly) throws Error {
  1048. + public TestPlan (TestAssembly assembly) throws Error {
  1049.  
  1050. this.assembly = assembly;
  1051. options = assembly.options;
  1052.  
  1053. - var plan_name = Path.get_basename(assembly.binary.get_path());
  1054. - if(plan_name.has_prefix("lt-"))
  1055. - plan_name = plan_name.substring(3);
  1056. -
  1057. - plan = assembly.srcdir.get_child(plan_name + ".vapi");
  1058. - if(!plan.query_exists()) {
  1059. - plan = assembly.builddir.get_child(plan_name + ".vapi");
  1060. - if(!plan.query_exists()) {
  1061. - throw new TestConfigError.TESTPLAN(
  1062. - "Test Plan %s Not Found in %s or %s", plan_name, assembly.srcdir.get_path(), assembly.builddir.get_path());
  1063. + var plan_name = Path.get_basename (assembly.binary.get_path ());
  1064. + if (plan_name.has_prefix ("lt-"))
  1065. + plan_name = plan_name.substring (3);
  1066. +
  1067. + plan = assembly.srcdir.get_child (plan_name + ".vapi");
  1068. + if (!plan.query_exists ()) {
  1069. + plan = assembly.builddir.get_child (plan_name + ".vapi");
  1070. + if (!plan.query_exists ()) {
  1071. + throw new TestConfigError.TESTPLAN (
  1072. + "Test Plan %s Not Found in %s or %s", plan_name, assembly.srcdir.get_path (), assembly.builddir.get_path ());
  1073. }
  1074. }
  1075. - config = new TestConfig(options);
  1076. - runner = new TestRunner();
  1077. - result = new TestResult(config);
  1078. - testsuite = root = new TestSuite("/");
  1079. - setup_context();
  1080. - load_test_plan();
  1081. + config = new TestConfig (options);
  1082. + runner = new TestRunner ();
  1083. + result = new TestResult (config);
  1084. + testsuite = root = new TestSuite ("/");
  1085. + setup_context ();
  1086. + load_test_plan ();
  1087. }
  1088.  
  1089. - public int run() throws Error {
  1090. - return runner.run_all(this);
  1091. + public int run () throws Error {
  1092. + return runner.run_all (this);
  1093. }
  1094.  
  1095. - private void setup_context() {
  1096. + private void setup_context () {
  1097. context = new Vala.CodeContext ();
  1098. Vala.CodeContext.push (context);
  1099. context.report.enable_warnings = false;
  1100. @@ -87,198 +87,198 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  1101. context.verbose_mode = false;
  1102. }
  1103.  
  1104. - public void load_test_plan() throws Error {
  1105. + public void load_test_plan () throws Error {
  1106. context.add_source_file (new Vala.SourceFile (
  1107. - context, Vala.SourceFileType.PACKAGE, plan.get_path()));
  1108. + context, Vala.SourceFileType.PACKAGE, plan.get_path ()));
  1109. var parser = new Vala.Parser ();
  1110. parser.parse (context);
  1111. - gatherer = new TestGatherer(assembly);
  1112. - context.accept(gatherer);
  1113. - context.accept(this);
  1114. + gatherer = new TestGatherer (assembly);
  1115. + context.accept (gatherer);
  1116. + context.accept (this);
  1117. }
  1118.  
  1119. - public override void visit_namespace(Vala.Namespace ns) {
  1120. + public override void visit_namespace (Vala.Namespace ns) {
  1121. if (ns.name != null) {
  1122. - var currpath = "/" + ns.get_full_name().replace(".","/");
  1123. - if(config.in_subprocess)
  1124. - if(!options.running_test.has_prefix(currpath))
  1125. + var currpath = "/" + ns.get_full_name ().replace (".","/");
  1126. + if (config.in_subprocess)
  1127. + if (!options.running_test.has_prefix (currpath))
  1128. return;
  1129.  
  1130. - if(currpath.last_index_of("/") == 0)
  1131. + if (currpath.last_index_of ("/") == 0)
  1132. testsuite = root;
  1133.  
  1134. - var ts = new TestSuite(ns.name);
  1135. - testsuite.add_test(ts);
  1136. + var ts = new TestSuite (ns.name);
  1137. + testsuite.add_test (ts);
  1138. testsuite = ts;
  1139. }
  1140. - ns.accept_children(this);
  1141. + ns.accept_children (this);
  1142. }
  1143.  
  1144. - public override void visit_class(Vala.Class cls) {
  1145. + public override void visit_class (Vala.Class cls) {
  1146.  
  1147. try {
  1148. - if (is_subtype_of(cls, typeof(TestCase)) && !cls.is_abstract) {
  1149. - unowned Constructor ctor = get_constructor(cls);
  1150. - testcase = ctor();
  1151. + if (is_subtype_of (cls, typeof (TestCase)) && !cls.is_abstract) {
  1152. + unowned Constructor ctor = get_constructor (cls);
  1153. + testcase = ctor ();
  1154. testcase.name = cls.name;
  1155. - testcase.label = "/%s".printf(cls.get_full_name().replace(".","/"));
  1156. - testsuite.add_test(testcase);
  1157. - visit_testcase(cls);
  1158. + testcase.label = "/%s".printf (cls.get_full_name ().replace (".","/"));
  1159. + testsuite.add_test (testcase);
  1160. + visit_testcase (cls);
  1161.  
  1162. - } else if (is_subtype_of(cls,typeof(TestSuite))) {
  1163. - visit_testsuite(cls);
  1164. + } else if (is_subtype_of (cls,typeof (TestSuite))) {
  1165. + visit_testsuite (cls);
  1166. }
  1167. } catch (Error e) {
  1168. - error(e.message);
  1169. + error (e.message);
  1170. }
  1171. - cls.accept_children(this);
  1172. + cls.accept_children (this);
  1173. }
  1174.  
  1175. - private bool is_subtype_of(Vala.Class cls, Type type) {
  1176. - var t = Type.from_name(cls.get_full_name().replace(".",""));
  1177. - if(t.is_a(type))
  1178. + private bool is_subtype_of (Vala.Class cls, Type type) {
  1179. + var t = Type.from_name (cls.get_full_name ().replace (".",""));
  1180. + if (t.is_a (type))
  1181. return true;
  1182. return false;
  1183. }
  1184.  
  1185. - private unowned Constructor get_constructor(Vala.Class cls) throws Error {
  1186. + private unowned Constructor get_constructor (Vala.Class cls) throws Error {
  1187. var attr = new Vala.CCodeAttribute (cls.default_construction_method);
  1188. - return (Constructor)assembly.get_method(attr.name);
  1189. + return (Constructor)assembly.get_method (attr.name);
  1190. }
  1191.  
  1192. - public void visit_testcase(Vala.Class cls) {
  1193. + public void visit_testcase (Vala.Class cls) {
  1194.  
  1195. - var t = Type.from_name(cls.get_full_name().replace(".",""));
  1196. - var p = t.parent();
  1197. - if(p != typeof(TestCase)) {
  1198. - var basecls = gatherer.classes.get(p);
  1199. - if(basecls != null)
  1200. - visit_testcase(basecls);
  1201. + var t = Type.from_name (cls.get_full_name ().replace (".",""));
  1202. + var p = t.parent ();
  1203. + if (p != typeof (TestCase)) {
  1204. + var basecls = gatherer.classes.get (p);
  1205. + if (basecls != null)
  1206. + visit_testcase (basecls);
  1207. }
  1208.  
  1209. - foreach(var method in cls.get_methods()) {
  1210. + foreach (var method in cls.get_methods ()) {
  1211.  
  1212. - if(config.in_subprocess)
  1213. - if (options.running_test != "%s/%s".printf(
  1214. + if (config.in_subprocess)
  1215. + if (options.running_test != "%s/%s".printf (
  1216. testcase.label, method.name))
  1217. continue;
  1218.  
  1219. - if(!is_test(method))
  1220. + if (!is_test (method))
  1221. continue;
  1222.  
  1223. var added = false;
  1224. - foreach(var test in testcase)
  1225. - if(test.name == method.name)
  1226. + foreach (var test in testcase)
  1227. + if (test.name == method.name)
  1228. added=true;
  1229. - if(added)
  1230. + if (added)
  1231. continue;
  1232.  
  1233. - var adapter = new TestAdapter(method.name, config.timeout);
  1234. - annotate_label(adapter);
  1235. - annotate(adapter, method);
  1236. + var adapter = new TestAdapter (method.name, config.timeout);
  1237. + annotate_label (adapter);
  1238. + annotate (adapter, method);
  1239.  
  1240. - if(config.in_subprocess && adapter.status != TestStatus.SKIPPED) {
  1241. + if (config.in_subprocess && adapter.status != TestStatus.SKIPPED) {
  1242. var attr = new Vala.CCodeAttribute (method);
  1243.  
  1244. - if(method.coroutine) {
  1245. + if (method.coroutine) {
  1246. try {
  1247. unowned TestPlan.AsyncTestMethod beginmethod =
  1248. - (TestPlan.AsyncTestMethod)assembly.get_method(attr.name);
  1249. + (TestPlan.AsyncTestMethod)assembly.get_method (attr.name);
  1250. unowned TestPlan.AsyncTestMethodResult testmethod =
  1251. - (TestPlan.AsyncTestMethodResult)assembly.get_method(attr.finish_real_name);
  1252. - adapter.add_async_test(beginmethod, testmethod);
  1253. + (TestPlan.AsyncTestMethodResult)assembly.get_method (attr.finish_real_name);
  1254. + adapter.add_async_test (beginmethod, testmethod);
  1255. } catch (Error e) {
  1256. var message = e.message;
  1257. - adapter.add_test_method(()=> {debug(message);});
  1258. + adapter.add_test_method (()=> {debug (message);});
  1259. }
  1260. } else {
  1261. try {
  1262. TestPlan.TestMethod testmethod =
  1263. - (TestPlan.TestMethod)assembly.get_method(attr.name);
  1264. - adapter.add_test((owned)testmethod);
  1265. + (TestPlan.TestMethod)assembly.get_method (attr.name);
  1266. + adapter.add_test ((owned)testmethod);
  1267. } catch (Error e) {
  1268. var message = e.message;
  1269. - adapter.add_test_method(()=> {debug(message);});
  1270. + adapter.add_test_method (()=> {debug (message);});
  1271. }
  1272. }
  1273. } else {
  1274. - adapter.add_test_method(()=> {assert_not_reached();});
  1275. + adapter.add_test_method (()=> {assert_not_reached ();});
  1276. }
  1277.  
  1278. - adapter.label = "%s/%s".printf(
  1279. + adapter.label = "%s/%s".printf (
  1280. testcase.label,
  1281. adapter.label);
  1282.  
  1283. - testcase.add_test(adapter);
  1284. + testcase.add_test (adapter);
  1285. }
  1286.  
  1287. }
  1288.  
  1289. - private void annotate_label(Test test) {
  1290. - if(test.name.has_prefix("test_")) {
  1291. - test.label = test.name.substring(5);
  1292. - } else if(test.name.has_prefix("_test_")) {
  1293. - test.label = test.name.substring(6);
  1294. + private void annotate_label (Test test) {
  1295. + if (test.name.has_prefix ("test_")) {
  1296. + test.label = test.name.substring (5);
  1297. + } else if (test.name.has_prefix ("_test_")) {
  1298. + test.label = test.name.substring (6);
  1299. test.status = TestStatus.SKIPPED;
  1300. - } else if(test.name.has_prefix("todo_test_")) {
  1301. - test.label = test.name.substring(10);
  1302. + } else if (test.name.has_prefix ("todo_test_")) {
  1303. + test.label = test.name.substring (10);
  1304. test.status = TestStatus.TODO;
  1305. } else {
  1306. test.label = test.name;
  1307. }
  1308. - test.label = test.label.replace("_", " ");
  1309. + test.label = test.label.replace ("_", " ");
  1310. }
  1311.  
  1312. - private void annotate(TestAdapter adapter, Vala.Method method) {
  1313. + private void annotate (TestAdapter adapter, Vala.Method method) {
  1314.  
  1315. - foreach(var attr in method.attributes) {
  1316. - if(attr.name == "Test") {
  1317. - if(attr.has_argument("name"))
  1318. - adapter.label = attr.get_string("name");
  1319. - if(attr.has_argument("skip")) {
  1320. + foreach (var attr in method.attributes) {
  1321. + if (attr.name == "Test") {
  1322. + if (attr.has_argument ("name"))
  1323. + adapter.label = attr.get_string ("name");
  1324. + if (attr.has_argument ("skip")) {
  1325. adapter.status = TestStatus.SKIPPED;
  1326. - adapter.status_message = attr.get_string("skip");
  1327. - } else if(attr.has_argument("todo")) {
  1328. + adapter.status_message = attr.get_string ("skip");
  1329. + } else if (attr.has_argument ("todo")) {
  1330. adapter.status = TestStatus.SKIPPED;
  1331. - adapter.status_message = attr.get_string("todo");
  1332. - } else if(attr.has_argument("timeout")) {
  1333. - adapter.timeout = int.parse(attr.get_string("timeout"));
  1334. + adapter.status_message = attr.get_string ("todo");
  1335. + } else if (attr.has_argument ("timeout")) {
  1336. + adapter.timeout = int.parse (attr.get_string ("timeout"));
  1337. }
  1338. }
  1339. }
  1340. }
  1341.  
  1342. - private bool is_test(Vala.Method method) {
  1343. + private bool is_test (Vala.Method method) {
  1344. bool istest = false;
  1345.  
  1346. - if(method.is_virtual)
  1347. - foreach(var test in testcase)
  1348. - if(test.name == method.name)
  1349. + if (method.is_virtual)
  1350. + foreach (var test in testcase)
  1351. + if (test.name == method.name)
  1352. return false;
  1353.  
  1354. - if (method.name.has_prefix("test_") ||
  1355. - method.name.has_prefix("_test_") ||
  1356. - method.name.has_prefix("todo_test_"))
  1357. + if (method.name.has_prefix ("test_") ||
  1358. + method.name.has_prefix ("_test_") ||
  1359. + method.name.has_prefix ("todo_test_"))
  1360. istest = true;
  1361.  
  1362. - foreach(var attr in method.attributes)
  1363. - if(attr.name == "Test")
  1364. + foreach (var attr in method.attributes)
  1365. + if (attr.name == "Test")
  1366. istest = true;
  1367.  
  1368. - if(method.has_result)
  1369. + if (method.has_result)
  1370. istest = false;
  1371.  
  1372. - if(method.get_parameters().size > 0)
  1373. + if (method.get_parameters ().size > 0)
  1374. istest = false;
  1375.  
  1376. return istest;
  1377. }
  1378.  
  1379. - public void visit_testsuite(Vala.Class testclass) throws Error {
  1380. - unowned Constructor meth = get_constructor(testclass);
  1381. - var tsuite = meth() as TestSuite;
  1382. + public void visit_testsuite (Vala.Class testclass) throws Error {
  1383. + unowned Constructor meth = get_constructor (testclass);
  1384. + var tsuite = meth () as TestSuite;
  1385. tsuite.name = testclass.name;
  1386. - testsuite.add_test(tsuite);
  1387. + testsuite.add_test (tsuite);
  1388. testsuite = tsuite;
  1389. }
  1390. }
  1391. diff --git a/valadate/testreport.vala b/valadate/testreport.vala
  1392. index f5e58f6d..d6fc0bef 100644
  1393. --- a/valadate/testreport.vala
  1394. +++ b/valadate/testreport.vala
  1395. @@ -53,120 +53,120 @@ public class Valadate.TestReport {
  1396.  
  1397. private static Regex regex_err;
  1398. private const string regex_err_string =
  1399. - """(\*{2}\n([A-Z]*):([\S]*) ([\S ]*)\n)""";
  1400. + """(\*{2}\n([A-Z]*):([\S]*)([\S ]*)\n)""";
  1401.  
  1402. - public TestReport(Test test, bool subprocess) throws Error {
  1403. + public TestReport (Test test, bool subprocess) throws Error {
  1404. this.test = test;
  1405. this.subprocess = subprocess;
  1406.  
  1407. - if(test.status == TestStatus.NOT_RUN)
  1408. + if (test.status == TestStatus.NOT_RUN)
  1409. test.status = TestStatus.RUNNING;
  1410.  
  1411. - if(subprocess) {
  1412. + if (subprocess) {
  1413. Log.set_default_handler (log_func);
  1414. GLib.set_printerr_handler (printerr_func);
  1415. - regex_err = new Regex(regex_err_string);
  1416. + regex_err = new Regex (regex_err_string);
  1417. }
  1418.  
  1419. - if(test is TestSuite || test is TestCase)
  1420. - new_testsuite();
  1421. + if (test is TestSuite || test is TestCase)
  1422. + new_testsuite ();
  1423. else if (test is TestAdapter)
  1424. - new_testcase();
  1425. + new_testcase ();
  1426. }
  1427.  
  1428. - private void new_testsuite() throws Error {
  1429. - if(subprocess)
  1430. + private void new_testsuite () throws Error {
  1431. + if (subprocess)
  1432. return;
  1433.  
  1434. - var decl = "%s<%s>%s</%s>".printf(XML_DECL, ROOT_TAG, TESTSUITE_XML, ROOT_TAG);
  1435. - var doc = Xml.Parser.read_memory(decl, decl.length);
  1436. - var root = doc->get_root_element()->children;
  1437. - root->set_prop("tests", test.count.to_string());
  1438. - root->set_prop("name",test.label);
  1439. - xml = new XmlFile.from_doc(doc);
  1440. + var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTSUITE_XML, ROOT_TAG);
  1441. + var doc = Xml.Parser.read_memory (decl, decl.length);
  1442. + var root = doc->get_root_element ()->children;
  1443. + root->set_prop ("tests", test.count.to_string ());
  1444. + root->set_prop ("name",test.label);
  1445. + xml = new XmlFile.from_doc (doc);
  1446. }
  1447.  
  1448. - private void new_testcase() throws Error {
  1449. - if(subprocess) {
  1450. - stderr.printf("%s<%s>",XML_DECL,ROOT_TAG);
  1451. - stderr.printf(TESTCASE_START,test.parent.get_type().name(), test.label);
  1452. - start_time = get_monotonic_time();
  1453. + private void new_testcase () throws Error {
  1454. + if (subprocess) {
  1455. + stderr.printf ("%s<%s>",XML_DECL,ROOT_TAG);
  1456. + stderr.printf (TESTCASE_START,test.parent.get_type ().name (), test.label);
  1457. + start_time = get_monotonic_time ();
  1458. } else {
  1459. - var decl = "%s<%s>%s</%s>".printf(XML_DECL, ROOT_TAG, TESTCASE_XML, ROOT_TAG);
  1460. - var doc = Xml.Parser.read_memory(decl, decl.length);
  1461. - var root = doc->get_root_element()->children;
  1462. - root->set_prop("classname",((TestAdapter)test).parent.name);
  1463. - root->set_prop("status",test.status.to_string().substring(21));
  1464. - root->set_prop("name",test.label);
  1465. - xml = new XmlFile.from_doc(doc);
  1466. + var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTCASE_XML, ROOT_TAG);
  1467. + var doc = Xml.Parser.read_memory (decl, decl.length);
  1468. + var root = doc->get_root_element ()->children;
  1469. + root->set_prop ("classname", ((TestAdapter)test).parent.name);
  1470. + root->set_prop ("status",test.status.to_string ().substring (21));
  1471. + root->set_prop ("name",test.label);
  1472. + xml = new XmlFile.from_doc (doc);
  1473. }
  1474. }
  1475.  
  1476. - public void add_error(string message) {
  1477. + public void add_error (string message) {
  1478. if (test.status != TestStatus.SKIPPED &&
  1479. test.status != TestStatus.TODO)
  1480. test.status = TestStatus.ERROR;
  1481.  
  1482. - add_message(ERROR_TAG, message);
  1483. + add_message (ERROR_TAG, message);
  1484.  
  1485. - if(subprocess) {
  1486. - emit_timer();
  1487. - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1488. - stderr.putc(0);
  1489. + if (subprocess) {
  1490. + emit_timer ();
  1491. + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1492. + stderr.putc (0);
  1493. }
  1494. - update_status();
  1495. + update_status ();
  1496. }
  1497.  
  1498. - public void add_failure(string message) {
  1499. + public void add_failure (string message) {
  1500. if (test.status != TestStatus.SKIPPED &&
  1501. test.status != TestStatus.TODO)
  1502. test.status = TestStatus.FAILED;
  1503.  
  1504. - add_message(FAILURE_TAG, message);
  1505. + add_message (FAILURE_TAG, message);
  1506.  
  1507. - if(subprocess) {
  1508. - emit_timer();
  1509. - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1510. - stderr.putc(0);
  1511. + if (subprocess) {
  1512. + emit_timer ();
  1513. + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1514. + stderr.putc (0);
  1515. }
  1516. - update_status();
  1517. + update_status ();
  1518. }
  1519.  
  1520. - public void add_skip(string message) {
  1521. + public void add_skip (string message) {
  1522. test.status = TestStatus.SKIPPED;
  1523. - add_message(SKIP_TAG, message);
  1524. - update_status();
  1525. + add_message (SKIP_TAG, message);
  1526. + update_status ();
  1527. }
  1528.  
  1529. - public void add_success() {
  1530. + public void add_success () {
  1531. if (test.status != TestStatus.SKIPPED &&
  1532. test.status != TestStatus.TODO)
  1533. test.status = TestStatus.PASSED;
  1534. - if(subprocess) {
  1535. - emit_timer();
  1536. - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1537. - stderr.putc(0);
  1538. + if (subprocess) {
  1539. + emit_timer ();
  1540. + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1541. + stderr.putc (0);
  1542. }
  1543. - update_status();
  1544. + update_status ();
  1545. }
  1546.  
  1547. - private void add_message(string tag, string message) {
  1548. - var escaped = Markup.escape_text(message);
  1549. - if(subprocess) {
  1550. - stderr.printf(MESSAGE_XML, tag, escaped, tag.up(), message, tag);
  1551. + private void add_message (string tag, string message) {
  1552. + var escaped = Markup.escape_text (message);
  1553. + if (subprocess) {
  1554. + stderr.printf (MESSAGE_XML, tag, escaped, tag.up (), message, tag);
  1555. } else {
  1556. - Xml.Node* child = new Xml.Node(null, tag);
  1557. - child->set_content(escaped);
  1558. + Xml.Node* child = new Xml.Node (null, tag);
  1559. + child->set_content (escaped);
  1560.  
  1561. string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
  1562.  
  1563. - if(tag in tags) {
  1564. - child->new_prop("message", escaped);
  1565. - child->new_prop("type", tag.up());
  1566. + if (tag in tags) {
  1567. + child->new_prop ("message", escaped);
  1568. + child->new_prop ("type", tag.up ());
  1569. }
  1570.  
  1571. - Xml.Node* root = xml.eval("//testcase | //testsuite")[0];
  1572. - root->add_child(child);
  1573. + Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
  1574. + root->add_child (child);
  1575. }
  1576. }
  1577. /**
  1578. @@ -177,46 +177,46 @@ public class Valadate.TestReport {
  1579. * the text will be escaped before being added.
  1580. * @param tag The tag to use for adding the text
  1581. */
  1582. - public void add_text(string text, string tag) {
  1583. - var markup = Markup.escape_text(text);
  1584. - Xml.Node* child = new Xml.Node(null, tag);
  1585. - child->set_content(markup);
  1586. + public void add_text (string text, string tag) {
  1587. + var markup = Markup.escape_text (text);
  1588. + Xml.Node* child = new Xml.Node (null, tag);
  1589. + child->set_content (markup);
  1590.  
  1591. string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
  1592.  
  1593. - if(tag in tags) {
  1594. - child->new_prop("message", markup);
  1595. - child->new_prop("type", tag.up());
  1596. + if (tag in tags) {
  1597. + child->new_prop ("message", markup);
  1598. + child->new_prop ("type", tag.up ());
  1599. }
  1600.  
  1601. - Xml.Node* root = xml.eval("//testcase | //testsuite")[0];
  1602. - root->add_child(child);
  1603. + Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
  1604. + root->add_child (child);
  1605. }
  1606.  
  1607. - public void update_status() {
  1608. - if(test is TestAdapter && !subprocess) {
  1609. - Xml.Node* root = xml.eval("//testcase")[0];
  1610. - root->set_prop("status",test.status.to_string().substring(21));
  1611. - root->set_prop("time",test.time.to_string());
  1612. + public void update_status () {
  1613. + if (test is TestAdapter && !subprocess) {
  1614. + Xml.Node* root = xml.eval ("//testcase")[0];
  1615. + root->set_prop ("status",test.status.to_string ().substring (21));
  1616. + root->set_prop ("time",test.time.to_string ());
  1617. }
  1618. }
  1619.  
  1620. - private static void emit_timer() {
  1621. - end_time = get_monotonic_time();
  1622. - var ms = "%f".printf(((double)(end_time-start_time))/1000);
  1623. - stderr.printf(MESSAGE_XML, TIMER_TAG, ms, TIMER_TAG, ms, TIMER_TAG);
  1624. + private static void emit_timer () {
  1625. + end_time = get_monotonic_time ();
  1626. + var ms = "%f".printf (((double) (end_time-start_time))/1000);
  1627. + stderr.printf (MESSAGE_XML, TIMER_TAG, ms, TIMER_TAG, ms, TIMER_TAG);
  1628. }
  1629.  
  1630. private static void printerr_func (string? text) {
  1631. - if(text == null)
  1632. + if (text == null)
  1633. return;
  1634. MatchInfo info;
  1635. - if(regex_err.match(text, 0, out info)) {
  1636. - var escaped = Markup.escape_text(info.fetch(4));
  1637. - stderr.printf(MESSAGE_XML, ERROR_TAG, escaped, ERROR_TAG, text, ERROR_TAG);
  1638. - emit_timer();
  1639. - stderr.printf("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1640. - stderr.putc(0);
  1641. + if (regex_err.match (text, 0, out info)) {
  1642. + var escaped = Markup.escape_text (info.fetch (4));
  1643. + stderr.printf (MESSAGE_XML, ERROR_TAG, escaped, ERROR_TAG, text, ERROR_TAG);
  1644. + emit_timer ();
  1645. + stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  1646. + stderr.putc (0);
  1647. }
  1648. }
  1649.  
  1650. @@ -226,41 +226,41 @@ public class Valadate.TestReport {
  1651. string? message) {
  1652.  
  1653. if (((log_levels & LogLevelFlags.LEVEL_INFO) != 0) ||
  1654. - ((log_levels & LogLevelFlags.LEVEL_MESSAGE) != 0) ||
  1655. - ((log_levels & LogLevelFlags.LEVEL_DEBUG) != 0)) {
  1656. - add_message(INFO_TAG, message);
  1657. + ((log_levels & LogLevelFlags.LEVEL_MESSAGE) != 0) ||
  1658. + ((log_levels & LogLevelFlags.LEVEL_DEBUG) != 0)) {
  1659. + add_message (INFO_TAG, message);
  1660. } else {
  1661. - add_error(message);
  1662. + add_error (message);
  1663. }
  1664. }
  1665.  
  1666. - public void process_buffer(string buffer) throws Error {
  1667. + public void process_buffer (string buffer) throws Error {
  1668.  
  1669. - xml = new XmlFile.from_string(buffer);
  1670. + xml = new XmlFile.from_string (buffer);
  1671.  
  1672. - var bits = xml.eval("//testcase/text()");
  1673. + var bits = xml.eval ("//testcase/text ()");
  1674.  
  1675. - if(bits.size != 0) {
  1676. + if (bits.size != 0) {
  1677. Xml.Node* textnode = bits[0];
  1678. - add_message(SYSTEM_ERR_TAG, textnode->get_content());
  1679. - textnode->unlink();
  1680. + add_message (SYSTEM_ERR_TAG, textnode->get_content ());
  1681. + textnode->unlink ();
  1682. }
  1683.  
  1684. - var errs = xml.eval("//failure | //error");
  1685. + var errs = xml.eval ("//failure | //error");
  1686. if (errs.size > 0 &&
  1687. test.status != TestStatus.SKIPPED &&
  1688. test.status != TestStatus.TODO)
  1689. test.status = TestStatus.FAILED;
  1690.  
  1691. - bits = xml.eval("//timer");
  1692. + bits = xml.eval ("//timer");
  1693. Xml.Node* timer = bits[0];
  1694. - test.time = double.parse(timer->get_content());
  1695. - timer->unlink();
  1696. + test.time = double.parse (timer->get_content ());
  1697. + timer->unlink ();
  1698.  
  1699. - update_status();
  1700. + update_status ();
  1701. }
  1702.  
  1703. - public void add_stdout(string text) {
  1704. - add_message(SYSTEM_OUT_TAG, text);
  1705. + public void add_stdout (string text) {
  1706. + add_message (SYSTEM_OUT_TAG, text);
  1707. }
  1708. }
  1709. diff --git a/valadate/testreportprinter.vala b/valadate/testreportprinter.vala
  1710. index 71c8ed81..2c09c2ee 100644
  1711. --- a/valadate/testreportprinter.vala
  1712. +++ b/valadate/testreportprinter.vala
  1713. @@ -23,25 +23,25 @@
  1714.  
  1715. public abstract class Valadate.TestReportPrinter {
  1716.  
  1717. - public static TestReportPrinter @new(TestConfig config) throws Error {
  1718. - switch(config.format) {
  1719. + public static TestReportPrinter @new (TestConfig config) throws Error {
  1720. + switch (config.format) {
  1721. case "tap" :
  1722. - return new TapTestReportPrinter(config);
  1723. + return new TapTestReportPrinter (config);
  1724. case "xml" :
  1725. - return new XmlTestReportPrinter(config);
  1726. + return new XmlTestReportPrinter (config);
  1727. case "gnu" :
  1728. - return new GnuTestReportPrinter(config);
  1729. + return new GnuTestReportPrinter (config);
  1730. default:
  1731. - throw new TestConfigError.TEST_PRINTER("TestReportPrinter %s does not exist", config.format);
  1732. + throw new TestConfigError.TEST_PRINTER ("TestReportPrinter %s does not exist", config.format);
  1733. }
  1734. }
  1735.  
  1736. public TestConfig config {get; set;}
  1737.  
  1738. - public TestReportPrinter(TestConfig config) throws Error {
  1739. + public TestReportPrinter (TestConfig config) throws Error {
  1740. this.config = config;
  1741. }
  1742.  
  1743. - public abstract void print(TestReport report);
  1744. + public abstract void print (TestReport report);
  1745.  
  1746. }
  1747. diff --git a/valadate/testresult.vala b/valadate/testresult.vala
  1748. index d04660d6..1dc3bdec 100644
  1749. --- a/valadate/testresult.vala
  1750. +++ b/valadate/testresult.vala
  1751. @@ -25,20 +25,20 @@ public class Valadate.TestResult {
  1752. public TestConfig config {get;set;}
  1753. public TestReportPrinter printer {get;set;}
  1754.  
  1755. - private Queue<TestReport> reports = new Queue<TestReport>();
  1756. - private HashTable<Test, TestReport> tests = new HashTable<Test, TestReport>(direct_hash, direct_equal);
  1757. + private Queue<TestReport> reports = new Queue<TestReport> ();
  1758. + private HashTable<Test, TestReport> tests = new HashTable<Test, TestReport> (direct_hash, direct_equal);
  1759.  
  1760. - public TestResult(TestConfig config) throws Error {
  1761. + public TestResult (TestConfig config) throws Error {
  1762. this.config = config;
  1763. - if(!config.in_subprocess)
  1764. - printer = TestReportPrinter.new(config);
  1765. + if (!config.in_subprocess)
  1766. + printer = TestReportPrinter.new (config);
  1767. }
  1768.  
  1769. - public bool report() {
  1770. - if (reports.is_empty())
  1771. + public bool report () {
  1772. + if (reports.is_empty ())
  1773. return false;
  1774.  
  1775. - var rpt = reports.peek_head();
  1776. + var rpt = reports.peek_head ();
  1777.  
  1778. if (rpt.test.status == TestStatus.PASSED ||
  1779. rpt.test.status == TestStatus.SKIPPED ||
  1780. @@ -46,91 +46,91 @@ public class Valadate.TestResult {
  1781. rpt.test.status == TestStatus.FAILED ||
  1782. rpt.test.status == TestStatus.ERROR) {
  1783.  
  1784. - printer.print(rpt);
  1785. - reports.pop_head();
  1786. - report();
  1787. + printer.print (rpt);
  1788. + reports.pop_head ();
  1789. + report ();
  1790. }
  1791. return true;
  1792. }
  1793.  
  1794. - private void update_status(Test test) {
  1795. - var rept = tests.get(test);
  1796. - if(rept == null)
  1797. + private void update_status (Test test) {
  1798. + var rept = tests.get (test);
  1799. + if (rept == null)
  1800. return;
  1801.  
  1802. var parent = test.parent;
  1803. - if(parent == null)
  1804. + if (parent == null)
  1805. return;
  1806.  
  1807. TestStatus status = TestStatus.PASSED;
  1808. - foreach(var t in parent) {
  1809. - if(t.status == TestStatus.RUNNING)
  1810. + foreach (var t in parent) {
  1811. + if (t.status == TestStatus.RUNNING)
  1812. return;
  1813. - else if(t.status == TestStatus.ERROR)
  1814. + else if (t.status == TestStatus.ERROR)
  1815. status = TestStatus.ERROR;
  1816. - else if(t.status == TestStatus.FAILED)
  1817. + else if (t.status == TestStatus.FAILED)
  1818. status = TestStatus.FAILED;
  1819. }
  1820. parent.status = status;
  1821. - update_status(parent);
  1822. + update_status (parent);
  1823. }
  1824.  
  1825. - public void add_test(Test test) {
  1826. + public void add_test (Test test) {
  1827. try {
  1828. - reports.push_tail(new TestReport(test, config.in_subprocess));
  1829. - tests.insert(test, reports.peek_tail());
  1830. + reports.push_tail (new TestReport (test, config.in_subprocess));
  1831. + tests.insert (test, reports.peek_tail ());
  1832. } catch (Error e) {
  1833. - error(e.message);
  1834. + error (e.message);
  1835. }
  1836. }
  1837.  
  1838. - public void add_error(Test test, string error) {
  1839. - tests.get(test).add_error(error);
  1840. - update_status(test);
  1841. + public void add_error (Test test, string error) {
  1842. + tests.get (test).add_error (error);
  1843. + update_status (test);
  1844. }
  1845.  
  1846. - public void add_failure(Test test, string failure) {
  1847. - tests.get(test).add_failure(failure);
  1848. - update_status(test);
  1849. + public void add_failure (Test test, string failure) {
  1850. + tests.get (test).add_failure (failure);
  1851. + update_status (test);
  1852. }
  1853.  
  1854. - public void add_success(Test test) {
  1855. - tests.get(test).add_success();
  1856. - update_status(test);
  1857. + public void add_success (Test test) {
  1858. + tests.get (test).add_success ();
  1859. + update_status (test);
  1860. }
  1861.  
  1862. - public void add_skip(Test test, string message) {
  1863. - tests.get(test).add_skip(message);
  1864. - update_status(test);
  1865. + public void add_skip (Test test, string message) {
  1866. + tests.get (test).add_skip (message);
  1867. + update_status (test);
  1868. }
  1869.  
  1870. - public void process_buffers(Test test, Assembly assembly) throws Error {
  1871. + public void process_buffers (Test test, Assembly assembly) throws Error {
  1872.  
  1873. - var rept = tests.get(test);
  1874. - if(rept == null)
  1875. + var rept = tests.get (test);
  1876. + if (rept == null)
  1877. return;
  1878.  
  1879. var bis = new BufferedInputStream (assembly.stderr);
  1880. - bis.fill(-1);
  1881. - var xml = (string)bis.peek_buffer();
  1882. - if(xml.length < 8)
  1883. + bis.fill (-1);
  1884. + var xml = (string)bis.peek_buffer ();
  1885. + if (xml.length < 8)
  1886. return;
  1887.  
  1888. - rept.process_buffer(xml);
  1889. + rept.process_buffer (xml);
  1890.  
  1891. - update_status(test);
  1892. + update_status (test);
  1893.  
  1894. uint8 outbuffer[4096] = {};
  1895. - assembly.stdout.read_all(outbuffer, null);
  1896. - xml = ((string)outbuffer).strip();
  1897. + assembly.stdout.read_all (outbuffer, null);
  1898. + xml = ((string)outbuffer).strip ();
  1899. int i;
  1900. - for(i=xml.length-1;i==0;i--)
  1901. - if(xml.get_char(i).isgraph())
  1902. + for (i=xml.length-1;i==0;i--)
  1903. + if (xml.get_char (i).isgraph ())
  1904. break;
  1905.  
  1906. - xml = xml.substring(0, i+1);
  1907. - if(xml.length < 1 || xml == "\n")
  1908. + xml = xml.substring (0, i+1);
  1909. + if (xml.length < 1 || xml == "\n")
  1910. return;
  1911. - rept.add_stdout(xml);
  1912. + rept.add_stdout (xml);
  1913. }
  1914. }
  1915. diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
  1916. index 2576cc3d..91d17fc4 100644
  1917. --- a/valadate/testrunner.vala
  1918. +++ b/valadate/testrunner.vala
  1919. @@ -28,90 +28,90 @@ public class Valadate.TestRunner {
  1920.  
  1921. private uint _n_ongoing_tests = 0;
  1922. private Queue<DelegateWrapper> _pending_tests = new Queue<DelegateWrapper> ();
  1923. - private static uint _max_n_ongoing_tests = GLib.get_num_processors();
  1924. + private static uint _max_n_ongoing_tests = GLib.get_num_processors ();
  1925. private MainLoop loop;
  1926. private TestPlan plan;
  1927.  
  1928. - public void run(Test test, TestResult result) {
  1929. - result.add_test(test);
  1930. - test.run(result);
  1931. - result.report();
  1932. + public void run (Test test, TestResult result) {
  1933. + result.add_test (test);
  1934. + test.run (result);
  1935. + result.report ();
  1936. }
  1937.  
  1938. - public int run_all(TestPlan plan) throws Error {
  1939. + public int run_all (TestPlan plan) throws Error {
  1940. this.plan = plan;
  1941.  
  1942. if (plan.config.list_only) {
  1943. - list_tests(plan.root, "");
  1944. + list_tests (plan.root, "");
  1945. return 0;
  1946. } else if (plan.root.count == 0) {
  1947. return 0;
  1948. } else if (!plan.config.in_subprocess) {
  1949. - loop = new MainLoop();
  1950. - Timeout.add(
  1951. + loop = new MainLoop ();
  1952. + Timeout.add (
  1953. 10,
  1954. - () => {
  1955. - bool res = plan.result.report();
  1956. - if(!res)
  1957. - loop.quit();
  1958. + () => {
  1959. + bool res = plan.result.report ();
  1960. + if (!res)
  1961. + loop.quit ();
  1962. return res;
  1963.  
  1964. },
  1965. Priority.HIGH_IDLE);
  1966. - run_test_internal(plan.root, plan.result, "");
  1967. - loop.run();
  1968. + run_test_internal (plan.root, plan.result, "");
  1969. + loop.run ();
  1970. } else {
  1971. - run_test_internal(plan.root, plan.result, "");
  1972. + run_test_internal (plan.root, plan.result, "");
  1973. }
  1974. return 0;
  1975. }
  1976.  
  1977. - private void list_tests(Test test, string path) {
  1978. - foreach(var subtest in test) {
  1979. - string testpath = "%s/%s".printf(path, subtest.name);
  1980. - if(subtest is TestAdapter)
  1981. - stdout.printf("%s\n", testpath);
  1982. + private void list_tests (Test test, string path) {
  1983. + foreach (var subtest in test) {
  1984. + string testpath = "%s/%s".printf (path, subtest.name);
  1985. + if (subtest is TestAdapter)
  1986. + stdout.printf ("%s\n", testpath);
  1987. else
  1988. - list_tests(subtest, testpath);
  1989. + list_tests (subtest, testpath);
  1990. }
  1991. }
  1992.  
  1993. - public void run_test(Test test, TestResult result) {
  1994. - test.run(result);
  1995. + public void run_test (Test test, TestResult result) {
  1996. + test.run (result);
  1997. }
  1998.  
  1999. - private void run_test_internal(Test test, TestResult result, string path) throws Error {
  2000. + private void run_test_internal (Test test, TestResult result, string path) throws Error {
  2001.  
  2002. - foreach(var subtest in test) {
  2003. + foreach (var subtest in test) {
  2004.  
  2005. - var testpath = "%s/%s".printf(path, subtest.name);
  2006. + var testpath = "%s/%s".printf (path, subtest.name);
  2007.  
  2008. - if(subtest is TestCase) {
  2009. - if(!plan.config.in_subprocess)
  2010. - result.add_test(subtest);
  2011. - run_test_internal(subtest, result, testpath);
  2012. + if (subtest is TestCase) {
  2013. + if (!plan.config.in_subprocess)
  2014. + result.add_test (subtest);
  2015. + run_test_internal (subtest, result, testpath);
  2016. } else if (subtest is TestSuite) {
  2017. - result.add_test(subtest);
  2018. - run_test_internal(subtest, result, testpath);
  2019. + result.add_test (subtest);
  2020. + run_test_internal (subtest, result, testpath);
  2021. } else if (plan.config.in_subprocess) {
  2022. - if(plan.config.running_test == testpath)
  2023. - test.run(result);
  2024. + if (plan.config.running_test == testpath)
  2025. + test.run (result);
  2026. } else if (subtest is TestAdapter) {
  2027. subtest.name = testpath;
  2028. - result.add_test(subtest);
  2029. - run_async.begin(subtest, result);
  2030. + result.add_test (subtest);
  2031. + run_async.begin (subtest, result);
  2032. }
  2033. }
  2034. }
  2035.  
  2036. - private async void run_async(Test test, TestResult result) throws Error
  2037. - requires(plan.config.in_subprocess != true) {
  2038. + private async void run_async (Test test, TestResult result) throws Error
  2039. + requires (plan.config.in_subprocess != true) {
  2040. var timeout = plan.config.timeout;
  2041. - var testprog = plan.assembly.clone();
  2042. + var testprog = plan.assembly.clone ();
  2043. if (_n_ongoing_tests > _max_n_ongoing_tests) {
  2044. - var wrapper = new DelegateWrapper();
  2045. + var wrapper = new DelegateWrapper ();
  2046. wrapper.cb = run_async.callback;
  2047. - _pending_tests.push_tail((owned)wrapper);
  2048. + _pending_tests.push_tail ((owned)wrapper);
  2049. yield;
  2050. }
  2051.  
  2052. @@ -119,47 +119,47 @@ public class Valadate.TestRunner {
  2053. _n_ongoing_tests++;
  2054. var cancellable = new Cancellable ();
  2055. var tcase = test as TestAdapter;
  2056. - if(timeout != tcase.timeout)
  2057. + if (timeout != tcase.timeout)
  2058. timeout = tcase.timeout;
  2059.  
  2060. var time = new TimeoutSource (timeout);
  2061.  
  2062. cancellable.cancelled.connect (() => {
  2063. - testprog.quit();
  2064. + testprog.quit ();
  2065. });
  2066.  
  2067. time.set_callback (() => {
  2068. if (tcase.status == TestStatus.RUNNING)
  2069. - cancellable.cancel();
  2070. + cancellable.cancel ();
  2071. return false;
  2072. });
  2073. - time.attach (loop.get_context());
  2074. + time.attach (loop.get_context ());
  2075.  
  2076. - testprog.run("-r %s".printf(test.name), cancellable);
  2077. - result.add_success(test);
  2078. - result.process_buffers(test, testprog);
  2079. + testprog.run ("-r %s".printf (test.name), cancellable);
  2080. + result.add_success (test);
  2081. + result.process_buffers (test, testprog);
  2082. } catch (IOError e) {
  2083. - result.add_error(test, "The test timed out after %d milliseconds".printf(timeout));
  2084. - result.process_buffers(test, testprog);
  2085. + result.add_error (test, "The test timed out after %d milliseconds".printf (timeout));
  2086. + result.process_buffers (test, testprog);
  2087. } catch (Error e) {
  2088. - result.add_error(test, e.message);
  2089. - result.process_buffers(test, testprog);
  2090. + result.add_error (test, e.message);
  2091. + result.process_buffers (test, testprog);
  2092. } finally {
  2093. - result.report();
  2094. + result.report ();
  2095. _n_ongoing_tests--;
  2096. var wrapper = _pending_tests.pop_head ();
  2097. - if(wrapper != null)
  2098. - wrapper.cb();
  2099. + if (wrapper != null)
  2100. + wrapper.cb ();
  2101. }
  2102. }
  2103.  
  2104. public static int main (string[] args) {
  2105. try {
  2106. - var assembly = new TestAssembly(args);
  2107. - var testplan = new TestPlan(assembly);
  2108. - return testplan.run();
  2109. + var assembly = new TestAssembly (args);
  2110. + var testplan = new TestPlan (assembly);
  2111. + return testplan.run ();
  2112. } catch (Error e) {
  2113. - error(e.message);
  2114. + error (e.message);
  2115. }
  2116. }
  2117.  
  2118. diff --git a/valadate/testsuite.vala b/valadate/testsuite.vala
  2119. index 6b0239cb..1009f661 100644
  2120. --- a/valadate/testsuite.vala
  2121. +++ b/valadate/testsuite.vala
  2122. @@ -22,7 +22,7 @@
  2123.  
  2124. public class Valadate.TestSuite : Object, Test {
  2125.  
  2126. - private List<Test> _tests = new List<Test>();
  2127. + private List<Test> _tests = new List<Test> ();
  2128. /**
  2129. * the name of the TestSuite
  2130. */
  2131. @@ -36,7 +36,7 @@ public class Valadate.TestSuite : Object, Test {
  2132. */
  2133. public int size {
  2134. get {
  2135. - return (int)_tests.length();
  2136. + return (int)_tests.length ();
  2137. }
  2138. }
  2139. /**
  2140. @@ -46,7 +46,7 @@ public class Valadate.TestSuite : Object, Test {
  2141. public int count {
  2142. get {
  2143. int testcount = 0;
  2144. - _tests.foreach((t) => {
  2145. + _tests.foreach ((t) => {
  2146. testcount += t.count;
  2147. });
  2148. return testcount;
  2149. @@ -71,41 +71,41 @@ public class Valadate.TestSuite : Object, Test {
  2150. * The public constructor takes an optional string parameter for the
  2151. * TestSuite's name
  2152. */
  2153. - public TestSuite(string? name = null) {
  2154. - this.name = name ?? this.get_type().name();
  2155. + public TestSuite (string? name = null) {
  2156. + this.name = name ?? this.get_type ().name ();
  2157. this.label = name;
  2158. }
  2159. /**
  2160. * Adds a test to the suite.
  2161. */
  2162. - public void add_test(Test test) {
  2163. + public void add_test (Test test) {
  2164. test.parent = this;
  2165. - _tests.append(test);
  2166. + _tests.append (test);
  2167. }
  2168. /**
  2169. * Runs all of the tests in the Suite
  2170. */
  2171. public void run (TestResult result) {
  2172.  
  2173. - if(status != TestStatus.NOT_RUN)
  2174. + if (status != TestStatus.NOT_RUN)
  2175. return;
  2176.  
  2177. - _tests.foreach((t) => {
  2178. - t.run(result);
  2179. + _tests.foreach ((t) => {
  2180. + t.run (result);
  2181. });
  2182. }
  2183.  
  2184. - public new Test get(int index) {
  2185. - return _tests.nth_data((uint)index);
  2186. + public new Test get (int index) {
  2187. + return _tests.nth_data ((uint)index);
  2188. }
  2189.  
  2190. - public new void set(int index, Test test) {
  2191. + public new void set (int index, Test test) {
  2192. test.parent = this;
  2193. - _tests.insert_before(_tests.nth(index), test);
  2194. - var t = _tests.nth_data((uint)index++);
  2195. - _tests.remove(t);
  2196. + _tests.insert_before (_tests.nth (index), test);
  2197. + var t = _tests.nth_data ((uint)index++);
  2198. + _tests.remove (t);
  2199. }
  2200.  
  2201. - public virtual void set_up() {}
  2202. - public virtual void tear_down() {}
  2203. + public virtual void set_up () {}
  2204. + public virtual void tear_down () {}
  2205. }
  2206. diff --git a/valadate/xmlfile.vala b/valadate/xmlfile.vala
  2207. index 682f6a29..ab0a6d8c 100644
  2208. --- a/valadate/xmlfile.vala
  2209. +++ b/valadate/xmlfile.vala
  2210. @@ -30,27 +30,27 @@ public class Valadate.XmlSearchResults {
  2211.  
  2212. public int size {
  2213. get {
  2214. - if(result == null || result->type != Xml.XPath.ObjectType.NODESET || result->nodesetval == null)
  2215. + if (result == null || result->type != Xml.XPath.ObjectType.NODESET || result->nodesetval == null)
  2216. return 0;
  2217. - return result->nodesetval->length();
  2218. + return result->nodesetval->length ();
  2219. }
  2220. }
  2221.  
  2222. - public void* get(int i)
  2223. - requires(size > 0)
  2224. - requires(i < size)
  2225. - requires(i >= 0)
  2226. + public void* get (int i)
  2227. + requires (size > 0)
  2228. + requires (i < size)
  2229. + requires (i >= 0)
  2230. {
  2231. return result->nodesetval->item (i);
  2232. }
  2233.  
  2234.  
  2235. - internal XmlSearchResults(Xml.XPath.Object* result) {
  2236. + internal XmlSearchResults (Xml.XPath.Object* result) {
  2237. this.result = result;
  2238. }
  2239.  
  2240. - ~XmlSearchResults() {
  2241. - if(result != null) delete result;
  2242. + ~XmlSearchResults () {
  2243. + if (result != null) delete result;
  2244. }
  2245.  
  2246. }
  2247. @@ -61,49 +61,49 @@ public class Valadate.XmlFile {
  2248. private Xml.XPath.Context context;
  2249. private bool owns_doc = false;
  2250.  
  2251. - public XmlFile(File path) throws Error {
  2252. - this.from_doc(Xml.Parser.parse_file(path.get_path()));
  2253. + public XmlFile (File path) throws Error {
  2254. + this.from_doc (Xml.Parser.parse_file (path.get_path ()));
  2255. owns_doc = true;
  2256. }
  2257.  
  2258. - internal XmlFile.from_doc(Xml.Doc* xmldoc) throws Error {
  2259. + internal XmlFile.from_doc (Xml.Doc* xmldoc) throws Error {
  2260. document = xmldoc;
  2261. owns_doc = true;
  2262.  
  2263. if (document == null)
  2264. - throw new XmlFileError.ERROR(
  2265. + throw new XmlFileError.ERROR (
  2266. "There was an error parsing the Xml.Doc");
  2267.  
  2268. - set_context();
  2269. + set_context ();
  2270. }
  2271.  
  2272. - public XmlFile.from_string(string xml) throws Error {
  2273. - document = Xml.Parser.read_memory(xml, xml.length, null, null,
  2274. + public XmlFile.from_string (string xml) throws Error {
  2275. + document = Xml.Parser.read_memory (xml, xml.length, null, null,
  2276. Xml.ParserOption.RECOVER | Xml.ParserOption.NOERROR |
  2277. Xml.ParserOption.NOWARNING | Xml.ParserOption.NOBLANKS);
  2278. owns_doc = true;
  2279.  
  2280. if (document == null)
  2281. - throw new XmlFileError.ERROR(
  2282. + throw new XmlFileError.ERROR (
  2283. "There was an error parsing the string %s", xml);
  2284. - set_context();
  2285. + set_context ();
  2286. }
  2287.  
  2288. - private void set_context() {
  2289. + private void set_context () {
  2290. context = new Xml.XPath.Context (document);
  2291. }
  2292.  
  2293. - ~XmlFile() {
  2294. + ~XmlFile () {
  2295. if (owns_doc)
  2296. delete document;
  2297. }
  2298.  
  2299. - public void register_ns(string prefix, string ns) {
  2300. - context.register_ns(prefix, ns);
  2301. + public void register_ns (string prefix, string ns) {
  2302. + context.register_ns (prefix, ns);
  2303. }
  2304.  
  2305. - public XmlSearchResults eval(string expression) {
  2306. - return new XmlSearchResults(context.eval_expression (expression));
  2307. + public XmlSearchResults eval (string expression) {
  2308. + return new XmlSearchResults (context.eval_expression (expression));
  2309. }
  2310.  
  2311. }
  2312. diff --git a/valadate/xmltestreportprinter.vala b/valadate/xmltestreportprinter.vala
  2313. index e389c7d1..47b1757a 100644
  2314. --- a/valadate/xmltestreportprinter.vala
  2315. +++ b/valadate/xmltestreportprinter.vala
  2316. @@ -35,36 +35,36 @@ public class Valadate.XmlTestReportPrinter : TestReportPrinter {
  2317. private int testcount = -1;
  2318. private int casecount = -1;
  2319.  
  2320. - public XmlTestReportPrinter(TestConfig config) throws Error {
  2321. - base(config);
  2322. + public XmlTestReportPrinter (TestConfig config) throws Error {
  2323. + base (config);
  2324. this.config = config;
  2325. - xml = new XmlFile.from_string(XML_DECL + TESTSUITES_XML);
  2326. + xml = new XmlFile.from_string (XML_DECL + TESTSUITES_XML);
  2327. }
  2328.  
  2329. - public override void print(TestReport report) {
  2330. - Xml.Node* root = xml.eval("//testsuites")[0];
  2331. - Xml.Node* node = report.xml.eval("//testsuite | //testcase")[0];
  2332. + public override void print (TestReport report) {
  2333. + Xml.Node* root = xml.eval ("//testsuites")[0];
  2334. + Xml.Node* node = report.xml.eval ("//testsuite | //testcase")[0];
  2335.  
  2336. - if(report.test is TestSuite) {
  2337. - if(testsuite == null) {
  2338. + if (report.test is TestSuite) {
  2339. + if (testsuite == null) {
  2340. testcount = report.test.count;
  2341. - testsuite = root->add_child(node->copy_list());
  2342. + testsuite = root->add_child (node->copy_list ());
  2343. } else {
  2344. oldtestsuite = testsuite;
  2345. - testsuite = testsuite->add_child(node->copy_list());
  2346. + testsuite = testsuite->add_child (node->copy_list ());
  2347. }
  2348. } else if (report.test is TestCase) {
  2349. oldtestsuite = testsuite;
  2350. - testsuite = testsuite->add_child(node->copy_list());
  2351. + testsuite = testsuite->add_child (node->copy_list ());
  2352. casecount = report.test.count;
  2353. - } else if(report.test is TestAdapter) {
  2354. - testsuite->add_child(node->copy_list());
  2355. + } else if (report.test is TestAdapter) {
  2356. + testsuite->add_child (node->copy_list ());
  2357. testcount--;
  2358. casecount--;
  2359. - if(casecount == 0)
  2360. + if (casecount == 0)
  2361. testsuite = oldtestsuite;
  2362. }
  2363. - if(testcount == 0)
  2364. - root->doc->dump_format(stdout);
  2365. + if (testcount == 0)
  2366. + root->doc->dump_format (stdout);
  2367. }
  2368. }
  2369. --
  2370. 2.11.0
  2371.  
  2372. From be8dcc9e974b1787d9bdfc7aca586457ea673d6b Mon Sep 17 00:00:00 2001
  2373. From: Rico Tzschichholz <ricotz@ubuntu.com>
  2374. Date: Fri, 28 Apr 2017 20:13:15 +0200
  2375. Subject: [PATCH 2/2] Trailing spaces
  2376.  
  2377. ---
  2378. tests/valatests.vala | 16 ++++++++--------
  2379. tests/valatestsfactory.vala | 18 +++++++++---------
  2380. valadate/assembly.vala | 8 ++++----
  2381. valadate/assemblyerror.vala | 2 +-
  2382. valadate/gnutestreportprinter.vala | 14 +++++++-------
  2383. valadate/taptestreportprinter.vala | 18 +++++++++---------
  2384. valadate/test.vala | 2 +-
  2385. valadate/testadapter.vala | 2 +-
  2386. valadate/testassembly.vala | 12 ++++++------
  2387. valadate/testcase.vala | 6 +++---
  2388. valadate/testerror.vala | 10 +++++-----
  2389. valadate/testexplorer.vala | 6 +++---
  2390. valadate/testgatherer.vala | 12 ++++++------
  2391. valadate/testmodule.vala | 6 +++---
  2392. valadate/testplan.vala | 32 ++++++++++++++++----------------
  2393. valadate/testreport.vala | 32 ++++++++++++++++----------------
  2394. valadate/testreportprinter.vala | 14 +++++++-------
  2395. valadate/testresult.vala | 12 ++++++------
  2396. valadate/testrunner.vala | 20 ++++++++++----------
  2397. valadate/testsuite.vala | 2 +-
  2398. valadate/xmlfile.vala | 18 +++++++++---------
  2399. valadate/xmltestreportprinter.vala | 14 +++++++-------
  2400. 22 files changed, 138 insertions(+), 138 deletions(-)
  2401.  
  2402. diff --git a/tests/valatests.vala b/tests/valatests.vala
  2403. index b1faf099..7a90d659 100644
  2404. --- a/tests/valatests.vala
  2405. +++ b/tests/valatests.vala
  2406. @@ -1,31 +1,31 @@
  2407. /**
  2408. * Vala.Tests
  2409. - *
  2410. + *
  2411. * Searchs all of the sub directories in the current directory for
  2412. * *.vala or *.test files, compiles and runs them.
  2413. - *
  2414. + *
  2415. * If the test is a self contained application (has its own main entry
  2416. * point), it will compile and run it. The test is deemed succesful if
  2417. * it compiles and runs without error.
  2418. - *
  2419. + *
  2420. * If the test is a .test file it will be parsed, the components
  2421. * assembled, compiled and run. The test is deemed succesful if
  2422. * it compiles and runs without error.
  2423. - *
  2424. + *
  2425. * The tests can be run against the system compiler or the one in the
  2426. * source tree. This can be used to verify if a patch or other change
  2427. * to the compiler either fixes a bug or causes a regression (or both)
  2428. */
  2429.  
  2430. public class Vala.Tests : Valadate.TestSuite {
  2431. -
  2432. +
  2433. private const string BUGZILLA_URL = "http://bugzilla.gnome.org/";
  2434.  
  2435. construct {
  2436. try {
  2437. var testdir = File.new_for_path (GLib.Environment.get_variable ("G_TEST_BUILDDIR"));
  2438. var testpath = Valadate.TestOptions.get_current_test_path ();
  2439. -
  2440. +
  2441. if (testpath != null) {
  2442. var testpaths = testpath.split ("/");
  2443. if (testpaths.length < 4)
  2444. @@ -64,7 +64,7 @@ public class Vala.Tests : Valadate.TestSuite {
  2445. private class ValaTest : Valadate.TestCase {
  2446.  
  2447. private TestsFactory factory = TestsFactory.get_instance ();
  2448. -
  2449. +
  2450. public ValaTest (File directory) throws Error {
  2451. this.name = directory.get_basename ();
  2452. this.label = directory.get_path ();
  2453. @@ -99,7 +99,7 @@ public class Vala.Tests : Valadate.TestSuite {
  2454. adapter.label = "/Vala/Tests/%s/%s".printf (
  2455. Path.get_basename (testfile.get_parent ().get_path ()),
  2456. testname);
  2457. -
  2458. +
  2459. adapter.add_test_method (() => {
  2460. try {
  2461. if (testname.has_prefix ("bug"))
  2462. diff --git a/tests/valatestsfactory.vala b/tests/valatestsfactory.vala
  2463. index 7021f938..3f42758d 100644
  2464. --- a/tests/valatestsfactory.vala
  2465. +++ b/tests/valatestsfactory.vala
  2466. @@ -44,7 +44,7 @@ public class Vala.TestsFactory : Object {
  2467. vapidir = File.new_for_path (usevapidir);
  2468. else
  2469. vapidir = buildir.get_child ("vapi");
  2470. -
  2471. +
  2472. }
  2473.  
  2474. private static TestsFactory instance;
  2475. @@ -78,9 +78,9 @@ public class Vala.TestsFactory : Object {
  2476. public Program get_test_program (File testfile) throws Error {
  2477. string basename = testfile.get_basename ();
  2478. string testname = basename.substring (0, basename.last_index_of ("."));
  2479. -
  2480. +
  2481. Program program = null;
  2482. -
  2483. +
  2484. if (basename.has_suffix (".vala") || basename.has_suffix (".gs")) {
  2485. program = compiler.compile (testdir.get_child (testname), testfile, "--main main");
  2486. } else if (basename.has_suffix (".test")) {
  2487. @@ -282,7 +282,7 @@ public class Vala.TestsFactory : Object {
  2488.  
  2489. private const string GIRFOOTER = "\n</namespace>\n</repository>";
  2490.  
  2491. - private const string VAPIHEADER =
  2492. + private const string VAPIHEADER =
  2493. """/* %s.vapi generated by lt-vapigen, do not modify. */
  2494. [CCode (cprefix = "Test", gir_namespace = "Test", gir_version = "1.2", lower_case_cprefix = "test_")]
  2495. namespace Test {""";
  2496. @@ -359,12 +359,12 @@ public class Vala.TestsFactory : Object {
  2497. prog.add_file (binary.get_parent ().get_child (binary.get_basename () + ".c"));
  2498. return prog;
  2499. }
  2500. -
  2501. +
  2502. private string get_flags () throws Error {
  2503. -
  2504. +
  2505. string result = "";
  2506. string[] flags = {"CFLAGS", "CPPFLAGS", "LDFLAGS"};
  2507. -
  2508. +
  2509. foreach (string key in flags) {
  2510. var val = Environment.get_variable (key);
  2511. if (val == null || val.length == 0)
  2512. @@ -376,9 +376,9 @@ public class Vala.TestsFactory : Object {
  2513. foreach (var item in args)
  2514. result += "-X %s ".printf (item);
  2515. }
  2516. -
  2517. +
  2518. return result;
  2519. }
  2520. -
  2521. +
  2522. }
  2523. }
  2524. diff --git a/valadate/assembly.vala b/valadate/assembly.vala
  2525. index b2e08093..aa48c7cf 100644
  2526. --- a/valadate/assembly.vala
  2527. +++ b/valadate/assembly.vala
  2528. @@ -15,15 +15,15 @@
  2529. * You should have received a copy of the GNU Lesser General Public
  2530. * License along with this library; if not, write to the Free Software
  2531. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2532. - *
  2533. + *
  2534. * Authors:
  2535. * Chris Daley <chebizarro@gmail.com>
  2536. */
  2537. -
  2538. +
  2539. public abstract class Valadate.Assembly {
  2540.  
  2541. protected static SubprocessLauncher launcher;
  2542. -
  2543. +
  2544. private static void init_launcher () {
  2545. if (launcher == null) {
  2546. launcher = new SubprocessLauncher (
  2547. @@ -35,7 +35,7 @@ public abstract class Valadate.Assembly {
  2548. launcher.setenv ("G_SLICE","always-malloc debug-blocks",true);
  2549. }
  2550. }
  2551. -
  2552. +
  2553. public File binary {get;set;}
  2554. public InputStream stderr {get;set;}
  2555. public OutputStream stdin {get;set;}
  2556. diff --git a/valadate/assemblyerror.vala b/valadate/assemblyerror.vala
  2557. index aa1b57e8..4c7f2f24 100644
  2558. --- a/valadate/assemblyerror.vala
  2559. +++ b/valadate/assemblyerror.vala
  2560. @@ -15,7 +15,7 @@
  2561. * You should have received a copy of the GNU Lesser General Public
  2562. * License along with this library; if not, write to the Free Software
  2563. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2564. - *
  2565. + *
  2566. * Authors:
  2567. * Chris Daley <chebizarro@gmail.com>
  2568. */
  2569. diff --git a/valadate/gnutestreportprinter.vala b/valadate/gnutestreportprinter.vala
  2570. index 2bc039a5..5de3199b 100644
  2571. --- a/valadate/gnutestreportprinter.vala
  2572. +++ b/valadate/gnutestreportprinter.vala
  2573. @@ -15,20 +15,20 @@
  2574. * You should have received a copy of the GNU Lesser General Public
  2575. * License along with this library; if not, write to the Free Software
  2576. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2577. - *
  2578. + *
  2579. * Authors:
  2580. * Chris Daley <chebizarro@gmail.com>
  2581. */
  2582. public class Valadate.GnuTestReportPrinter : TestReportPrinter {
  2583. -
  2584. +
  2585. private const string TAP_VERSION = "13";
  2586. -
  2587. +
  2588. private List<TestCase> testcases = new List<TestCase> ();
  2589. -
  2590. +
  2591. public GnuTestReportPrinter (TestConfig config) throws Error {
  2592. base (config);
  2593. }
  2594. -
  2595. +
  2596. public override void print (TestReport report) {
  2597.  
  2598. if (report.test is TestSuite) {
  2599. @@ -39,11 +39,11 @@ public class Valadate.GnuTestReportPrinter : TestReportPrinter {
  2600. var test = report.test as TestAdapter;
  2601. var idx = testcases.index (test.parent as TestCase);
  2602. int index = 1;
  2603. -
  2604. +
  2605. if (idx > 0)
  2606. for (int i=0; i<idx;i++)
  2607. index += testcases.nth_data (i).count;
  2608. -
  2609. +
  2610. for (int i=0;i<test.parent.count; i++) {
  2611. if (test.parent[i] == test) {
  2612. index += i;
  2613. diff --git a/valadate/taptestreportprinter.vala b/valadate/taptestreportprinter.vala
  2614. index 7fa2f026..92fb4273 100644
  2615. --- a/valadate/taptestreportprinter.vala
  2616. +++ b/valadate/taptestreportprinter.vala
  2617. @@ -15,17 +15,17 @@
  2618. * You should have received a copy of the GNU Lesser General Public
  2619. * License along with this library; if not, write to the Free Software
  2620. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2621. - *
  2622. + *
  2623. * Authors:
  2624. * Chris Daley <chebizarro@gmail.com>
  2625. */
  2626. -
  2627. +
  2628. public class Valadate.TapTestReportPrinter : TestReportPrinter {
  2629. -
  2630. +
  2631. private const string TAP_VERSION = "13";
  2632. -
  2633. +
  2634. private List<TestCase> testcases = new List<TestCase> ();
  2635. -
  2636. +
  2637. public TapTestReportPrinter (TestConfig config) throws Error {
  2638. base (config);
  2639. if (!config.list_only) {
  2640. @@ -33,12 +33,12 @@ public class Valadate.TapTestReportPrinter : TestReportPrinter {
  2641. stdout.printf ("# random seed: %s\n", config.seed);
  2642. }
  2643. }
  2644. -
  2645. +
  2646. public override void print (TestReport report) {
  2647.  
  2648. if (report.test is TestSuite && report.test.parent.name == "/") {
  2649. stdout.printf ("1..%d\n", report.test.count);
  2650. -
  2651. +
  2652. var props = report.xml.eval ("//properties/property");
  2653. stdout.puts ("# Environment\n");
  2654. foreach (Xml.Node* prop in props) {
  2655. @@ -55,11 +55,11 @@ public class Valadate.TapTestReportPrinter : TestReportPrinter {
  2656. var idx = testcases.index (test.parent as TestCase);
  2657. int index = 1;
  2658. bool lasttest = false;
  2659. -
  2660. +
  2661. if (idx > 0)
  2662. for (int i=0; i<idx;i++)
  2663. index += testcases.nth_data (i).count;
  2664. -
  2665. +
  2666. for (int i=0;i<test.parent.count; i++) {
  2667. if (test.parent[i] == test) {
  2668. index += i;
  2669. diff --git a/valadate/test.vala b/valadate/test.vala
  2670. index 310fbd65..f6350d64 100644
  2671. --- a/valadate/test.vala
  2672. +++ b/valadate/test.vala
  2673. @@ -26,7 +26,7 @@
  2674. */
  2675. public interface Valadate.Test : Object {
  2676. /**
  2677. - * Runs the Tests and collects the results in a TestResult
  2678. + * Runs the Tests and collects the results in a TestResult
  2679. *
  2680. * @param result the TestResult object used to store the results of the Test
  2681. */
  2682. diff --git a/valadate/testadapter.vala b/valadate/testadapter.vala
  2683. index 2b5499f3..e3849f47 100644
  2684. --- a/valadate/testadapter.vala
  2685. +++ b/valadate/testadapter.vala
  2686. @@ -25,7 +25,7 @@ public class Valadate.TestAdapter : Object, Test {
  2687. public string name {get;set;}
  2688. public string label {get;set;}
  2689. public double time {get;set;}
  2690. -
  2691. +
  2692. public int timeout {get;set;}
  2693.  
  2694. public TestStatus status {get;set;default=TestStatus.NOT_RUN;}
  2695. diff --git a/valadate/testassembly.vala b/valadate/testassembly.vala
  2696. index 7c2f8038..18199878 100644
  2697. --- a/valadate/testassembly.vala
  2698. +++ b/valadate/testassembly.vala
  2699. @@ -15,7 +15,7 @@
  2700. * You should have received a copy of the GNU Lesser General Public
  2701. * License along with this library; if not, write to the Free Software
  2702. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2703. - *
  2704. + *
  2705. * Authors:
  2706. * Chris Daley <chebizarro@gmail.com>
  2707. */
  2708. @@ -32,12 +32,12 @@ public class Valadate.TestAssembly : TestModule {
  2709. options = new TestOptions (args);
  2710. setup_dirs ();
  2711. }
  2712. -
  2713. +
  2714. private TestAssembly.copy (TestAssembly other) throws Error {
  2715. base (other.binary);
  2716. options = other.options;
  2717. }
  2718. -
  2719. +
  2720. private void setup_dirs () throws Error {
  2721. var buildstr = Environment.get_variable ("G_TEST_BUILDDIR");
  2722.  
  2723. @@ -50,7 +50,7 @@ public class Valadate.TestAssembly : TestModule {
  2724. }
  2725.  
  2726. var srcstr = Environment.get_variable ("G_TEST_SRCDIR");
  2727. -
  2728. +
  2729. if (srcstr == null) {
  2730. // we're running outside the test harness
  2731. // check for buildir!=srcdir
  2732. @@ -71,7 +71,7 @@ public class Valadate.TestAssembly : TestModule {
  2733. }
  2734. }
  2735. }
  2736. -
  2737. +
  2738. if (srcstr == null)
  2739. srcdir = builddir;
  2740. else
  2741. @@ -81,7 +81,7 @@ public class Valadate.TestAssembly : TestModule {
  2742.  
  2743. if (mesondir.query_exists ())
  2744. srcdir = mesondir;
  2745. -
  2746. +
  2747. Environment.set_variable ("G_TEST_BUILDDIR", builddir.get_path (), true);
  2748. Environment.set_variable ("G_TEST_SRCDIR", srcdir.get_path (), true);
  2749.  
  2750. diff --git a/valadate/testcase.vala b/valadate/testcase.vala
  2751. index 35207ddb..713bec60 100644
  2752. --- a/valadate/testcase.vala
  2753. +++ b/valadate/testcase.vala
  2754. @@ -1,4 +1,4 @@
  2755. -/*
  2756. +/*
  2757. * Valadate - Unit testing library for GObject-based libraries.
  2758. *
  2759. * testcase.vala
  2760. @@ -68,7 +68,7 @@ public abstract class Valadate.TestCase : Object, Test {
  2761. public double time {get;set;}
  2762.  
  2763. public string bug_base {get;set;}
  2764. -
  2765. +
  2766. private List<Test> _tests = new List<Test> ();
  2767.  
  2768. private Test current_test;
  2769. @@ -97,7 +97,7 @@ public abstract class Valadate.TestCase : Object, Test {
  2770. adapter.parent = this;
  2771. _tests.append (adapter);
  2772. }
  2773. -
  2774. +
  2775. public virtual void run (TestResult result) {
  2776. if (status != TestStatus.NOT_RUN)
  2777. return;
  2778. diff --git a/valadate/testerror.vala b/valadate/testerror.vala
  2779. index b173f71a..8262442c 100644
  2780. --- a/valadate/testerror.vala
  2781. +++ b/valadate/testerror.vala
  2782. @@ -1,23 +1,23 @@
  2783. /*
  2784. * Valadate - Unit testing library for GObject-based libraries.
  2785. * Copyright 2017 Chris Daley <bizarro@localhost.localdomain>
  2786. - *
  2787. + *
  2788. * This program is free software; you can redistribute it and/or modify
  2789. * it under the terms of the GNU General Public License as published by
  2790. * the Free Software Foundation; either version 2 of the License, or
  2791. * (at your option) any later version.
  2792. - *
  2793. + *
  2794. * This program is distributed in the hope that it will be useful,
  2795. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2796. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2797. * GNU General Public License for more details.
  2798. - *
  2799. + *
  2800. * You should have received a copy of the GNU General Public License
  2801. * along with this program; if not, write to the Free Software
  2802. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  2803. * MA 02110-1301, USA.
  2804. - *
  2805. - *
  2806. + *
  2807. + *
  2808. */
  2809.  
  2810. public errordomain Valadate.TestError {
  2811. diff --git a/valadate/testexplorer.vala b/valadate/testexplorer.vala
  2812. index df7a0b89..e2f81d97 100644
  2813. --- a/valadate/testexplorer.vala
  2814. +++ b/valadate/testexplorer.vala
  2815. @@ -45,7 +45,7 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
  2816. testplan = testplan.substring (3);
  2817.  
  2818. string testplanfile = testdir + GLib.Path.DIR_SEPARATOR_S + testplan + ".vapi";
  2819. -
  2820. +
  2821. if (!FileUtils.test (testplanfile, FileTest.EXISTS))
  2822. throw new TestConfigError.TESTPLAN ("Test Plan %s Not Found!", testplanfile);
  2823.  
  2824. @@ -65,7 +65,7 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
  2825. parser.parse (context);
  2826. context.accept (this);
  2827. }
  2828. -
  2829. +
  2830. private void setup_context () {
  2831. context = new Vala.CodeContext ();
  2832. Vala.CodeContext.push (context);
  2833. @@ -105,7 +105,7 @@ internal class Valadate.TestExplorer : Vala.CodeVisitor {
  2834. unowned Constructor meth = get_constructor (cl);
  2835. var current_test = meth () as TestCase;
  2836. current_test.name = cl.name;
  2837. -
  2838. +
  2839. foreach (var method in cl.get_methods ()) {
  2840. if (method.name.has_prefix ("test_") &&
  2841. method.has_result != true &&
  2842. diff --git a/valadate/testgatherer.vala b/valadate/testgatherer.vala
  2843. index 67b5d0f0..e61a817a 100644
  2844. --- a/valadate/testgatherer.vala
  2845. +++ b/valadate/testgatherer.vala
  2846. @@ -19,12 +19,12 @@
  2847. * Authors:
  2848. * Chris Daley <chebizarro@gmail.com>
  2849. */
  2850. -
  2851. +
  2852. public class Valadate.TestGatherer : Vala.CodeVisitor {
  2853. -
  2854. - public HashTable<Type, Vala.Class> classes =
  2855. +
  2856. + public HashTable<Type, Vala.Class> classes =
  2857. new HashTable<Type, Vala.Class> (direct_hash, direct_equal);
  2858. -
  2859. +
  2860. private TestAssembly assembly;
  2861.  
  2862. public TestGatherer (TestAssembly assembly) {
  2863. @@ -34,7 +34,7 @@ public class Valadate.TestGatherer : Vala.CodeVisitor {
  2864. public override void visit_namespace (Vala.Namespace ns) {
  2865. ns.accept_children (this);
  2866. }
  2867. -
  2868. +
  2869. public override void visit_class (Vala.Class cls) {
  2870. try {
  2871. var classtype = find_type (cls);
  2872. @@ -45,7 +45,7 @@ public class Valadate.TestGatherer : Vala.CodeVisitor {
  2873. }
  2874. cls.accept_children (this);
  2875. }
  2876. -
  2877. +
  2878. private Type find_type (Vala.Class cls) throws Error {
  2879. var attr = new Vala.CCodeAttribute (cls);
  2880. unowned TestPlan.GetType node_get_type =
  2881. diff --git a/valadate/testmodule.vala b/valadate/testmodule.vala
  2882. index 67122cf0..a0da7bfb 100644
  2883. --- a/valadate/testmodule.vala
  2884. +++ b/valadate/testmodule.vala
  2885. @@ -24,9 +24,9 @@
  2886. * Represents a loadable module containing {@link Valadate.Test}s
  2887. */
  2888. public class Valadate.TestModule : Assembly {
  2889. -
  2890. +
  2891. private GLib.Module module;
  2892. -
  2893. +
  2894. public TestModule (File binary) throws Error {
  2895. base (binary);
  2896. }
  2897. @@ -37,7 +37,7 @@ public class Valadate.TestModule : Assembly {
  2898. throw new AssemblyError.LOAD (GLib.Module.error ());
  2899. module.make_resident ();
  2900. }
  2901. -
  2902. +
  2903. public virtual void* get_method (string method_name) throws AssemblyError {
  2904. if (module == null)
  2905. load_module ();
  2906. diff --git a/valadate/testplan.vala b/valadate/testplan.vala
  2907. index a5dfba9b..9c32b1da 100644
  2908. --- a/valadate/testplan.vala
  2909. +++ b/valadate/testplan.vala
  2910. @@ -15,11 +15,11 @@
  2911. * You should have received a copy of the GNU Lesser General Public
  2912. * License along with this library; if not, write to the Free Software
  2913. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  2914. - *
  2915. + *
  2916. * Authors:
  2917. * Chris Daley <chebizarro@gmail.com>
  2918. */
  2919. -
  2920. +
  2921. public class Valadate.TestPlan : Vala.CodeVisitor {
  2922.  
  2923. [CCode (has_target = false)]
  2924. @@ -28,8 +28,8 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2925. public delegate void AsyncTestMethod (TestCase self, AsyncReadyCallback cb);
  2926. public delegate void AsyncTestMethodResult (TestCase self, AsyncResult res) throws Error;
  2927.  
  2928. - public delegate Type GetType ();
  2929. -
  2930. + public delegate Type GetType ();
  2931. +
  2932. public File plan {get;set;}
  2933.  
  2934. public TestAssembly assembly {get;set;}
  2935. @@ -39,14 +39,14 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2936. public TestConfig config {get;set;}
  2937.  
  2938. public TestResult result {get;set;}
  2939. -
  2940. +
  2941. public TestRunner runner {get;set;}
  2942.  
  2943. public TestSuite root {get;protected set;}
  2944.  
  2945. private Vala.CodeContext context;
  2946. private TestGatherer gatherer;
  2947. - private delegate TestCase Constructor ();
  2948. + private delegate TestCase Constructor ();
  2949. private TestSuite testsuite;
  2950. private TestCase testcase;
  2951.  
  2952. @@ -54,7 +54,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2953.  
  2954. this.assembly = assembly;
  2955. options = assembly.options;
  2956. -
  2957. +
  2958. var plan_name = Path.get_basename (assembly.binary.get_path ());
  2959. if (plan_name.has_prefix ("lt-"))
  2960. plan_name = plan_name.substring (3);
  2961. @@ -113,7 +113,7 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2962. }
  2963. ns.accept_children (this);
  2964. }
  2965. -
  2966. +
  2967. public override void visit_class (Vala.Class cls) {
  2968.  
  2969. try {
  2970. @@ -182,9 +182,9 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2971.  
  2972. if (method.coroutine) {
  2973. try {
  2974. - unowned TestPlan.AsyncTestMethod beginmethod =
  2975. + unowned TestPlan.AsyncTestMethod beginmethod =
  2976. (TestPlan.AsyncTestMethod)assembly.get_method (attr.name);
  2977. - unowned TestPlan.AsyncTestMethodResult testmethod =
  2978. + unowned TestPlan.AsyncTestMethodResult testmethod =
  2979. (TestPlan.AsyncTestMethodResult)assembly.get_method (attr.finish_real_name);
  2980. adapter.add_async_test (beginmethod, testmethod);
  2981. } catch (Error e) {
  2982. @@ -250,12 +250,12 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2983.  
  2984. private bool is_test (Vala.Method method) {
  2985. bool istest = false;
  2986. -
  2987. +
  2988. if (method.is_virtual)
  2989. foreach (var test in testcase)
  2990. if (test.name == method.name)
  2991. return false;
  2992. -
  2993. +
  2994. if (method.name.has_prefix ("test_") ||
  2995. method.name.has_prefix ("_test_") ||
  2996. method.name.has_prefix ("todo_test_"))
  2997. @@ -267,18 +267,18 @@ public class Valadate.TestPlan : Vala.CodeVisitor {
  2998.  
  2999. if (method.has_result)
  3000. istest = false;
  3001. -
  3002. +
  3003. if (method.get_parameters ().size > 0)
  3004. istest = false;
  3005. -
  3006. +
  3007. return istest;
  3008. }
  3009.  
  3010. public void visit_testsuite (Vala.Class testclass) throws Error {
  3011. - unowned Constructor meth = get_constructor (testclass);
  3012. + unowned Constructor meth = get_constructor (testclass);
  3013. var tsuite = meth () as TestSuite;
  3014. tsuite.name = testclass.name;
  3015. testsuite.add_test (tsuite);
  3016. testsuite = tsuite;
  3017. - }
  3018. + }
  3019. }
  3020. diff --git a/valadate/testreport.vala b/valadate/testreport.vala
  3021. index d6fc0bef..d54d982f 100644
  3022. --- a/valadate/testreport.vala
  3023. +++ b/valadate/testreport.vala
  3024. @@ -19,7 +19,7 @@
  3025. * Authors:
  3026. * Chris Daley <chebizarro@gmail.com>
  3027. */
  3028. -
  3029. +
  3030. public class Valadate.TestReport {
  3031.  
  3032. private const string XML_DECL ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  3033. @@ -45,7 +45,7 @@ public class Valadate.TestReport {
  3034.  
  3035. public Test test {get;set;}
  3036. public bool subprocess {get;set;}
  3037. -
  3038. +
  3039. public XmlFile xml {get;set;}
  3040.  
  3041. private static int64 start_time;
  3042. @@ -54,7 +54,7 @@ public class Valadate.TestReport {
  3043. private static Regex regex_err;
  3044. private const string regex_err_string =
  3045. """(\*{2}\n([A-Z]*):([\S]*)([\S ]*)\n)""";
  3046. -
  3047. +
  3048. public TestReport (Test test, bool subprocess) throws Error {
  3049. this.test = test;
  3050. this.subprocess = subprocess;
  3051. @@ -73,11 +73,11 @@ public class Valadate.TestReport {
  3052. else if (test is TestAdapter)
  3053. new_testcase ();
  3054. }
  3055. -
  3056. +
  3057. private void new_testsuite () throws Error {
  3058. if (subprocess)
  3059. return;
  3060. -
  3061. +
  3062. var decl = "%s<%s>%s</%s>".printf (XML_DECL, ROOT_TAG, TESTSUITE_XML, ROOT_TAG);
  3063. var doc = Xml.Parser.read_memory (decl, decl.length);
  3064. var root = doc->get_root_element ()->children;
  3065. @@ -123,7 +123,7 @@ public class Valadate.TestReport {
  3066. test.status = TestStatus.FAILED;
  3067.  
  3068. add_message (FAILURE_TAG, message);
  3069. -
  3070. +
  3071. if (subprocess) {
  3072. emit_timer ();
  3073. stderr.printf ("</%s></%s>",TESTCASE_TAG, ROOT_TAG);
  3074. @@ -157,14 +157,14 @@ public class Valadate.TestReport {
  3075. } else {
  3076. Xml.Node* child = new Xml.Node (null, tag);
  3077. child->set_content (escaped);
  3078. -
  3079. +
  3080. string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
  3081. -
  3082. +
  3083. if (tag in tags) {
  3084. child->new_prop ("message", escaped);
  3085. child->new_prop ("type", tag.up ());
  3086. }
  3087. -
  3088. +
  3089. Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
  3090. root->add_child (child);
  3091. }
  3092. @@ -172,27 +172,27 @@ public class Valadate.TestReport {
  3093. /**
  3094. * Adds arbitrary text to the TestReport. In the xml output this
  3095. * text will be encapsulated in <system-out/> or <system-err/> tag
  3096. - *
  3097. + *
  3098. * @param text The text to be added to the {@link TestReport}.
  3099. * the text will be escaped before being added.
  3100. * @param tag The tag to use for adding the text
  3101. - */
  3102. + */
  3103. public void add_text (string text, string tag) {
  3104. var markup = Markup.escape_text (text);
  3105. Xml.Node* child = new Xml.Node (null, tag);
  3106. child->set_content (markup);
  3107. -
  3108. +
  3109. string[] tags = {ERROR_TAG, FAILURE_TAG, INFO_TAG};
  3110. -
  3111. +
  3112. if (tag in tags) {
  3113. child->new_prop ("message", markup);
  3114. child->new_prop ("type", tag.up ());
  3115. }
  3116. -
  3117. +
  3118. Xml.Node* root = xml.eval ("//testcase | //testsuite")[0];
  3119. root->add_child (child);
  3120. }
  3121. -
  3122. +
  3123. public void update_status () {
  3124. if (test is TestAdapter && !subprocess) {
  3125. Xml.Node* root = xml.eval ("//testcase")[0];
  3126. @@ -235,7 +235,7 @@ public class Valadate.TestReport {
  3127. }
  3128.  
  3129. public void process_buffer (string buffer) throws Error {
  3130. -
  3131. +
  3132. xml = new XmlFile.from_string (buffer);
  3133.  
  3134. var bits = xml.eval ("//testcase/text ()");
  3135. diff --git a/valadate/testreportprinter.vala b/valadate/testreportprinter.vala
  3136. index 2c09c2ee..ab9015a6 100644
  3137. --- a/valadate/testreportprinter.vala
  3138. +++ b/valadate/testreportprinter.vala
  3139. @@ -1,22 +1,22 @@
  3140. /*
  3141. * Valadate - Unit testing library for GObject-based libraries.
  3142. * Copyright (C) 2017 Chris Daley <chebizarro@gmail.com>
  3143. - *
  3144. + *
  3145. * This program is free software; you can redistribute it and/or modify
  3146. * it under the terms of the GNU General Public License as published by
  3147. * the Free Software Foundation; either version 2 of the License, or
  3148. * (at your option) any later version.
  3149. - *
  3150. + *
  3151. * This program is distributed in the hope that it will be useful,
  3152. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3153. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3154. * GNU General Public License for more details.
  3155. - *
  3156. + *
  3157. * You should have received a copy of the GNU General Public License
  3158. * along with this program; if not, write to the Free Software
  3159. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  3160. * MA 02110-1301, USA.
  3161. - *
  3162. + *
  3163. * Authors:
  3164. * Chris Daley <chebizarro@gmail.com>
  3165. */
  3166. @@ -35,13 +35,13 @@ public abstract class Valadate.TestReportPrinter {
  3167. throw new TestConfigError.TEST_PRINTER ("TestReportPrinter %s does not exist", config.format);
  3168. }
  3169. }
  3170. -
  3171. +
  3172. public TestConfig config {get; set;}
  3173. -
  3174. +
  3175. public TestReportPrinter (TestConfig config) throws Error {
  3176. this.config = config;
  3177. }
  3178.  
  3179. public abstract void print (TestReport report);
  3180. -
  3181. +
  3182. }
  3183. diff --git a/valadate/testresult.vala b/valadate/testresult.vala
  3184. index 1dc3bdec..cf917112 100644
  3185. --- a/valadate/testresult.vala
  3186. +++ b/valadate/testresult.vala
  3187. @@ -37,15 +37,15 @@ public class Valadate.TestResult {
  3188. public bool report () {
  3189. if (reports.is_empty ())
  3190. return false;
  3191. -
  3192. +
  3193. var rpt = reports.peek_head ();
  3194. -
  3195. +
  3196. if (rpt.test.status == TestStatus.PASSED ||
  3197. rpt.test.status == TestStatus.SKIPPED ||
  3198. rpt.test.status == TestStatus.TODO ||
  3199. rpt.test.status == TestStatus.FAILED ||
  3200. rpt.test.status == TestStatus.ERROR) {
  3201. -
  3202. +
  3203. printer.print (rpt);
  3204. reports.pop_head ();
  3205. report ();
  3206. @@ -73,7 +73,7 @@ public class Valadate.TestResult {
  3207. }
  3208. parent.status = status;
  3209. update_status (parent);
  3210. - }
  3211. + }
  3212.  
  3213. public void add_test (Test test) {
  3214. try {
  3215. @@ -93,7 +93,7 @@ public class Valadate.TestResult {
  3216. tests.get (test).add_failure (failure);
  3217. update_status (test);
  3218. }
  3219. -
  3220. +
  3221. public void add_success (Test test) {
  3222. tests.get (test).add_success ();
  3223. update_status (test);
  3224. @@ -105,7 +105,7 @@ public class Valadate.TestResult {
  3225. }
  3226.  
  3227. public void process_buffers (Test test, Assembly assembly) throws Error {
  3228. -
  3229. +
  3230. var rept = tests.get (test);
  3231. if (rept == null)
  3232. return;
  3233. diff --git a/valadate/testrunner.vala b/valadate/testrunner.vala
  3234. index 91d17fc4..af9968b6 100644
  3235. --- a/valadate/testrunner.vala
  3236. +++ b/valadate/testrunner.vala
  3237. @@ -15,7 +15,7 @@
  3238. * You should have received a copy of the GNU Lesser General Public
  3239. * License along with this library; if not, write to the Free Software
  3240. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  3241. - *
  3242. + *
  3243. * Authors:
  3244. * Chris Daley <chebizarro@gmail.com>
  3245. */
  3246. @@ -31,7 +31,7 @@ public class Valadate.TestRunner {
  3247. private static uint _max_n_ongoing_tests = GLib.get_num_processors ();
  3248. private MainLoop loop;
  3249. private TestPlan plan;
  3250. -
  3251. +
  3252. public void run (Test test, TestResult result) {
  3253. result.add_test (test);
  3254. test.run (result);
  3255. @@ -40,7 +40,7 @@ public class Valadate.TestRunner {
  3256.  
  3257. public int run_all (TestPlan plan) throws Error {
  3258. this.plan = plan;
  3259. -
  3260. +
  3261. if (plan.config.list_only) {
  3262. list_tests (plan.root, "");
  3263. return 0;
  3264. @@ -55,7 +55,7 @@ public class Valadate.TestRunner {
  3265. if (!res)
  3266. loop.quit ();
  3267. return res;
  3268. -
  3269. +
  3270. },
  3271. Priority.HIGH_IDLE);
  3272. run_test_internal (plan.root, plan.result, "");
  3273. @@ -65,7 +65,7 @@ public class Valadate.TestRunner {
  3274. }
  3275. return 0;
  3276. }
  3277. -
  3278. +
  3279. private void list_tests (Test test, string path) {
  3280. foreach (var subtest in test) {
  3281. string testpath = "%s/%s".printf (path, subtest.name);
  3282. @@ -114,16 +114,16 @@ public class Valadate.TestRunner {
  3283. _pending_tests.push_tail ((owned)wrapper);
  3284. yield;
  3285. }
  3286. -
  3287. +
  3288. try {
  3289. _n_ongoing_tests++;
  3290. var cancellable = new Cancellable ();
  3291. var tcase = test as TestAdapter;
  3292. if (timeout != tcase.timeout)
  3293. timeout = tcase.timeout;
  3294. -
  3295. +
  3296. var time = new TimeoutSource (timeout);
  3297. -
  3298. +
  3299. cancellable.cancelled.connect (() => {
  3300. testprog.quit ();
  3301. });
  3302. @@ -152,7 +152,7 @@ public class Valadate.TestRunner {
  3303. wrapper.cb ();
  3304. }
  3305. }
  3306. -
  3307. +
  3308. public static int main (string[] args) {
  3309. try {
  3310. var assembly = new TestAssembly (args);
  3311. @@ -162,5 +162,5 @@ public class Valadate.TestRunner {
  3312. error (e.message);
  3313. }
  3314. }
  3315. -
  3316. +
  3317. }
  3318. diff --git a/valadate/testsuite.vala b/valadate/testsuite.vala
  3319. index 1009f661..bb4541e3 100644
  3320. --- a/valadate/testsuite.vala
  3321. +++ b/valadate/testsuite.vala
  3322. @@ -40,7 +40,7 @@ public class Valadate.TestSuite : Object, Test {
  3323. }
  3324. }
  3325. /**
  3326. - * Returns the number of {@link Valadate.Test}s that will be run by
  3327. + * Returns the number of {@link Valadate.Test}s that will be run by
  3328. * this TestSuite
  3329. */
  3330. public int count {
  3331. diff --git a/valadate/xmlfile.vala b/valadate/xmlfile.vala
  3332. index ab0a6d8c..28bb3f77 100644
  3333. --- a/valadate/xmlfile.vala
  3334. +++ b/valadate/xmlfile.vala
  3335. @@ -1,17 +1,17 @@
  3336. /*
  3337. * Valadate - Unit testing library for GObject-based libraries.
  3338. * Copyright 2016 Chris Daley <chebizarro@gmail.com>
  3339. - *
  3340. + *
  3341. * This program is free software; you can redistribute it and/or modify
  3342. * it under the terms of the GNU General Public License as published by
  3343. * the Free Software Foundation; either version 2 of the License, or
  3344. * (at your option) any later version.
  3345. - *
  3346. + *
  3347. * This program is distributed in the hope that it will be useful,
  3348. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3349. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3350. * GNU General Public License for more details.
  3351. - *
  3352. + *
  3353. * You should have received a copy of the GNU General Public License
  3354. * along with this program; if not, write to the Free Software
  3355. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  3356. @@ -25,7 +25,7 @@ public errordomain Valadate.XmlFileError {
  3357. }
  3358.  
  3359. public class Valadate.XmlSearchResults {
  3360. -
  3361. +
  3362. private Xml.XPath.Object* result;
  3363.  
  3364. public int size {
  3365. @@ -43,8 +43,8 @@ public class Valadate.XmlSearchResults {
  3366. {
  3367. return result->nodesetval->item (i);
  3368. }
  3369. -
  3370. -
  3371. +
  3372. +
  3373. internal XmlSearchResults (Xml.XPath.Object* result) {
  3374. this.result = result;
  3375. }
  3376. @@ -56,11 +56,11 @@ public class Valadate.XmlSearchResults {
  3377. }
  3378.  
  3379. public class Valadate.XmlFile {
  3380. -
  3381. +
  3382. private Xml.Doc* document;
  3383. private Xml.XPath.Context context;
  3384. private bool owns_doc = false;
  3385. -
  3386. +
  3387. public XmlFile (File path) throws Error {
  3388. this.from_doc (Xml.Parser.parse_file (path.get_path ()));
  3389. owns_doc = true;
  3390. @@ -105,5 +105,5 @@ public class Valadate.XmlFile {
  3391. public XmlSearchResults eval (string expression) {
  3392. return new XmlSearchResults (context.eval_expression (expression));
  3393. }
  3394. -
  3395. +
  3396. }
  3397. diff --git a/valadate/xmltestreportprinter.vala b/valadate/xmltestreportprinter.vala
  3398. index 47b1757a..dc6e7540 100644
  3399. --- a/valadate/xmltestreportprinter.vala
  3400. +++ b/valadate/xmltestreportprinter.vala
  3401. @@ -1,33 +1,33 @@
  3402. /*
  3403. * Valadate - Unit testing library for GObject-based libraries.
  3404. * Copyright (C) 2017 Chris Daley <chebizarro@gmail.com>
  3405. - *
  3406. + *
  3407. * This program is free software; you can redistribute it and/or modify
  3408. * it under the terms of the GNU General Public License as published by
  3409. * the Free Software Foundation; either version 2 of the License, or
  3410. * (at your option) any later version.
  3411. - *
  3412. + *
  3413. * This program is distributed in the hope that it will be useful,
  3414. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3415. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3416. * GNU General Public License for more details.
  3417. - *
  3418. + *
  3419. * You should have received a copy of the GNU General Public License
  3420. * along with this program; if not, write to the Free Software
  3421. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  3422. * MA 02110-1301, USA.
  3423. - *
  3424. + *
  3425. * Authors:
  3426. * Chris Daley <chebizarro@gmail.com>
  3427. */
  3428.  
  3429. public class Valadate.XmlTestReportPrinter : TestReportPrinter {
  3430. -
  3431. +
  3432. private const string XML_DECL ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  3433. private const string TESTSUITES_XML =
  3434. """<testsuites disabled="" errors="" failures="" name="" """ +
  3435. """tests="" time=""></testsuites>""";
  3436. -
  3437. +
  3438. public XmlFile xml {get;set;}
  3439.  
  3440. private Xml.Node* testsuite;
  3441. @@ -63,7 +63,7 @@ public class Valadate.XmlTestReportPrinter : TestReportPrinter {
  3442. casecount--;
  3443. if (casecount == 0)
  3444. testsuite = oldtestsuite;
  3445. - }
  3446. + }
  3447. if (testcount == 0)
  3448. root->doc->dump_format (stdout);
  3449. }
  3450. --
  3451. 2.11.0
Add Comment
Please, Sign In to add comment