Test-Rail-Parser.t 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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' => 117;
  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. is($tap->{'global_status'},6, "Test global result is SKIP on skip all");
  156. }
  157. #Ok, let's test the plan, config, and spawn bits.
  158. undef $tap;
  159. $opts->{'run'} = 'hoo hoo I do not exist';
  160. $opts->{'plan'} = 'mah dubz plan';
  161. $opts->{'configs'} = ['testPlatform1'];
  162. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  163. isnt($res,undef,"TR Parser explodes on instantiation when asking for run not in plan");
  164. undef $tap;
  165. $opts->{'run'} = 'TestingSuite';
  166. $opts->{'configs'} = ['testConfig'];
  167. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  168. is($res,undef,"TR Parser doesn't explode on instantiation looking for existing run in plan");
  169. isa_ok($tap,"Test::Rail::Parser");
  170. if (!$res) {
  171. $tap->run();
  172. is($tap->{'errors'},0,"No errors encountered uploading case results");
  173. }
  174. #Now, test spawning.
  175. undef $tap;
  176. $opts->{'run'} = 'TestingSuite2';
  177. $opts->{'configs'} = ['testPlatform1'];
  178. $opts->{'testsuite_id'} = 9;
  179. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  180. is($res,undef,"TR Parser doesn't explode on instantiation when spawning run in plan");
  181. isa_ok($tap,"Test::Rail::Parser");
  182. if (!$res) {
  183. $tap->run();
  184. is($tap->{'errors'},0,"No errors encountered uploading case results");
  185. }
  186. #Test spawning of builds not in plans.
  187. #Now, test spawning.
  188. undef $tap;
  189. delete $opts->{'testsuite_id'};
  190. delete $opts->{'plan'};
  191. delete $opts->{'configs'};
  192. $opts->{'testsuite'} = 'HAMBURGER-IZE HUMANITY';
  193. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  194. is($res,undef,"TR Parser doesn't explode on instantiation when spawning run in plan");
  195. isa_ok($tap,"Test::Rail::Parser");
  196. if (!$res) {
  197. $tap->run();
  198. is($tap->{'errors'},0,"No errors encountered uploading case results");
  199. }
  200. #Test spawning of plans and runs.
  201. undef $tap;
  202. $opts->{'run'} = 'BogoRun';
  203. $opts->{'plan'} = 'BogoPlan';
  204. $opts->{'testsuite_id'} = 9;
  205. delete $opts->{'testsuite'};
  206. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  207. is($res,undef,"TR Parser doesn't explode on instantiation when spawning run in plan");
  208. isa_ok($tap,"Test::Rail::Parser");
  209. if (!$res) {
  210. $tap->run();
  211. is($tap->{'errors'},0,"No errors encountered uploading case results");
  212. }
  213. #Check that per-section spawn works
  214. undef $tap;
  215. $opts->{'source'} = 't/fake.test';
  216. delete $opts->{'plan'};
  217. $opts->{'sections'} = ['fake.test'];
  218. delete $opts->{'step_results'};
  219. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  220. is($res,undef,"TR Parser doesn't explode on instantiation");
  221. isa_ok($tap,"Test::Rail::Parser");
  222. if (!$res) {
  223. $tap->run();
  224. is($tap->{'errors'},0,"No errors encountered uploading case results");
  225. }
  226. #Check that per-section spawn works
  227. undef $tap;
  228. $opts->{'plan'} = 'BogoPlan';
  229. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  230. is($res,undef,"TR Parser doesn't explode on instantiation");
  231. isa_ok($tap,"Test::Rail::Parser");
  232. if (!$res) {
  233. $tap->run();
  234. is($tap->{'errors'},0,"No errors encountered uploading case results");
  235. }
  236. undef $tap;
  237. $opts->{'sections'} = ['potzrebie'];
  238. delete $opts->{'plan'};
  239. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  240. isnt($res,undef,"TR Parser explodes on instantiation with invalid section");
  241. undef $tap;
  242. $opts->{'source'} = 't/notests.test';
  243. delete $opts->{'sections'};
  244. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  245. is($res,undef,"TR Parser doesn't explode on instantiation");
  246. isa_ok($tap,"Test::Rail::Parser");
  247. if (!$res) {
  248. $tap->run();
  249. is($tap->{'errors'},0,"No errors encountered uploading case results");
  250. is($tap->{'global_status'},4, "Test global result is RETEST on env fail");
  251. }
  252. undef $tap;
  253. $opts->{'source'} = 't/pass.test';
  254. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  255. is($res,undef,"TR Parser doesn't explode on instantiation");
  256. isa_ok($tap,"Test::Rail::Parser");
  257. if (!$res) {
  258. $tap->run();
  259. is($tap->{'errors'},0,"No errors encountered uploading case results");
  260. is($tap->{'global_status'},1, "Test global result is PASS on ok test");
  261. }
  262. undef $tap;
  263. $opts->{'source'} = 't/todo_pass.test';
  264. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  265. is($res,undef,"TR Parser doesn't explode on instantiation");
  266. isa_ok($tap,"Test::Rail::Parser");
  267. if (!$res) {
  268. $tap->run();
  269. is($tap->{'errors'},0,"No errors encountered uploading case results");
  270. is($tap->{'global_status'},8, "Test global result is TODO PASS on todo pass test");
  271. }
  272. undef $tap;
  273. $opts->{'step_results'} = 'bogus_garbage';
  274. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  275. like($res,qr/invalid step results/i,"Bogus step results name throws");
  276. undef $tap;
  277. $opts->{'source'} = 't/todo_pass_and_fail.test';
  278. $opts->{'step_results'} = 'step_results';
  279. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  280. is($res,undef,"TR Parser doesn't explode on instantiation");
  281. isa_ok($tap,"Test::Rail::Parser");
  282. if (!$res) {
  283. capture { $tap->run() };
  284. is($tap->{'errors'},1,"Errors encountered uploading case results for case that does not exist in TestRail");
  285. is($tap->{'global_status'},7, "Test global result is TODO FAIL on todo pass & fail test");
  286. my @desired_statuses = qw{1 8 7};
  287. my @got_statuses = map {$_->{'status_id'}} @{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}};
  288. my @desired_expected = ('OK', 'OK', 'OK');
  289. my @got_expected = map {$_->{'expected'}} @{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}};
  290. my @desired_actual = ('OK', 'TODO PASS', 'TODO FAIL');
  291. my @got_actual = map {$_->{'actual'}} @{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}};
  292. cmp_deeply(\@got_expected,\@desired_expected,"Expected status names look OK");
  293. cmp_deeply(\@got_actual,\@desired_actual,"Actual status names look OK");
  294. cmp_deeply(\@got_statuses,\@desired_statuses,"Step result status codes set correctly");
  295. like($tap->{'tr_opts'}->{'test_notes'},qr/ez duz it/i,"TODO reason captured in test notes");
  296. }
  297. undef $opts->{'step_results'};
  298. undef $tap;
  299. #Check bad plan w/ todo pass logic
  300. $fcontents = "
  301. todo_pass.test ..
  302. 1..2
  303. ok 1 - STORAGE TANKS SEARED #TODO todo pass
  304. # goo
  305. ";
  306. undef $opts->{'source'};
  307. $opts->{'tap'} = $fcontents;
  308. $opts->{'step_results'} = 'step_results';
  309. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  310. is($res,undef,"TR Parser doesn't explode on instantiation");
  311. isa_ok($tap,"Test::Rail::Parser");
  312. if (!$res) {
  313. $tap->run();
  314. is($tap->{'errors'},0,"No errors encountered uploading case results");
  315. is($tap->{'global_status'},5, "Test global result is FAIL on todo pass test w/ bad plan");
  316. my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  317. is($srs->[-1]->{'content'},"Bad Plan.","Bad plan noted in step results");
  318. }
  319. undef $opts->{'step_results'};
  320. #Check instant pizza
  321. $fcontents = "
  322. todo_pass.test ..
  323. 1..2
  324. ";
  325. undef $opts->{'source'};
  326. $opts->{'tap'} = $fcontents;
  327. $opts->{'step_results'} = 'step_results';
  328. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  329. is($res,undef,"TR Parser doesn't explode on instantiation");
  330. isa_ok($tap,"Test::Rail::Parser");
  331. if (!$res) {
  332. $tap->run();
  333. is($tap->{'errors'},0,"No errors encountered uploading case results");
  334. is($tap->{'global_status'},4, "Test global result is retest when insta-bombout occurs");
  335. my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  336. is($srs->[-1]->{'content'},"Bad Plan.","Bad plan noted in step results");
  337. }
  338. undef $opts->{'step_results'};
  339. #Check unplanned tests
  340. $fcontents = "
  341. todo_pass.test ..
  342. 1..1
  343. ok 1 - STORAGE TANKS SEARED
  344. ok 2 - ZIPPPEEE
  345. ";
  346. $opts->{'tap'} = $fcontents;
  347. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  348. is($res,undef,"TR Parser doesn't explode on instantiation");
  349. isa_ok($tap,"Test::Rail::Parser");
  350. if (!$res) {
  351. $tap->run();
  352. is($tap->{'errors'},0,"No errors encountered uploading case results w/ unplanned tests");
  353. is($tap->{'global_status'},5, "Test global result is FAIL when unplanned test seen without case-per-ok");
  354. }
  355. undef $tap;
  356. #Check bad plan w/ todo pass logic
  357. $fcontents = "
  358. todo_pass.test ..
  359. 1..2
  360. ok 1 - STORAGE TANKS SEARED #TODO todo pass
  361. # goo
  362. % mark_status=todo_fail #Appears tanks weren't so sealed after all
  363. ";
  364. undef $opts->{'source'};
  365. $opts->{'tap'} = $fcontents;
  366. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  367. is($res,undef,"TR Parser doesn't explode on instantiation");
  368. isa_ok($tap,"Test::Rail::Parser");
  369. if (!$res) {
  370. $tap->run();
  371. is($tap->{'errors'},0,"No errors encountered uploading case results");
  372. is($tap->{'global_status'},7, "Test global result is respected when using global status override");
  373. }
  374. undef $opts->{'tap'};
  375. #Check autoclose functionality against Run with all tests in run status.
  376. undef $tap;
  377. $opts->{'source'} = 't/skip.test';
  378. $opts->{'run'} = 'FinalRun';
  379. $opts->{'autoclose'} = 1;
  380. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  381. is($res,undef,"TR Parser doesn't explode on instantiation");
  382. isa_ok($tap,"Test::Rail::Parser");
  383. if (!$res) {
  384. $tap->run();
  385. is($tap->{'errors'},0,"No errors encountered uploading case results");
  386. is($tap->{'run_closed'},1, "Run closed by parser when all tests done");
  387. }
  388. #Check autoclose functionality against Run with not all tests in run status.
  389. undef $tap;
  390. $opts->{'source'} = 't/todo_pass.test';
  391. $opts->{'run'} = 'BogoRun';
  392. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  393. is($res,undef,"TR Parser doesn't explode on instantiation");
  394. isa_ok($tap,"Test::Rail::Parser");
  395. if (!$res) {
  396. $tap->run();
  397. is($tap->{'errors'},0,"No errors encountered uploading case results");
  398. is($tap->{'run_closed'},undef, "Run not closed by parser when results are outstanding");
  399. }
  400. #Check that autoclose works against plan with all tests in run status
  401. undef $tap;
  402. $opts->{'source'} = 't/fake.test';
  403. $opts->{'run'} = 'FinalRun';
  404. $opts->{'plan'} = 'FinalPlan';
  405. $opts->{'configs'} = ['testConfig'];
  406. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  407. is($res,undef,"TR Parser doesn't explode on instantiation");
  408. isa_ok($tap,"Test::Rail::Parser");
  409. if (!$res) {
  410. $tap->run();
  411. is($tap->{'errors'},0,"No errors encountered uploading case results");
  412. is($tap->{'plan_closed'},1, "Plan closed by parser when all tests done");
  413. }
  414. #Check that autoclose works against plan with all tests not in run status
  415. undef $tap;
  416. $opts->{'run'} = 'BogoRun';
  417. $opts->{'plan'} = 'BogoPlan';
  418. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  419. is($res,undef,"TR Parser doesn't explode on instantiation");
  420. isa_ok($tap,"Test::Rail::Parser");
  421. if (!$res) {
  422. $tap->run();
  423. is($tap->{'errors'},0,"No errors encountered uploading case results");
  424. is($tap->{'plan_closed'},undef, "Plan not closed by parser when results are outstanding");
  425. }
  426. #Plan but no run 'splodes
  427. undef $tap;
  428. $opts->{'plan'} = 'CompletePlan';
  429. delete $opts->{'run'};
  430. delete $opts->{'configs'};
  431. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  432. like($res,qr/but no run passed/i,"TR Parser explodes on instantiation due to passing plan with no run");
  433. #Check that trying without spawn opts, using completed plan fails
  434. undef $tap;
  435. $opts->{'plan'} = 'ClosedPlan';
  436. $opts->{'run'} = 'BogoRun';
  437. delete $opts->{'testsuite_id'};
  438. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  439. like($res,qr/plan provided is completed/i,"TR Parser explodes on instantiation due to passing closed plan");
  440. #Check that the above two will just spawn a new plan in these cases
  441. $opts->{'testsuite_id'} = 9;
  442. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  443. is($res,undef,"TR Parser runs all the way through on completed run when spawning");
  444. #Check that trying without spawn opts, using completed run fails
  445. undef $tap;
  446. delete $opts->{'testsuite_id'};
  447. delete $opts->{'plan'};
  448. $opts->{'run'} = 'ClosedRun';
  449. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  450. like($res,qr/run provided is completed/i,"TR Parser explodes on instantiation due to passing closed run");
  451. #Check that the above two will just spawn a new run in these cases
  452. $opts->{'testsuite_id'} = 9;
  453. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  454. is($res,undef,"TR Parser runs all the way through on completed run when spawning");
  455. $fcontents = "
  456. todo_pass.test ..
  457. 1..2
  458. ok 1 - STORAGE TANKS SEARED #TODO todo pass
  459. # goo
  460. Bail out! #YOLO
  461. ";
  462. undef $opts->{'source'};
  463. $opts->{'tap'} = $fcontents;
  464. $opts->{'step_results'} = 'step_results';
  465. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  466. is($res,undef,"TR Parser runs all the way through on bailout");
  467. if (!$res) {
  468. $tap->run();
  469. is($tap->{'errors'},0,"No errors encountered uploading case results");
  470. is($tap->{'global_status'},5, "Test global result is FAIL on todo pass test w/ bailout");
  471. my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  472. is($srs->[-1]->{'content'},"Bail Out!.","Bailout noted in step results");
  473. }
  474. #Check section spawn recursion is done correctly
  475. undef $opts->{'tap'};
  476. $opts->{'source'} = 't/pass.test';
  477. $opts->{'testsuite_id'} = 5;
  478. $opts->{'project_id'} = 3;
  479. $opts->{'run'} = 'zippyRun';
  480. $opts->{'sections'} = ['Recursing section','grandchild'];
  481. $res = exception { $tap = Test::Rail::Parser->new($opts) };
  482. is($res,undef,"TR Parser runs all the way through when recursing sections");
  483. if (!$res) {
  484. $tap->run();
  485. is($tap->{'errors'},0,"No errors encountered uploading case results");
  486. }