Test-Rail-Parser.t 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use FindBin;
  5. use lib "$FindBin::Bin/lib";
  6. use Scalar::Util qw{reftype};
  7. use TestRail::API;
  8. use Test::LWP::UserAgent::TestRailMock;
  9. use Test::Rail::Parser;
  10. use Test::More 'tests' => 119;
  11. use Test::Fatal qw{exception};
  12. use Test::Deep qw{cmp_deeply};
  13. use Capture::Tiny qw{capture};
  14. #Same song and dance as in TestRail-API.t
  15. my $apiurl = $ENV{'TESTRAIL_API_URL'};
  16. my $login = $ENV{'TESTRAIL_USER'};
  17. my $pw = $ENV{'TESTRAIL_PASSWORD'};
  18. my $is_mock = (!$apiurl && !$login && !$pw);
  19. ($apiurl,$login,$pw) = ('http://testrail.local','teodesian@cpan.org','fake') if $is_mock;
  20. my ($debug,$browser);
  21. $debug = 1;
  22. if ($is_mock) {
  23. $browser = $Test::LWP::UserAgent::TestRailMock::mockObject;
  24. }
  25. #test exceptions...
  26. #TODO
  27. my $fcontents = "
  28. fake.test ..
  29. 1..2
  30. ok 1 - STORAGE TANKS SEARED
  31. #goo
  32. not ok 2 - NOT SO SEARED AFTER ARR
  33. ";
  34. my $tap;
  35. my $opts = {
  36. 'tap' => $fcontents,
  37. 'apiurl' => $apiurl,
  38. 'user' => $login,
  39. 'pass' => $pw,
  40. 'debug' => $debug,
  41. 'browser' => $browser,
  42. 'run' => 'TestingSuite',
  43. 'project' => 'TestProject',
  44. 'merge' => 1,
  45. };
  46. my $res = exception { $tap = Test::Rail::Parser->new($opts) };
  47. is($res,undef,"TR Parser doesn't explode on instantiation");
  48. isa_ok($tap,"Test::Rail::Parser");
  49. if (!$res) {
  50. $tap->run();
  51. is($tap->{'errors'},0,"No errors encountered uploading case results");
  52. }
  53. undef $tap;
  54. delete $opts->{'tap'};
  55. $opts->{'source'} = 't/fake.test';
  56. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  57. is($res,undef,"TR Parser doesn't explode on instantiation");
  58. isa_ok($tap,"Test::Rail::Parser");
  59. if (!$res) {
  60. $tap->run();
  61. is($tap->{'errors'},0,"No errors encountered uploading case results");
  62. }
  63. $fcontents = "fake.test...
  64. ok 1 - STORAGE TANKS SEARED
  65. # whee
  66. not ok 2 - NOT SO SEARED AFTER ARR
  67. # Failed test 'NOT SO SEARED AFTER ARR'
  68. # at t/fake.test line 10.
  69. # Looks like you failed 1 test of 2.
  70. ";
  71. like($tap->{'raw_output'},qr/SEARED\n# whee.*\n.*AFTER ARR\n\n.*Failed/msxi,"Full raw content uploaded in non step results mode");
  72. #Check that time run is being uploaded
  73. my $timeResults = $tap->{'tr_opts'}->{'testrail'}->getTestResults(1);
  74. if ( ( reftype($timeResults) || 'undef') eq 'ARRAY') {
  75. is( $timeResults->[0]->{'elapsed'}, '2s', "Plugin correctly sets elapsed time");
  76. } else {
  77. fail("Could not get test results to check elapsed time!");
  78. }
  79. #Check the time formatting routine.
  80. is(Test::Rail::Parser::_compute_elapsed(0,0),undef,"Elapsed computation correct at second boundary");
  81. is(Test::Rail::Parser::_compute_elapsed(0,61),'1m 1s',"Elapsed computation correct at minute boundary");
  82. is(Test::Rail::Parser::_compute_elapsed(0,3661),'1h 1m 1s',"Elapsed computation correct at hour boundary");
  83. is(Test::Rail::Parser::_compute_elapsed(0,86461),'24h 1m 1s',"Elapsed computation correct at day boundary");
  84. undef $tap;
  85. $opts->{'source'} = 't/faker.test';
  86. $opts->{'run'} = 'OtherOtherSuite';
  87. $opts->{'step_results'} = 'step_results';
  88. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  89. is($res,undef,"TR Parser doesn't explode on instantiation");
  90. isa_ok($tap,"Test::Rail::Parser");
  91. if (!$res) {
  92. $tap->run();
  93. is($tap->{'errors'},0,"No errors encountered uploading case results");
  94. is($tap->{'global_status'},5, "Test global result is FAIL when one subtest fails even if there are TODO passes");
  95. subtest 'Timestamp/elapsed printed in step results' => sub {
  96. foreach my $result (@{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}}) {
  97. like($result->{'content'}, qr/^\[.*\(.*\)\]/i, "Timestamp printed in step results");
  98. }
  99. };
  100. }
  101. #Default mode
  102. undef $tap;
  103. delete $opts->{'step_results'};
  104. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  105. is($res,undef,"TR Parser doesn't explode on instantiation");
  106. isa_ok($tap,"Test::Rail::Parser");
  107. if (!$res) {
  108. $tap->run();
  109. is($tap->{'errors'},0,"No errors encountered uploading case results");
  110. my @matches = $tap->{'raw_output'} =~ m/^(\[.*\(.*\)\])/msgi;
  111. ok(scalar(@matches),"Timestamps present in raw TAP");
  112. }
  113. #Default mode
  114. undef $tap;
  115. $fcontents = "
  116. fake.test ..
  117. 1..2
  118. ok 1 - STORAGE TANKS SEARED
  119. #Subtest NOT SO SEARED AFTER ARR
  120. ok 1 - STROGGIFY POPULATION CENTERS
  121. not ok 2 - STROGGIFY POPULATION CENTERS
  122. #goo
  123. not ok 2 - NOT SO SEARED AFTER ARR
  124. ";
  125. $opts->{'tap'} = $fcontents;
  126. delete $opts->{'source'};
  127. delete $opts->{'step_results'};
  128. $opts->{'run'} = 'TestingSuite';
  129. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  130. is($res,undef,"TR Parser doesn't explode on instantiation");
  131. isa_ok($tap,"Test::Rail::Parser");
  132. if (!$res) {
  133. $tap->run();
  134. is($tap->{'errors'},0,"No errors encountered uploading case results");
  135. }
  136. undef $tap;
  137. delete $opts->{'tap'};
  138. $opts->{'source'} = 't/skip.test';
  139. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  140. is($res,undef,"TR Parser doesn't explode on instantiation");
  141. isa_ok($tap,"Test::Rail::Parser");
  142. if (!$res) {
  143. $tap->run();
  144. is($tap->{'errors'},0,"No errors encountered uploading case results");
  145. }
  146. #Default mode skip (skip_all)
  147. undef $tap;
  148. $opts->{'source'} = 't/skipall.test';
  149. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  150. is($res,undef,"TR Parser doesn't explode on instantiation");
  151. isa_ok($tap,"Test::Rail::Parser");
  152. if (!$res) {
  153. $tap->run();
  154. is($tap->{'errors'},0,"No errors encountered uploading case results");
  155. like( $tap->{raw_output}, qr/cause I can/i, "SKIP_ALL reason recorded"); diag $tap->{raw_output};
  156. is($tap->{'global_status'},6, "Test global result is SKIP on skip all");
  157. }
  158. #Ok, let's test the plan, config, and spawn bits.
  159. undef $tap;
  160. $opts->{'run'} = 'hoo hoo I do not exist';
  161. $opts->{'plan'} = 'mah dubz plan';
  162. $opts->{'configs'} = ['testPlatform1'];
  163. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  164. isnt($res,undef,"TR Parser explodes on instantiation when asking for run not in plan");
  165. undef $tap;
  166. $opts->{'run'} = 'TestingSuite';
  167. $opts->{'configs'} = ['testConfig'];
  168. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  169. is($res,undef,"TR Parser doesn't explode on instantiation looking for existing run in plan");
  170. isa_ok($tap,"Test::Rail::Parser");
  171. if (!$res) {
  172. $tap->run();
  173. is($tap->{'errors'},0,"No errors encountered uploading case results");
  174. }
  175. #Now, test spawning.
  176. undef $tap;
  177. $opts->{'run'} = 'TestingSuite2';
  178. $opts->{'configs'} = ['testPlatform1'];
  179. $opts->{'testsuite_id'} = 9;
  180. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  181. is($res,undef,"TR Parser doesn't explode on instantiation when spawning run in plan");
  182. isa_ok($tap,"Test::Rail::Parser");
  183. if (!$res) {
  184. $tap->run();
  185. is($tap->{'errors'},0,"No errors encountered uploading case results");
  186. }
  187. #Test spawning of builds not in plans.
  188. #Now, test spawning.
  189. undef $tap;
  190. delete $opts->{'testsuite_id'};
  191. delete $opts->{'plan'};
  192. delete $opts->{'configs'};
  193. $opts->{'testsuite'} = 'HAMBURGER-IZE HUMANITY';
  194. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  195. is($res,undef,"TR Parser doesn't explode on instantiation when spawning run in plan");
  196. isa_ok($tap,"Test::Rail::Parser");
  197. if (!$res) {
  198. $tap->run();
  199. is($tap->{'errors'},0,"No errors encountered uploading case results");
  200. }
  201. #Test spawning of plans and runs.
  202. undef $tap;
  203. $opts->{'run'} = 'BogoRun';
  204. $opts->{'plan'} = 'BogoPlan';
  205. $opts->{'testsuite_id'} = 9;
  206. delete $opts->{'testsuite'};
  207. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  208. is($res,undef,"TR Parser doesn't explode on instantiation when spawning run in plan");
  209. isa_ok($tap,"Test::Rail::Parser");
  210. if (!$res) {
  211. $tap->run();
  212. is($tap->{'errors'},0,"No errors encountered uploading case results");
  213. }
  214. #Check that per-section spawn works
  215. undef $tap;
  216. $opts->{'source'} = 't/fake.test';
  217. delete $opts->{'plan'};
  218. $opts->{'sections'} = ['fake.test'];
  219. delete $opts->{'step_results'};
  220. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  221. is($res,undef,"TR Parser doesn't explode on instantiation");
  222. isa_ok($tap,"Test::Rail::Parser");
  223. if (!$res) {
  224. $tap->run();
  225. is($tap->{'errors'},0,"No errors encountered uploading case results");
  226. }
  227. #Check that per-section spawn works
  228. undef $tap;
  229. $opts->{'plan'} = 'BogoPlan';
  230. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  231. is($res,undef,"TR Parser doesn't explode on instantiation");
  232. isa_ok($tap,"Test::Rail::Parser");
  233. if (!$res) {
  234. $tap->run();
  235. is($tap->{'errors'},0,"No errors encountered uploading case results");
  236. }
  237. undef $tap;
  238. $opts->{'sections'} = ['potzrebie'];
  239. delete $opts->{'plan'};
  240. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  241. isnt($res,undef,"TR Parser explodes on instantiation with invalid section");
  242. undef $tap;
  243. $opts->{'source'} = 't/notests.test';
  244. delete $opts->{'sections'};
  245. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  246. is($res,undef,"TR Parser doesn't explode on instantiation");
  247. isa_ok($tap,"Test::Rail::Parser");
  248. if (!$res) {
  249. $tap->run();
  250. is($tap->{'errors'},0,"No errors encountered uploading case results");
  251. is($tap->{'global_status'},4, "Test global result is RETEST on env fail");
  252. }
  253. undef $tap;
  254. $opts->{'source'} = 't/pass.test';
  255. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  256. is($res,undef,"TR Parser doesn't explode on instantiation");
  257. isa_ok($tap,"Test::Rail::Parser");
  258. if (!$res) {
  259. $tap->run();
  260. is($tap->{'errors'},0,"No errors encountered uploading case results");
  261. is($tap->{'global_status'},1, "Test global result is PASS on ok test");
  262. }
  263. undef $tap;
  264. $opts->{'source'} = 't/todo_pass.test';
  265. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  266. is($res,undef,"TR Parser doesn't explode on instantiation");
  267. isa_ok($tap,"Test::Rail::Parser");
  268. if (!$res) {
  269. $tap->run();
  270. is($tap->{'errors'},0,"No errors encountered uploading case results");
  271. is($tap->{'global_status'},8, "Test global result is TODO PASS on todo pass test");
  272. }
  273. undef $tap;
  274. $opts->{'step_results'} = 'bogus_garbage';
  275. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  276. like($res,qr/invalid step results/i,"Bogus step results name throws");
  277. undef $tap;
  278. $opts->{'source'} = 't/todo_pass_and_fail.test';
  279. $opts->{'step_results'} = 'step_results';
  280. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  281. is($res,undef,"TR Parser doesn't explode on instantiation");
  282. isa_ok($tap,"Test::Rail::Parser");
  283. if (!$res) {
  284. capture { $tap->run() };
  285. is($tap->{'errors'},1,"Errors encountered uploading case results for case that does not exist in TestRail");
  286. is($tap->{'global_status'},7, "Test global result is TODO FAIL on todo pass & fail test");
  287. my @desired_statuses = qw{1 8 7};
  288. my @got_statuses = map {$_->{'status_id'}} @{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}};
  289. my @desired_expected = ('OK', 'OK', 'OK');
  290. my @got_expected = map {$_->{'expected'}} @{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}};
  291. my @desired_actual = ('OK', 'TODO PASS', 'TODO FAIL');
  292. my @got_actual = map {$_->{'actual'}} @{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}};
  293. cmp_deeply(\@got_expected,\@desired_expected,"Expected status names look OK");
  294. cmp_deeply(\@got_actual,\@desired_actual,"Actual status names look OK");
  295. cmp_deeply(\@got_statuses,\@desired_statuses,"Step result status codes set correctly");
  296. like($tap->{'tr_opts'}->{'test_notes'},qr/ez duz it/i,"TODO reason captured in test notes");
  297. }
  298. undef $opts->{'step_results'};
  299. undef $tap;
  300. #Check bad plan w/ todo pass logic
  301. $fcontents = "
  302. todo_pass.test ..
  303. 1..2
  304. ok 1 - STORAGE TANKS SEARED #TODO todo pass
  305. # goo
  306. ";
  307. undef $opts->{'source'};
  308. $opts->{'tap'} = $fcontents;
  309. $opts->{'step_results'} = 'step_results';
  310. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  311. is($res,undef,"TR Parser doesn't explode on instantiation");
  312. isa_ok($tap,"Test::Rail::Parser");
  313. if (!$res) {
  314. $tap->run();
  315. is($tap->{'errors'},0,"No errors encountered uploading case results");
  316. is($tap->{'global_status'},5, "Test global result is FAIL on todo pass test w/ bad plan");
  317. my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  318. is($srs->[-1]->{'content'},"Bad Plan.","Bad plan noted in step results");
  319. }
  320. undef $opts->{'step_results'};
  321. #Check instant pizza
  322. $fcontents = "
  323. todo_pass.test ..
  324. 1..2
  325. ";
  326. undef $opts->{'source'};
  327. $opts->{'tap'} = $fcontents;
  328. $opts->{'step_results'} = 'step_results';
  329. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  330. is($res,undef,"TR Parser doesn't explode on instantiation");
  331. isa_ok($tap,"Test::Rail::Parser");
  332. if (!$res) {
  333. $tap->run();
  334. is($tap->{'errors'},0,"No errors encountered uploading case results");
  335. is($tap->{'global_status'},4, "Test global result is retest when insta-bombout occurs");
  336. my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  337. is($srs->[-1]->{'content'},"Bad Plan.","Bad plan noted in step results");
  338. }
  339. undef $opts->{'step_results'};
  340. #Check unplanned tests
  341. $fcontents = "
  342. todo_pass.test ..
  343. 1..1
  344. ok 1 - STORAGE TANKS SEARED
  345. ok 2 - ZIPPPEEE
  346. ";
  347. $opts->{'tap'} = $fcontents;
  348. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  349. is($res,undef,"TR Parser doesn't explode on instantiation");
  350. isa_ok($tap,"Test::Rail::Parser");
  351. if (!$res) {
  352. $tap->run();
  353. is($tap->{'errors'},0,"No errors encountered uploading case results w/ unplanned tests");
  354. is($tap->{'global_status'},5, "Test global result is FAIL when unplanned test seen without case-per-ok");
  355. }
  356. undef $tap;
  357. #Check bad plan w/ todo pass logic
  358. $fcontents = "
  359. todo_pass.test ..
  360. 1..2
  361. ok 1 - STORAGE TANKS SEARED #TODO todo pass
  362. # goo
  363. % mark_status=todo_fail #Appears tanks weren't so sealed after all
  364. ";
  365. undef $opts->{'source'};
  366. $opts->{'tap'} = $fcontents;
  367. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  368. is($res,undef,"TR Parser doesn't explode on instantiation");
  369. isa_ok($tap,"Test::Rail::Parser");
  370. if (!$res) {
  371. $tap->run();
  372. is($tap->{'errors'},0,"No errors encountered uploading case results");
  373. is($tap->{'global_status'},7, "Test global result is respected when using global status override");
  374. }
  375. undef $opts->{'tap'};
  376. #Check autoclose functionality against Run with all tests in run status.
  377. undef $tap;
  378. $opts->{'source'} = 't/skip.test';
  379. $opts->{'run'} = 'FinalRun';
  380. $opts->{'autoclose'} = 1;
  381. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  382. is($res,undef,"TR Parser doesn't explode on instantiation");
  383. isa_ok($tap,"Test::Rail::Parser");
  384. if (!$res) {
  385. $tap->run();
  386. is($tap->{'errors'},0,"No errors encountered uploading case results");
  387. is($tap->{'run_closed'},1, "Run closed by parser when all tests done");
  388. }
  389. #Check autoclose functionality against Run with not all tests in run status.
  390. undef $tap;
  391. $opts->{'source'} = 't/todo_pass.test';
  392. $opts->{'run'} = 'BogoRun';
  393. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  394. is($res,undef,"TR Parser doesn't explode on instantiation");
  395. isa_ok($tap,"Test::Rail::Parser");
  396. if (!$res) {
  397. $tap->run();
  398. is($tap->{'errors'},0,"No errors encountered uploading case results");
  399. is($tap->{'run_closed'},undef, "Run not closed by parser when results are outstanding");
  400. }
  401. #Check that autoclose works against plan with all tests in run status
  402. undef $tap;
  403. $opts->{'source'} = 't/fake.test';
  404. $opts->{'run'} = 'FinalRun';
  405. $opts->{'plan'} = 'FinalPlan';
  406. $opts->{'configs'} = ['testConfig'];
  407. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  408. is($res,undef,"TR Parser doesn't explode on instantiation");
  409. isa_ok($tap,"Test::Rail::Parser");
  410. if (!$res) {
  411. $tap->run();
  412. is($tap->{'errors'},0,"No errors encountered uploading case results");
  413. is($tap->{'plan_closed'},1, "Plan closed by parser when all tests done");
  414. }
  415. #Check that autoclose works against plan with all tests not in run status
  416. undef $tap;
  417. $opts->{'run'} = 'BogoRun';
  418. $opts->{'plan'} = 'BogoPlan';
  419. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  420. is($res,undef,"TR Parser doesn't explode on instantiation");
  421. isa_ok($tap,"Test::Rail::Parser");
  422. if (!$res) {
  423. $tap->run();
  424. is($tap->{'errors'},0,"No errors encountered uploading case results");
  425. is($tap->{'plan_closed'},undef, "Plan not closed by parser when results are outstanding");
  426. }
  427. #Plan but no run 'splodes
  428. undef $tap;
  429. $opts->{'plan'} = 'CompletePlan';
  430. delete $opts->{'run'};
  431. delete $opts->{'configs'};
  432. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  433. like($res,qr/but no run passed/i,"TR Parser explodes on instantiation due to passing plan with no run");
  434. #Check that trying without spawn opts, using completed plan fails
  435. undef $tap;
  436. $opts->{'plan'} = 'ClosedPlan';
  437. $opts->{'run'} = 'BogoRun';
  438. delete $opts->{'testsuite_id'};
  439. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  440. like($res,qr/plan provided is completed/i,"TR Parser explodes on instantiation due to passing closed plan");
  441. #Check that the above two will just spawn a new plan in these cases
  442. $opts->{'testsuite_id'} = 9;
  443. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  444. is($res,undef,"TR Parser runs all the way through on completed run when spawning");
  445. #Check that trying without spawn opts, using completed run fails
  446. undef $tap;
  447. delete $opts->{'testsuite_id'};
  448. delete $opts->{'plan'};
  449. $opts->{'run'} = 'ClosedRun';
  450. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  451. like($res,qr/run provided is completed/i,"TR Parser explodes on instantiation due to passing closed run");
  452. #Check that the above two will just spawn a new run in these cases
  453. $opts->{'testsuite_id'} = 9;
  454. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  455. is($res,undef,"TR Parser runs all the way through on completed run when spawning");
  456. $fcontents = "
  457. todo_pass.test ..
  458. 1..2
  459. ok 1 - STORAGE TANKS SEARED #TODO todo pass
  460. # goo
  461. Bail out! #YOLO
  462. ";
  463. undef $opts->{'source'};
  464. $opts->{'tap'} = $fcontents;
  465. $opts->{'step_results'} = 'step_results';
  466. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  467. is($res,undef,"TR Parser runs all the way through on bailout");
  468. if (!$res) {
  469. $tap->run();
  470. is($tap->{'errors'},0,"No errors encountered uploading case results");
  471. is($tap->{'global_status'},5, "Test global result is FAIL on todo pass test w/ bailout");
  472. my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  473. is($srs->[-1]->{'content'},"Bail Out!.","Bailout noted in step results");
  474. }
  475. #Check section spawn recursion is done correctly
  476. undef $opts->{'tap'};
  477. $opts->{'source'} = 't/pass.test';
  478. $opts->{'testsuite_id'} = 5;
  479. $opts->{'project_id'} = 3;
  480. $opts->{'run'} = 'zippyRun';
  481. $opts->{'sections'} = ['Recursing section','grandchild'];
  482. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  483. is($res,undef,"TR Parser runs all the way through when recursing sections");
  484. if (!$res) {
  485. $tap->run();
  486. is($tap->{'errors'},0,"No errors encountered uploading case results");
  487. }
  488. #Check configuration group spawn is done correctly
  489. undef $opts->{'tap'};
  490. $opts->{'source'} = 't/pass.test';
  491. $opts->{'project_id'} = 9;
  492. $opts->{'run'} = 'TestingSuite';
  493. $opts->{'plan'} = 'mah dubz plan';
  494. $opts->{'config_group'} = 'noSuchGroup';
  495. $opts->{'configs'} = ['noSuchConfig'];
  496. $opts->{'sections'} = [];
  497. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  498. is($res,undef,"TR Parser runs all the way through when spawning configurations");