summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2016-07-12 08:43:31 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2016-07-12 08:43:31 +0100
commite7e8a34938ff589c7ca942b39bfe4021592e9e22 (patch)
treeb92c633c1716cefc60a911598fb21c9beed87c05 /cpan/Test-Simple
parentfb7f2fa30aa1a0ae073687c141e54ee988425430 (diff)
downloadperl-e7e8a34938ff589c7ca942b39bfe4021592e9e22.tar.gz
Upgrade Test-Simple from version 1.302037 to 1.302040
Diffstat (limited to 'cpan/Test-Simple')
-rw-r--r--cpan/Test-Simple/lib/Test/Builder.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Formatter.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Module.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Tester.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/More.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Simple.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Tester.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Tester/Capture.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Tester/Delegate.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/use/ok.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/API.pm41
-rw-r--r--cpan/Test-Simple/lib/Test2/API/Breakage.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/API/Context.pm35
-rw-r--r--cpan/Test-Simple/lib/Test2/API/Instance.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/API/Stack.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event.pm6
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Bail.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Diag.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Exception.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Generic.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Info.pm127
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Note.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Ok.pm7
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Plan.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Skip.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Subtest.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Event/Waiting.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Formatter.pm4
-rw-r--r--cpan/Test-Simple/lib/Test2/Formatter/TAP.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Hub.pm12
-rw-r--r--cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Hub/Subtest.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/IPC.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/IPC/Driver.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Util.pm4
-rw-r--r--cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Util/HashBase.pm2
-rw-r--r--cpan/Test-Simple/lib/Test2/Util/Trace.pm2
-rw-r--r--cpan/Test-Simple/lib/ok.pm2
-rw-r--r--cpan/Test-Simple/t/Test2/modules/API/Context.t19
-rw-r--r--cpan/Test-Simple/t/Test2/modules/Event/Info.t45
47 files changed, 288 insertions, 86 deletions
diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm
index 401cb3cf7e..bc0e095f75 100644
--- a/cpan/Test-Simple/lib/Test/Builder.pm
+++ b/cpan/Test-Simple/lib/Test/Builder.pm
@@ -4,7 +4,7 @@ use 5.006;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN {
if( $] < 5.008 ) {
diff --git a/cpan/Test-Simple/lib/Test/Builder/Formatter.pm b/cpan/Test-Simple/lib/Test/Builder/Formatter.pm
index da09cb22c1..b89beea72d 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Formatter.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Formatter.pm
@@ -2,7 +2,7 @@ package Test::Builder::Formatter;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Formatter::TAP; our @ISA = qw(Test2::Formatter::TAP) }
diff --git a/cpan/Test-Simple/lib/Test/Builder/Module.pm b/cpan/Test-Simple/lib/Test/Builder/Module.pm
index b2db6394c4..165b433344 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Module.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Module.pm
@@ -7,7 +7,7 @@ use Test::Builder;
require Exporter;
our @ISA = qw(Exporter);
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
=head1 NAME
diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester.pm b/cpan/Test-Simple/lib/Test/Builder/Tester.pm
index 455ecf3796..22003f960c 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Tester.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Tester.pm
@@ -1,7 +1,7 @@
package Test::Builder::Tester;
use strict;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test::Builder;
use Symbol;
diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
index 60be59ab2b..9e723ee17a 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
@@ -1,7 +1,7 @@
package Test::Builder::Tester::Color;
use strict;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
require Test::Builder::Tester;
diff --git a/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm b/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm
index 27262118d3..a5d0f6e135 100644
--- a/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm
@@ -2,7 +2,7 @@ package Test::Builder::TodoDiag;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event::Diag; our @ISA = qw(Test2::Event::Diag) }
diff --git a/cpan/Test-Simple/lib/Test/More.pm b/cpan/Test-Simple/lib/Test/More.pm
index 7d69e721f8..01d96533da 100644
--- a/cpan/Test-Simple/lib/Test/More.pm
+++ b/cpan/Test-Simple/lib/Test/More.pm
@@ -17,7 +17,7 @@ sub _carp {
return warn @_, " at $file line $line\n";
}
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test::Builder::Module;
our @ISA = qw(Test::Builder::Module);
diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm
index bffc7e5167..75820c29f0 100644
--- a/cpan/Test-Simple/lib/Test/Simple.pm
+++ b/cpan/Test-Simple/lib/Test/Simple.pm
@@ -4,7 +4,7 @@ use 5.006;
use strict;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test::Builder::Module;
our @ISA = qw(Test::Builder::Module);
diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm
index 1d86981220..bb93920788 100644
--- a/cpan/Test-Simple/lib/Test/Tester.pm
+++ b/cpan/Test-Simple/lib/Test/Tester.pm
@@ -18,7 +18,7 @@ require Exporter;
use vars qw( @ISA @EXPORT );
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
@EXPORT = qw( run_tests check_tests check_test cmp_results show_space );
@ISA = qw( Exporter );
diff --git a/cpan/Test-Simple/lib/Test/Tester/Capture.pm b/cpan/Test-Simple/lib/Test/Tester/Capture.pm
index d6a4c1cfca..0cfa580736 100644
--- a/cpan/Test-Simple/lib/Test/Tester/Capture.pm
+++ b/cpan/Test-Simple/lib/Test/Tester/Capture.pm
@@ -2,7 +2,7 @@ use strict;
package Test::Tester::Capture;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test::Builder;
diff --git a/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm b/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm
index 4a81f22d15..91a48ccce1 100644
--- a/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm
+++ b/cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm
@@ -3,7 +3,7 @@ use strict;
package Test::Tester::CaptureRunner;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test::Tester::Capture;
diff --git a/cpan/Test-Simple/lib/Test/Tester/Delegate.pm b/cpan/Test-Simple/lib/Test/Tester/Delegate.pm
index 9ace7a01e1..080509e2bc 100644
--- a/cpan/Test-Simple/lib/Test/Tester/Delegate.pm
+++ b/cpan/Test-Simple/lib/Test/Tester/Delegate.pm
@@ -3,7 +3,7 @@ use warnings;
package Test::Tester::Delegate;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use vars '$AUTOLOAD';
diff --git a/cpan/Test-Simple/lib/Test/use/ok.pm b/cpan/Test-Simple/lib/Test/use/ok.pm
index 1258906167..a5899cb6b5 100644
--- a/cpan/Test-Simple/lib/Test/use/ok.pm
+++ b/cpan/Test-Simple/lib/Test/use/ok.pm
@@ -1,7 +1,7 @@
package Test::use::ok;
use 5.005;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
__END__
diff --git a/cpan/Test-Simple/lib/Test2.pm b/cpan/Test-Simple/lib/Test2.pm
index 560bba4d88..0ac6c1cc01 100644
--- a/cpan/Test-Simple/lib/Test2.pm
+++ b/cpan/Test-Simple/lib/Test2.pm
@@ -2,7 +2,7 @@ package Test2;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
1;
diff --git a/cpan/Test-Simple/lib/Test2/API.pm b/cpan/Test-Simple/lib/Test2/API.pm
index 31b0d0fcad..0dcf4aa3ab 100644
--- a/cpan/Test-Simple/lib/Test2/API.pm
+++ b/cpan/Test-Simple/lib/Test2/API.pm
@@ -2,7 +2,7 @@ package Test2::API;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
my $INST;
@@ -546,9 +546,9 @@ publicly exposed.
This is done primarily to avoid the problems Test::Builder had by exposing its
singleton. We do not want anyone to replace this singleton, rebless it, or
-directly muck with its internals. If you need to do something, and cannot
-because of the restrictions placed here then please report it as an issue. If
-possible we will create a way for you to implement your functionality without
+directly muck with its internals. If you need to do something and cannot
+because of the restrictions placed here, then please report it as an issue. If
+possible, we will create a way for you to implement your functionality without
exposing things that should not be exposed.
=head1 DESCRIPTION
@@ -623,13 +623,13 @@ generated by the test system:
=head1 MAIN API EXPORTS
-All exports are optional, you must specify subs to import.
+All exports are optional. You must specify subs to import.
use Test2::API qw/context intercept run_subtest/;
This is the list of exports that are most commonly needed. If you are simply
-writing a tool then this is probably all you need. If you need something and
-you cannot find it here then you can also look at L</OTHER API EXPORTS>.
+writing a tool, then this is probably all you need. If you need something and
+you cannot find it here, then you can also look at L</OTHER API EXPORTS>.
These exports lack the 'test2_' prefix because of how important/common they
are. Exports in the L</OTHER API EXPORTS> section have the 'test2_' prefix to
@@ -647,9 +647,9 @@ Usage:
=back
-The C<context()> function will always return the current context to you. If
-there is already a context active it will be returned. If there is not an
-active context one will be generated. When a context is generated it will
+The C<context()> function will always return the current context. If
+there is already a context active, it will be returned. If there is not an
+active context, one will be generated. When a context is generated it will
default to using the file and line number where the currently running sub was
called from.
@@ -709,7 +709,7 @@ with the intent that it should return a context object.
$ctx->release;
}
-If you do not do this than tools you call that also check for a context will
+If you do not do this, then tools you call that also check for a context will
notice that the context they grabbed was created at the same stack depth, which
will trigger protective measures that warn you and destroy the existing
context.
@@ -750,7 +750,7 @@ the callback will be the context object itself.
This lets you provide a callback sub that will be called when the context
instance is released. This callback will be added to the returned context even
-if an existing context is returned. If multiple calls to context add callbacks
+if an existing context is returned. If multiple calls to context add callbacks,
then all will be called in reverse order when the context is finally released.
sub foo {
@@ -830,7 +830,7 @@ will ensure a context is acquired. It will capture and rethrow any exception. It
will insure the context is released when you are done. It preserves the
subroutine call context (array, scalar, void).
-This is the safest way to write a test tool. The only 2 downsides to this are a
+This is the safest way to write a test tool. The only two downsides to this are a
slight performance decrease, and some extra indentation in your source. If the
indentation is a problem for you then you can take a peek at the next section.
@@ -964,7 +964,7 @@ eventually used to populate the C<subevents> attribute on the
L<Test2::Event::Subtest> event that is generated at the end of the subtest.
This flag has no effect on this part, it always happens.
-At the end of the subtest the final L<Test2::Event::Subtest> event is sent to
+At the end of the subtest, the final L<Test2::Event::Subtest> event is sent to
the formatter.
=item Things that are effected by this flag
@@ -988,11 +988,12 @@ sent independently of the final subtest event.
An example of how this is used is the L<Test2::Formatter::TAP> formatter. For
unbuffered subtests the events are rendered as they are generated. At the end
-of the subtest the final subtest event is rendered, but the C<subevents>
+of the subtest, the final subtest event is rendered, but the C<subevents>
attribute is ignored. For buffered subtests the opposite occurs, the events are
NOT rendered as they are generated, instead the C<subevents> attribute is used
to render them all at once. This is useful when running subtests tests in
-parallel, without it the subtests would be garbled.
+parallel, since without it the output from subtests would be interleaved
+together.
=head1 OTHER API EXPORTS
@@ -1002,7 +1003,7 @@ EXPORTS> section before looking here. This section is one where "Great power
comes with great responsibility". It is possible to break things badly if you
are not careful with these.
-All exports are optional, you need to list which ones you want at import time:
+All exports are optional. You need to list which ones you want at import time:
use Test2::API qw/test2_init_done .../;
@@ -1016,7 +1017,7 @@ These provide access to internal state and object instances.
This will return true if the stack and IPC instances have already been
initialized. It will return false if they have not. Init happens as late as
-possible, it happens as soon as a tool requests the IPC instance, the
+possible. It happens as soon as a tool requests the IPC instance, the
formatter, or the stack.
=item $bool = test2_load_done()
@@ -1039,7 +1040,7 @@ multiple END phases.
=item $bool = test2_get_is_end()
-Check if test2 believes it is the END phase.
+Check if Test2 believes it is the END phase.
=item $stack = test2_stack()
@@ -1093,7 +1094,7 @@ If Test2 has already finished loading then the callback will be run immediately.
Add a callback that will be called every time someone tries to acquire a
context. This will be called on EVERY call to C<context()>. It gets a single
-argument, a reference the the hash of parameters being used the construct the
+argument, a reference to the hash of parameters being used the construct the
context. This is your chance to change the parameters by directly altering the
hash.
diff --git a/cpan/Test-Simple/lib/Test2/API/Breakage.pm b/cpan/Test-Simple/lib/Test2/API/Breakage.pm
index 049446d7a6..93d10c08b7 100644
--- a/cpan/Test-Simple/lib/Test2/API/Breakage.pm
+++ b/cpan/Test-Simple/lib/Test2/API/Breakage.pm
@@ -2,7 +2,7 @@ package Test2::API::Breakage;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::Util qw/pkg_to_file/;
diff --git a/cpan/Test-Simple/lib/Test2/API/Context.pm b/cpan/Test-Simple/lib/Test2/API/Context.pm
index 82814018dd..98e5247b1c 100644
--- a/cpan/Test-Simple/lib/Test2/API/Context.pm
+++ b/cpan/Test-Simple/lib/Test2/API/Context.pm
@@ -2,7 +2,7 @@ package Test2::API::Context;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Carp qw/confess croak longmess/;
@@ -19,7 +19,7 @@ my %LOADED = (
my $file = "Test2/Event/$_.pm";
require $file unless $INC{$file};
( $pkg => $pkg, $_ => $pkg )
- } qw/Ok Diag Note Plan Bail Exception Waiting Skip Subtest/
+ } qw/Ok Diag Note Info Plan Bail Exception Waiting Skip Subtest/
);
use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/;
@@ -224,7 +224,7 @@ sub build_event {
sub ok {
my $self = shift;
- my ($pass, $name, $diag) = @_;
+ my ($pass, $name, $on_fail) = @_;
my $hub = $self->{+HUB};
@@ -240,8 +240,15 @@ sub ok {
$self->failure_diag($e);
- if ($diag && @$diag) {
- $self->diag($_) for @$diag
+ if ($on_fail && @$on_fail) {
+ for my $of (@$on_fail) {
+ if (ref($of)) {
+ $self->info($of, diagnostics => 1);
+ }
+ else {
+ $self->diag($of);
+ }
+ }
}
return $e;
@@ -286,6 +293,12 @@ sub skip {
);
}
+sub info {
+ my $self = shift;
+ my ($renderer, %params) = @_;
+ $self->send_event('Info', renderer => $renderer, %params);
+}
+
sub note {
my $self = shift;
my ($message) = @_;
@@ -537,15 +550,21 @@ The value of C<$@> when the context was created.
=item $event = $ctx->ok($bool, $name)
-=item $event = $ctx->ok($bool, $name, \@diag)
+=item $event = $ctx->ok($bool, $name, \@on_fail)
This will create an L<Test2::Event::Ok> object for you. If C<$bool> is false
then an L<Test2::Event::Diag> event will be sent as well with details about the
failure. If you do not want automatic diagnostics you should use the
C<send_event()> method directly.
-The C<\@diag> can contain diagnostics messages you wish to have displayed in the
-event of a failure. For a passing test the diagnostics array will be ignored.
+The third argument C<\@on_fail>) is an optional set of diagnostics to be sent in
+the event of a test failure. Plain strings will be sent as
+L<Test2::Event::Diag> events. References will be used to construct
+L<Test2::Event::Info> events with C<< diagnostics => 1 >>.
+
+=item $event = $ctx->info($renderer, diagnostics => $bool, %other_params)
+
+Send an L<Test2::Event::Info>.
=item $event = $ctx->note($message)
diff --git a/cpan/Test-Simple/lib/Test2/API/Instance.pm b/cpan/Test-Simple/lib/Test2/API/Instance.pm
index 712e1938af..515af627b9 100644
--- a/cpan/Test-Simple/lib/Test2/API/Instance.pm
+++ b/cpan/Test-Simple/lib/Test2/API/Instance.pm
@@ -2,7 +2,7 @@ package Test2::API::Instance;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
our @CARP_NOT = qw/Test2::API Test2::API::Instance Test2::IPC::Driver Test2::Formatter/;
diff --git a/cpan/Test-Simple/lib/Test2/API/Stack.pm b/cpan/Test-Simple/lib/Test2/API/Stack.pm
index fa85f62040..894de47119 100644
--- a/cpan/Test-Simple/lib/Test2/API/Stack.pm
+++ b/cpan/Test-Simple/lib/Test2/API/Stack.pm
@@ -2,7 +2,7 @@ package Test2::API::Stack;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::Hub();
diff --git a/cpan/Test-Simple/lib/Test2/Event.pm b/cpan/Test-Simple/lib/Test2/Event.pm
index 1b0cac0a37..6e1c9253db 100644
--- a/cpan/Test-Simple/lib/Test2/Event.pm
+++ b/cpan/Test-Simple/lib/Test2/Event.pm
@@ -2,7 +2,7 @@ package Test2::Event;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::Util::HashBase qw/trace nested in_subtest subtest_id/;
@@ -142,8 +142,8 @@ instead so that a harness will hide it outside of verbose mode.
=item $msg = $e->summary
This is intended to be a human readable summary of the event. This should
-ideally only be 1-line long, but you can use multiple lines if necessary. This
-is intended for human consumption, you do not need to make it easy for machines
+ideally only be one line long, but you can use multiple lines if necessary. This
+is intended for human consumption. You do not need to make it easy for machines
to understand.
The default is to simply return the event package name.
diff --git a/cpan/Test-Simple/lib/Test2/Event/Bail.pm b/cpan/Test-Simple/lib/Test2/Event/Bail.pm
index 00e7ffc3ac..e95890e327 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Bail.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Bail.pm
@@ -2,7 +2,7 @@ package Test2::Event::Bail;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Diag.pm b/cpan/Test-Simple/lib/Test2/Event/Diag.pm
index e825d73b07..66b1ac5c75 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Diag.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Diag.pm
@@ -2,7 +2,7 @@ package Test2::Event::Diag;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Exception.pm b/cpan/Test-Simple/lib/Test2/Event/Exception.pm
index 70ace48605..d08bde372f 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Exception.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Exception.pm
@@ -2,7 +2,7 @@ package Test2::Event::Exception;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Generic.pm b/cpan/Test-Simple/lib/Test2/Event/Generic.pm
index 78ec6dffc3..69007a2e1e 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Generic.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Generic.pm
@@ -5,7 +5,7 @@ use warnings;
use Carp qw/croak/;
use Scalar::Util qw/reftype/;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
use Test2::Util::HashBase;
diff --git a/cpan/Test-Simple/lib/Test2/Event/Info.pm b/cpan/Test-Simple/lib/Test2/Event/Info.pm
new file mode 100644
index 0000000000..656e272c55
--- /dev/null
+++ b/cpan/Test-Simple/lib/Test2/Event/Info.pm
@@ -0,0 +1,127 @@
+package Test2::Event::Info;
+use strict;
+use warnings;
+
+use Scalar::Util qw/blessed/;
+
+our $VERSION = '1.302040';
+
+BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
+use Test2::Util::HashBase qw/diagnostics renderer/;
+
+sub init {
+ my $self = shift;
+
+ my $r = $self->{+RENDERER} or $self->trace->throw("'renderer' is a required attribute");
+
+ return if ref($r) eq 'CODE';
+ return if blessed($r) && $r->can('render');
+
+ $self->trace->throw("renderer '$r' is not a valid renderer, must be a coderef or an object implementing the 'render()' method");
+}
+
+sub render {
+ my $self = shift;
+ my ($fmt) = @_;
+
+ $fmt ||= 'text';
+
+ my $r = $self->{+RENDERER};
+
+ return $r->($fmt) if ref($r) eq 'CODE';
+ return $r->render($fmt);
+}
+
+sub summary { $_[0]->render($_[1] || 'text') }
+
+1;
+
+__END__
+
+=pod
+
+=encoding UTF-8
+
+=head1 NAME
+
+Test2::Event::Info - Info event base class
+
+=head1 DESCRIPTION
+
+Successor for note and diag events. This event base class supports multiple
+formats. This event makes it possible to send additional information such as
+color and highlighting to the harness.
+
+=head1 SYNOPSIS
+
+ use Test2::API::Context qw/context/;
+
+ $ctx->info($obj, diagnostics => $bool);
+
+=head1 FORMATS
+
+Format will be passed in to C<render()> and C<summary()> as a string. Any
+string is considered valid, if your event does not recognize the format it
+should fallback to 'text'.
+
+=over 4
+
+=item 'text'
+
+Plain and ordinary text.
+
+=item 'ansi'
+
+Text that may include ansi sequences such as colors.
+
+=item 'html'
+
+HTML formatted text.
+
+=back
+
+=head1 ACCESSORS
+
+=over 4
+
+=item $bool = $info->diagnostics()
+
+=item $info->set_diagnostics($bool)
+
+True if this info is essential for diagnostics. The implication is that
+diagnostics will got to STDERR while everything else goes to STDOUT, but that
+is formatter/harness specific.
+
+=back
+
+=head1 SOURCE
+
+The source code repository for Test2 can be found at
+F<http://github.com/Test-More/test-more/>.
+
+=head1 MAINTAINERS
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 AUTHORS
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See F<http://dev.perl.org/licenses/>
+
+=cut
diff --git a/cpan/Test-Simple/lib/Test2/Event/Note.pm b/cpan/Test-Simple/lib/Test2/Event/Note.pm
index 4e24e54de5..1425ce4e31 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Note.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Note.pm
@@ -2,7 +2,7 @@ package Test2::Event::Note;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Ok.pm b/cpan/Test-Simple/lib/Test2/Event/Ok.pm
index 9ccd7cbee7..2b8c31e266 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Ok.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Ok.pm
@@ -2,7 +2,7 @@ package Test2::Event::Ok;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
@@ -84,7 +84,6 @@ or:
'Ok',
pass => $bool,
name => $name,
- diag => \@diag
);
=head1 ACCESSORS
@@ -100,10 +99,6 @@ reduced down to 1 or 0).
Name of the test.
-=item $diag = $e->diag
-
-An arrayref full of diagnostics strings to print in the event of a failure.
-
=item $b = $e->effective_pass
This is the true/false value of the test after TODO and similar modifiers are
diff --git a/cpan/Test-Simple/lib/Test2/Event/Plan.pm b/cpan/Test-Simple/lib/Test2/Event/Plan.pm
index 56b99f1a0b..a7d51b3df8 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Plan.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Plan.pm
@@ -2,7 +2,7 @@ package Test2::Event::Plan;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Skip.pm b/cpan/Test-Simple/lib/Test2/Event/Skip.pm
index b1f9614e4a..71a0a2238d 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Skip.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Skip.pm
@@ -2,7 +2,7 @@ package Test2::Event::Skip;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Subtest.pm b/cpan/Test-Simple/lib/Test2/Event/Subtest.pm
index 28efabaffa..45efddb16b 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Subtest.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Subtest.pm
@@ -2,7 +2,7 @@ package Test2::Event::Subtest;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) }
diff --git a/cpan/Test-Simple/lib/Test2/Event/Waiting.pm b/cpan/Test-Simple/lib/Test2/Event/Waiting.pm
index 4fc5ed35aa..fb41f14d12 100644
--- a/cpan/Test-Simple/lib/Test2/Event/Waiting.pm
+++ b/cpan/Test-Simple/lib/Test2/Event/Waiting.pm
@@ -2,7 +2,7 @@ package Test2::Event::Waiting;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
diff --git a/cpan/Test-Simple/lib/Test2/Formatter.pm b/cpan/Test-Simple/lib/Test2/Formatter.pm
index f83bb7c48f..e258651624 100644
--- a/cpan/Test-Simple/lib/Test2/Formatter.pm
+++ b/cpan/Test-Simple/lib/Test2/Formatter.pm
@@ -2,7 +2,7 @@ package Test2::Formatter;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
my %ADDED;
@@ -50,7 +50,7 @@ A formatter is any package or object with a C<write($event, $num)> method.
1;
-The C<write> method is a method, so it either gets a class or instance. The 2
+The C<write> method is a method, so it either gets a class or instance. The two
arguments are the C<$event> object it should record, and the C<$assert_num>
which is the number of the current assertion (ok), or the last assertion if
this even is not itself an assertion. The assertion number may be any integer 0
diff --git a/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm b/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm
index a610f45972..9243069fde 100644
--- a/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm
+++ b/cpan/Test-Simple/lib/Test2/Formatter/TAP.pm
@@ -3,7 +3,7 @@ use strict;
use warnings;
require PerlIO;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::Util::HashBase qw{
diff --git a/cpan/Test-Simple/lib/Test2/Hub.pm b/cpan/Test-Simple/lib/Test2/Hub.pm
index 89a04f0e1f..d1ba5319bf 100644
--- a/cpan/Test-Simple/lib/Test2/Hub.pm
+++ b/cpan/Test-Simple/lib/Test2/Hub.pm
@@ -2,7 +2,7 @@ package Test2::Hub;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Carp qw/carp croak confess/;
@@ -476,7 +476,7 @@ handle thread/fork sync, filters, listeners, TAP output, etc.
=head2 ALTERING OR REMOVING EVENTS
-You can use either C<filter()> or C<pre_filter()>, which one depends on your
+You can use either C<filter()> or C<pre_filter()>, depending on your
needs. Both have identical syntax, so only C<filter()> is shown here.
$hub->filter(sub {
@@ -499,7 +499,7 @@ needs. Both have identical syntax, so only C<filter()> is shown here.
die "Should not happen";
});
-By default filters are not inherited by child hubs, that means if you start a
+By default, filters are not inherited by child hubs. That means if you start a
subtest, the subtest will not inherit the filter. You can change this behavior
with the C<inherit> parameter:
@@ -515,7 +515,7 @@ with the C<inherit> parameter:
# return is ignored
});
-By default listeners are not inherited by child hubs, that means if you start a
+By default listeners are not inherited by child hubs. That means if you start a
subtest, the subtest will not inherit the listener. You can change this behavior
with the C<inherit> parameter:
@@ -532,7 +532,7 @@ with the C<inherit> parameter:
# Return is ignored
});
-follow_up subs are called only once, ether when done_testing is called, or in
+follow_up subs are called only once, either when done_testing is called, or in
an END block.
=head2 SETTING THE FORMATTER
@@ -543,7 +543,7 @@ By default an instance of L<Test2::Formatter::TAP> is created and used.
Setting the formatter will REPLACE any existing formatter. You may set the
formatter to undef to prevent output. The old formatter will be returned if one
-was already set. Only 1 formatter is allowed at a time.
+was already set. Only one formatter is allowed at a time.
=head1 METHODS
diff --git a/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm b/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm
index 4e98aeabe7..d9dec73c6e 100644
--- a/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm
+++ b/cpan/Test-Simple/lib/Test2/Hub/Interceptor.pm
@@ -2,7 +2,7 @@ package Test2::Hub::Interceptor;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::Hub::Interceptor::Terminator();
diff --git a/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm b/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm
index 00af99f7c3..1fa89130fc 100644
--- a/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm
+++ b/cpan/Test-Simple/lib/Test2/Hub/Interceptor/Terminator.pm
@@ -2,7 +2,7 @@ package Test2::Hub::Interceptor::Terminator;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
1;
diff --git a/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm b/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm
index a050a75d14..96338c22b2 100644
--- a/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm
+++ b/cpan/Test-Simple/lib/Test2/Hub/Subtest.pm
@@ -2,7 +2,7 @@ package Test2::Hub::Subtest;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::Hub; our @ISA = qw(Test2::Hub) }
diff --git a/cpan/Test-Simple/lib/Test2/IPC.pm b/cpan/Test-Simple/lib/Test2/IPC.pm
index 4ceed432ef..4fa952d009 100644
--- a/cpan/Test-Simple/lib/Test2/IPC.pm
+++ b/cpan/Test-Simple/lib/Test2/IPC.pm
@@ -2,7 +2,7 @@ package Test2::IPC;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::API::Instance;
diff --git a/cpan/Test-Simple/lib/Test2/IPC/Driver.pm b/cpan/Test-Simple/lib/Test2/IPC/Driver.pm
index 0df7b50777..2e06eab097 100644
--- a/cpan/Test-Simple/lib/Test2/IPC/Driver.pm
+++ b/cpan/Test-Simple/lib/Test2/IPC/Driver.pm
@@ -2,7 +2,7 @@ package Test2::IPC::Driver;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Carp qw/confess longmess/;
diff --git a/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm b/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm
index e7ff407739..5c9740d275 100644
--- a/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm
+++ b/cpan/Test-Simple/lib/Test2/IPC/Driver/Files.pm
@@ -2,7 +2,7 @@ package Test2::IPC::Driver::Files;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
BEGIN { require Test2::IPC::Driver; our @ISA = qw(Test2::IPC::Driver) }
diff --git a/cpan/Test-Simple/lib/Test2/Util.pm b/cpan/Test-Simple/lib/Test2/Util.pm
index 49d04993f5..299a0be336 100644
--- a/cpan/Test-Simple/lib/Test2/Util.pm
+++ b/cpan/Test-Simple/lib/Test2/Util.pm
@@ -2,7 +2,7 @@ package Test2::Util;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Config qw/%Config/;
@@ -157,7 +157,7 @@ Collection of tools used by L<Test2> and friends.
=head1 EXPORTS
-All exports are optional, you must specify subs to import.
+All exports are optional. You must specify subs to import.
=over 4
diff --git a/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm b/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm
index 54d675b9f2..37ce841710 100644
--- a/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm
+++ b/cpan/Test-Simple/lib/Test2/Util/ExternalMeta.pm
@@ -2,7 +2,7 @@ package Test2::Util::ExternalMeta;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Carp qw/croak/;
diff --git a/cpan/Test-Simple/lib/Test2/Util/HashBase.pm b/cpan/Test-Simple/lib/Test2/Util/HashBase.pm
index 5b6d1e032e..a61b7fb43a 100644
--- a/cpan/Test-Simple/lib/Test2/Util/HashBase.pm
+++ b/cpan/Test-Simple/lib/Test2/Util/HashBase.pm
@@ -2,7 +2,7 @@ package Test2::Util::HashBase;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
require Carp;
diff --git a/cpan/Test-Simple/lib/Test2/Util/Trace.pm b/cpan/Test-Simple/lib/Test2/Util/Trace.pm
index 3c20d90a29..67286f9f5a 100644
--- a/cpan/Test-Simple/lib/Test2/Util/Trace.pm
+++ b/cpan/Test-Simple/lib/Test2/Util/Trace.pm
@@ -2,7 +2,7 @@ package Test2::Util::Trace;
use strict;
use warnings;
-our $VERSION = '1.302037';
+our $VERSION = '1.302040';
use Test2::Util qw/get_tid/;
diff --git a/cpan/Test-Simple/lib/ok.pm b/cpan/Test-Simple/lib/ok.pm
index ce019a7aa9..c8cf3081ba 100644
--- a/cpan/Test-Simple/lib/ok.pm
+++ b/cpan/Test-Simple/lib/ok.pm
@@ -1,5 +1,5 @@
package ok;
-$ok::VERSION = '1.302037';
+$ok::VERSION = '1.302040';
use strict;
use Test::More ();
diff --git a/cpan/Test-Simple/t/Test2/modules/API/Context.t b/cpan/Test-Simple/t/Test2/modules/API/Context.t
index b4ca009f5e..6badc4ff81 100644
--- a/cpan/Test-Simple/t/Test2/modules/API/Context.t
+++ b/cpan/Test-Simple/t/Test2/modules/API/Context.t
@@ -333,10 +333,15 @@ sub {
}->();
{
+ {
+ package An::Info::Thingy;
+ sub render { 'zzz' }
+ }
+
my ($e1, $e2);
my $events = intercept {
my $ctx = context();
- $e1 = $ctx->ok(0, 'foo', ['xxx']);
+ $e1 = $ctx->ok(0, 'foo', ['xxx', sub { 'yyy' }, bless({}, 'An::Info::Thingy')]);
$e2 = $ctx->ok(0, 'foo');
$ctx->release;
};
@@ -345,9 +350,19 @@ sub {
ok($e2->isa('Test2::Event::Ok'), "returned ok event");
is($events->[0], $e1, "got ok event 1");
- is($events->[3], $e2, "got ok event 2");
is($events->[2]->message, 'xxx', "event 1 diag 2");
+ ok($events->[2]->isa('Test2::Event::Diag'), "event 1 diag 2 is diag");
+
+ is($events->[3]->summary, 'yyy', "event 1 info 1");
+ is($events->[3]->diagnostics, 1, "event 1 info 1 is diagnostics");
+ ok($events->[3]->isa('Test2::Event::Info'), "event 1 info 1 is an info");
+
+ is($events->[4]->summary, 'zzz', "event 1 info 2");
+ is($events->[4]->diagnostics, 1, "event 1 info 2 is diagnostics");
+ ok($events->[4]->isa('Test2::Event::Info'), "event 2 info 1 is an info");
+
+ is($events->[5], $e2, "got ok event 2");
}
sub {
diff --git a/cpan/Test-Simple/t/Test2/modules/Event/Info.t b/cpan/Test-Simple/t/Test2/modules/Event/Info.t
new file mode 100644
index 0000000000..8bf9d7812d
--- /dev/null
+++ b/cpan/Test-Simple/t/Test2/modules/Event/Info.t
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+BEGIN { require "t/tools.pl" };
+
+use Test2::Event::Info;
+use Test2::Util::Trace;
+
+my @got;
+
+my $info = Test2::Event::Info->new(
+ trace => Test2::Util::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__]),
+ renderer => sub { @got = @_; 'foo' },
+);
+
+is($info->summary, 'foo', "summary is just rendering");
+is_deeply(\@got, ['text'], "got text");
+
+is($info->summary('blah'), 'foo', "summary is just rendering (arg)");
+is_deeply(\@got, ['blah'], "got arg");
+
+{
+ package An::Info::Thingy;
+ sub render { shift; @got = @_; 'foo' }
+}
+
+$info = Test2::Event::Info->new(
+ trace => Test2::Util::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__]),
+ renderer => bless({}, 'An::Info::Thingy'),
+);
+
+is($info->summary, 'foo', "summary is just rendering");
+is_deeply(\@got, ['text'], "got text");
+
+is($info->summary('blah'), 'foo', "summary is just rendering (arg)");
+is_deeply(\@got, ['blah'], "got arg");
+
+eval { Test2::Event::Info->new(trace => Test2::Util::Trace->new(frame => ['Foo', 'foo.pl', 42])) };
+like(
+ $@,
+ qr/'renderer' is a required attribute at foo\.pl line 42/,
+ "Got expected error"
+);
+
+done_testing;