1use strict; 2use warnings; 3use Test2::Tools::Tiny; 4use Test2::Event::Bail; 5use Test2::EventFacet::Trace; 6 7my $bail = Test2::Event::Bail->new( 8 trace => Test2::EventFacet::Trace->new(frame => ['foo', 'foo.t', 42]), 9 reason => 'evil', 10); 11 12ok($bail->causes_fail, "bailout always causes fail."); 13 14is($bail->terminate, 255, "Bail will cause the test to exit."); 15is($bail->global, 1, "Bail is global, everything should bail"); 16 17is($bail->summary, "Bail out! evil", "Summary includes reason"); 18$bail->set_reason(""); 19is($bail->summary, "Bail out!", "Summary has no reason"); 20 21ok($bail->diagnostics, "Bail events are counted as diagnostics"); 22 23is_deeply( 24 $bail->facet_data, 25 { 26 about => { 27 package => 'Test2::Event::Bail', 28 eid => $bail->eid, 29 }, 30 control => { 31 global => 1, 32 terminate => 255, 33 details => '', 34 halt => 1 35 }, 36 trace => { 37 frame => [ 38 'foo', 39 'foo.t', 40 '42', 41 ], 42 pid => $$, 43 tid => 0 44 }, 45 }, 46 "Got facet data", 47); 48 49$bail->set_reason('uhg'); 50is_deeply( 51 $bail->facet_data, 52 { 53 about => { 54 package => 'Test2::Event::Bail', 55 eid => $bail->eid, 56 }, 57 control => { 58 global => 1, 59 terminate => 255, 60 details => 'uhg', 61 halt => 1 62 }, 63 trace => { 64 frame => [ 65 'foo', 66 'foo.t', 67 '42', 68 ], 69 pid => $$, 70 tid => 0 71 }, 72 }, 73 "Got facet data with reason", 74); 75 76done_testing; 77