Commit | Line | Data |
---|---|---|
b4514920 CG |
1 | package Test2::Event::Bail; |
2 | use strict; | |
3 | use warnings; | |
4 | ||
061828b3 | 5 | our $VERSION = '1.302059'; |
b4514920 CG |
6 | |
7 | ||
58818a66 | 8 | BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } |
b4514920 CG |
9 | use Test2::Util::HashBase qw{reason}; |
10 | ||
11 | sub callback { | |
12 | my $self = shift; | |
13 | my ($hub) = @_; | |
14 | ||
15 | $hub->set_bailed_out($self); | |
16 | } | |
17 | ||
18 | # Make sure the tests terminate | |
19 | sub terminate { 255 }; | |
20 | ||
21 | sub global { 1 }; | |
22 | ||
23 | sub causes_fail { 1 } | |
24 | ||
25 | sub summary { | |
26 | my $self = shift; | |
27 | return "Bail out! " . $self->{+REASON} | |
28 | if $self->{+REASON}; | |
29 | ||
30 | return "Bail out!"; | |
31 | } | |
32 | ||
33 | sub diagnostics { 1 } | |
34 | ||
35 | 1; | |
36 | ||
37 | __END__ | |
38 | ||
39 | =pod | |
40 | ||
41 | =encoding UTF-8 | |
42 | ||
43 | =head1 NAME | |
44 | ||
45 | Test2::Event::Bail - Bailout! | |
46 | ||
47 | =head1 DESCRIPTION | |
48 | ||
49 | The bailout event is generated when things go horribly wrong and you need to | |
50 | halt all testing in the current file. | |
51 | ||
52 | =head1 SYNOPSIS | |
53 | ||
54 | use Test2::API qw/context/; | |
55 | use Test2::Event::Bail; | |
56 | ||
57 | my $ctx = context(); | |
58 | my $event = $ctx->bail('Stuff is broken'); | |
59 | ||
60 | =head1 METHODS | |
61 | ||
62 | Inherits from L<Test2::Event>. Also defines: | |
63 | ||
64 | =over 4 | |
65 | ||
66 | =item $reason = $e->reason | |
67 | ||
68 | The reason for the bailout. | |
69 | ||
70 | =back | |
71 | ||
72 | =head1 SOURCE | |
73 | ||
74 | The source code repository for Test2 can be found at | |
75 | F<http://github.com/Test-More/test-more/>. | |
76 | ||
77 | =head1 MAINTAINERS | |
78 | ||
79 | =over 4 | |
80 | ||
81 | =item Chad Granum E<lt>exodist@cpan.orgE<gt> | |
82 | ||
83 | =back | |
84 | ||
85 | =head1 AUTHORS | |
86 | ||
87 | =over 4 | |
88 | ||
89 | =item Chad Granum E<lt>exodist@cpan.orgE<gt> | |
90 | ||
91 | =back | |
92 | ||
93 | =head1 COPYRIGHT | |
94 | ||
95 | Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>. | |
96 | ||
97 | This program is free software; you can redistribute it and/or | |
98 | modify it under the same terms as Perl itself. | |
99 | ||
100 | See F<http://dev.perl.org/licenses/> | |
101 | ||
102 | =cut |