[PATCH] update to latest Test-Simple dev release #15101
Comments
From @exodistThis updates Test-Simple to the latest dev release. This dev release is The idea where is to get this into perl blead for testing and smoking -Chad |
From @exodistI did some initial checking, I ran the test suite both with and without the Ultimately there is a 4.8% speed difference. in an ~11 minute run this I would welcome and appreciate anyone who wants to independently check this On Wed, Dec 23, 2015 at 10:21 AM, Chad Granum <perlbug-followup@perl.org>
|
From @jkeenanOn Wed Dec 23 13:21:14 2015, exodist7@gmail.com wrote:
Smoke-testing in this branch: -- |
The RT System itself - Status changed from 'new' to 'open' |
From @exodistHere is a second patch, it should be applied after the first. This patch fixes some TAP output issues. |
From @exodist0001-Bugfixes-for-Test2-Test-Simple.patchFrom 97d36f3c1035838d1d4e90e85785ec332d0827d7 Mon Sep 17 00:00:00 2001
From: Chad Granum <exodist7@gmail.com>
Date: Mon, 28 Dec 2015 11:50:40 -0800
Subject: [PATCH] Bugfixes for Test2+Test-Simple
This patch introduces fixes for the last patch on these. The fixes are
related to changes in TAP output that have been reverted.
---
MANIFEST | 1 +
cpan/Test-Simple/lib/Test/Builder.pm | 12 +-
cpan/Test-Simple/lib/Test/Builder/Module.pm | 2 +-
cpan/Test-Simple/lib/Test/Builder/Tester.pm | 2 +-
cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm | 2 +-
cpan/Test-Simple/lib/Test/More.pm | 2 +-
cpan/Test-Simple/lib/Test/Simple.pm | 2 +-
cpan/Test-Simple/lib/Test/Tester.pm | 2 +-
cpan/Test-Simple/lib/Test/use/ok.pm | 2 +-
cpan/Test-Simple/lib/ok.pm | 2 +-
cpan/Test2/lib/Test2.pm | 2 +-
cpan/Test2/lib/Test2/Event/Diag.pm | 7 +-
cpan/Test2/lib/Test2/Event/Note.pm | 7 +-
cpan/Test2/lib/Test2/Formatter/TAP.pm | 13 +-
cpan/Test2/t/legacy/TAP.t | 177 ++++++++++++++++++++++
cpan/Test2/t/modules/Formatter/TAP.t | 30 ++--
16 files changed, 218 insertions(+), 47 deletions(-)
create mode 100644 cpan/Test2/t/legacy/TAP.t
diff --git a/MANIFEST b/MANIFEST
index 2f2ef38..5555c99 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2286,6 +2286,7 @@ cpan/Test2/t/acceptance/try_it_plan.t
cpan/Test2/t/acceptance/try_it_skip.t
cpan/Test2/t/acceptance/try_it_todo.t
cpan/Test2/t/behavior/Taint.t
+cpan/Test2/t/legacy/TAP.t
cpan/Test2/t/modules/Context/Stack.t
cpan/Test2/t/modules/Context.t
cpan/Test2/t/modules/Context/Trace.t
diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm
index 094d4e4..0327cf3 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
BEGIN {
@@ -622,7 +622,7 @@ sub _ok_debug {
my $self = shift;
my ($trace, $orig_name, $is_todo) = @_;
my $msg = $is_todo ? "Failed (TODO)" : "Failed";
- $self->diag("\n") if $ENV{HARNESS_ACTIVE};
+ print {$self->_diag_fh} "\n" if $ENV{HARNESS_ACTIVE};
my (undef, $file, $line) = $trace->call;
if (defined $orig_name) {
@@ -634,6 +634,12 @@ sub _ok_debug {
}
}
+sub _diag_fh {
+ my $self = shift;
+ local $Level = $Level + 1;
+ return $self->in_todo ? $self->todo_output : $self->failure_output;
+}
+
sub _unoverload {
my ($self, $type, $thing) = @_;
@@ -1120,6 +1126,7 @@ sub no_ending {
sub diag {
my $self = shift;
+ return unless @_;
my $ctx = $self->ctx;
$ctx->diag(join '' => map {defined($_) ? $_ : 'undef'} @_);
@@ -1129,6 +1136,7 @@ sub diag {
sub note {
my $self = shift;
+ return unless @_;
my $ctx = $self->ctx;
$ctx->note(join '' => map {defined($_) ? $_ : 'undef'} @_);
diff --git a/cpan/Test-Simple/lib/Test/Builder/Module.pm b/cpan/Test-Simple/lib/Test/Builder/Module.pm
index 63c7b61..6a9fbe5 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 1.00;
require Exporter;
our @ISA = qw(Exporter);
-our $VERSION = '1.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester.pm b/cpan/Test-Simple/lib/Test/Builder/Tester.pm
index d0aa503..52e0ab4 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Builder 0.99;
diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
index d156dc5..da8e007 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
require Test::Builder::Tester;
diff --git a/cpan/Test-Simple/lib/Test/More.pm b/cpan/Test-Simple/lib/Test/More.pm
index 138947d..ec7d019 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Builder::Module 0.99;
diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm
index 25cb781..f6f8419 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Builder::Module 0.99;
diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm
index ef1d075..8d10c8d 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
@EXPORT = qw( run_tests check_tests check_test cmp_results show_space );
@ISA = qw( Exporter );
diff --git a/cpan/Test-Simple/lib/Test/use/ok.pm b/cpan/Test-Simple/lib/Test/use/ok.pm
index ca60ba0..00eb21f 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.302013_003';
+our $VERSION = '1.302013_004';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
__END__
diff --git a/cpan/Test-Simple/lib/ok.pm b/cpan/Test-Simple/lib/ok.pm
index 0547678..66bb06f 100644
--- a/cpan/Test-Simple/lib/ok.pm
+++ b/cpan/Test-Simple/lib/ok.pm
@@ -1,5 +1,5 @@
package ok;
-$ok::VERSION = '1.302013_003';
+$ok::VERSION = '1.302013_004';
use strict;
use Test::More ();
diff --git a/cpan/Test2/lib/Test2.pm b/cpan/Test2/lib/Test2.pm
index c4151ca..9294b4d 100644
--- a/cpan/Test2/lib/Test2.pm
+++ b/cpan/Test2/lib/Test2.pm
@@ -2,7 +2,7 @@ package Test2;
use strict;
use warnings;
-our $VERSION = '0.000010';
+our $VERSION = '0.000011';
1;
diff --git a/cpan/Test2/lib/Test2/Event/Diag.pm b/cpan/Test2/lib/Test2/Event/Diag.pm
index 3ed16bd..92bba36 100644
--- a/cpan/Test2/lib/Test2/Event/Diag.pm
+++ b/cpan/Test2/lib/Test2/Event/Diag.pm
@@ -6,12 +6,7 @@ use base 'Test2::Event';
use Test2::Util::HashBase qw{message todo};
sub init {
- if (defined $_[0]->{+MESSAGE}) {
- $_[0]->{+MESSAGE} .= "";
- }
- else {
- $_[0]->{+MESSAGE} = 'undef';
- }
+ $_[0]->{+MESSAGE} = 'undef' unless defined $_[0]->{+MESSAGE};
}
1;
diff --git a/cpan/Test2/lib/Test2/Event/Note.pm b/cpan/Test2/lib/Test2/Event/Note.pm
index 31fb1de..9d863f4 100644
--- a/cpan/Test2/lib/Test2/Event/Note.pm
+++ b/cpan/Test2/lib/Test2/Event/Note.pm
@@ -6,12 +6,7 @@ use base 'Test2::Event';
use Test2::Util::HashBase qw/message/;
sub init {
- if (defined $_[0]->{+MESSAGE}) {
- $_[0]->{+MESSAGE} .= "";
- }
- else {
- $_[0]->{+MESSAGE} = 'undef';
- }
+ $_[0]->{+MESSAGE} = 'undef' unless defined $_[0]->{+MESSAGE};
}
1;
diff --git a/cpan/Test2/lib/Test2/Formatter/TAP.pm b/cpan/Test2/lib/Test2/Formatter/TAP.pm
index da82a78..1f01bb2 100644
--- a/cpan/Test2/lib/Test2/Formatter/TAP.pm
+++ b/cpan/Test2/lib/Test2/Formatter/TAP.pm
@@ -137,7 +137,7 @@ sub _ok_event {
$out .= "not " unless $e->{pass};
$out .= "ok";
$out .= " $num" if defined $num;
- $out .= " - $name" if $name;
+ $out .= " - $name" if defined $name;
if (defined $todo) {
$out .= " # TODO";
@@ -190,8 +190,7 @@ sub _note_event {
my ($e, $num) = @_;
chomp(my $msg = $e->message);
- return unless $msg;
- $msg = "# $msg" unless $msg =~ m/^\n/;
+ $msg =~ s/^/# /;
$msg =~ s/\n/\n# /g;
return [OUT_STD, "$msg\n"];
@@ -202,11 +201,8 @@ sub _diag_event {
my ($e, $num) = @_;
return if $self->{+NO_DIAG};
- my $msg = $e->message or return;
-
- $msg = "# $msg" unless $msg eq "\n";
-
- chomp($msg);
+ chomp(my $msg = $e->message);
+ $msg =~ s/^/# /;
$msg =~ s/\n/\n# /g;
return [
@@ -274,6 +270,7 @@ sub _plan_event {
return if $directive && $directive eq 'NO PLAN';
my $reason = $e->reason;
+ $reason =~ s/\n/\n# /g if $reason;
my $plan = "1.." . $e->max;
if ($directive) {
diff --git a/cpan/Test2/t/legacy/TAP.t b/cpan/Test2/t/legacy/TAP.t
new file mode 100644
index 0000000..4bbba6c
--- /dev/null
+++ b/cpan/Test2/t/legacy/TAP.t
@@ -0,0 +1,177 @@
+use strict;
+use warnings;
+BEGIN { require "t/tools.pl" };
+
+#########################
+#
+# This test us here to insure that Ok, Diag, and Note events render the way
+# Test::More renders them, trailing whitespace and all.
+#
+#########################
+
+use Test2::Global qw/test2_stack/;
+
+sub capture(&) {
+ my $code = shift;
+
+ my ($err, $out) = ("", "");
+
+ my $handles = test2_stack->top->format->handles;
+ my ($ok, $e);
+ {
+ my ($out_fh, $err_fh);
+
+ ($ok, $e) = try {
+ open($out_fh, '>', \$out) or die "Failed to open a temporary STDOUT: $!";
+ open($err_fh, '>', \$err) or die "Failed to open a temporary STDERR: $!";
+
+ test2_stack->top->format->set_handles([$out_fh, $err_fh, $out_fh]);
+
+ $code->();
+ };
+ }
+ test2_stack->top->format->set_handles($handles);
+
+ die $e unless $ok;
+
+ $err =~ s/ $/_/mg;
+ $out =~ s/ $/_/mg;
+
+ return {
+ STDOUT => $out,
+ STDERR => $err,
+ };
+}
+
+# The tools in tools.pl have some intentional differences from the Test::More
+# versions, these behave more like Test::More which is important for
+# back-compat.
+sub tm_ok($;$) {
+ my ($bool, $name) = @_;
+ my $ctx = context;
+
+ $name && (
+ (index($name, "#" ) >= 0 && $name =~ s|#|\\#|g),
+ (index($name, "\n") >= 0 && $name =~ s{\n}{\n# }sg)
+ );
+
+ $ctx->send_event(
+ 'Ok',
+ pass => $bool,
+ name => $name,
+ allow_bad_name => 1,
+ );
+ $ctx->release;
+ return $bool;
+}
+
+# Test::More actually does a bit more, but for this test we just want to see
+# what happens when message is a specific string, or undef.
+sub tm_diag {
+ my $ctx = context();
+ $ctx->diag(@_);
+ $ctx->release;
+}
+
+sub tm_note {
+ my $ctx = context();
+ $ctx->note(@_);
+ $ctx->release;
+}
+
+# Ensure the top hub is generated
+test2_stack->top;
+
+my $temp_hub = test2_stack->new_hub();
+my $diag = capture {
+ tm_diag(undef);
+ tm_diag("");
+ tm_diag(" ");
+ tm_diag("A");
+ tm_diag("\n");
+ tm_diag("\nB");
+ tm_diag("C\n");
+ tm_diag("\nD\n");
+ tm_diag("E\n\n");
+};
+
+my $note = capture {
+ tm_note(undef);
+ tm_note("");
+ tm_note(" ");
+ tm_note("A");
+ tm_note("\n");
+ tm_note("\nB");
+ tm_note("C\n");
+ tm_note("\nD\n");
+ tm_note("E\n\n");
+};
+
+my $ok = capture {
+ tm_ok(1);
+ tm_ok(1, "");
+ tm_ok(1, " ");
+ tm_ok(1, "A");
+ tm_ok(1, "\n");
+ tm_ok(1, "\nB");
+ tm_ok(1, "C\n");
+ tm_ok(1, "\nD\n");
+ tm_ok(1, "E\n\n");
+};
+test2_stack->pop($temp_hub);
+
+is($diag->{STDOUT}, "", "STDOUT is empty for diag");
+is($diag->{STDERR}, <<EOT, "STDERR for diag looks right");
+# undef
+#_
+# _
+# A
+#_
+#_
+# B
+# C
+#_
+# D
+# E
+#_
+EOT
+
+
+is($note->{STDERR}, "", "STDERR for note is empty");
+is($note->{STDOUT}, <<EOT, "STDOUT looks right for note");
+# undef
+#_
+# _
+# A
+#_
+#_
+# B
+# C
+#_
+# D
+# E
+#_
+EOT
+
+
+is($ok->{STDERR}, "", "STDERR for ok is empty");
+is($ok->{STDOUT}, <<EOT, "STDOUT looks right for ok");
+ok 1
+ok 2 -_
+ok 3 - _
+ok 4 - A
+ok 5 -_
+#_
+ok 6 -_
+# B
+ok 7 - C
+#_
+ok 8 -_
+# D
+#_
+ok 9 - E
+#_
+#_
+EOT
+
+done_testing;
diff --git a/cpan/Test2/t/modules/Formatter/TAP.t b/cpan/Test2/t/modules/Formatter/TAP.t
index 6074638..299bdd1 100644
--- a/cpan/Test2/t/modules/Formatter/TAP.t
+++ b/cpan/Test2/t/modules/Formatter/TAP.t
@@ -182,13 +182,6 @@ tests diag => sub {
[[OUT_TODO, "# foo\n# bar\n# baz\n"]],
"All lines have proper prefix"
);
-
- $diag->set_todo(undef);
- $diag->set_message("");
- is_deeply([$fmt->event_tap($diag)], [], "no tap with an empty message");
-
- $diag->set_message("\n");
- is_deeply([$fmt->event_tap($diag)], [[OUT_ERR, "\n"]], "newline on its own is unchanged");
};
tests exception => sub {
@@ -229,15 +222,6 @@ tests note => sub {
[[OUT_STD, "# foo\n# bar\n# baz\n"]],
"All lines have proper prefix"
);
-
- $note->set_message("");
- is_deeply([$fmt->event_tap($note)], [], "no tap with an empty message");
-
- $note->set_message("\n");
- is_deeply([$fmt->event_tap($note)], [], "newline on its own is not shown");
-
- $note->set_message("\nxxx");
- is_deeply([$fmt->event_tap($note)], [[OUT_STD, "\n# xxx\n"]], "newline starting");
};
for my $pass (1, 0) {
@@ -384,6 +368,20 @@ tests plan => sub {
[],
"NO PLAN"
);
+
+ $plan = Test2::Event::Plan->new(
+ trace => $trace,
+ max => 0,
+ directive => 'skip_all',
+ reason => "Foo\nBar\nBaz",
+ );
+ is_deeply(
+ [$fmt->event_tap($plan)],
+ [
+ [OUT_STD, "1..0 # SKIP Foo\n# Bar\n# Baz\n"],
+ ],
+ "Multi-line reason for skip"
+ );
};
tests subtest => sub {
--
1.9.1
|
From @exodistA lot has happened since I opened this ticket. Attached is a new patch directly against blead. Please do not include any other patches from this thread. Someone in the know should look at my ext/XS-APItest/t/svpeek.t changes and make sure they are sane. -Chad |
From @exodistRJBS and I talked, and I made some changes based on his feedback. Here is a new patch, apply directly against blead, do not include previous patches. |
From @exodistOn Tue Feb 02 20:39:42 2016, exodist7@gmail.com wrote:
This can be closed. After talking with RJBS and attending the QAH we have decided to merge Test2 into Test-Simple, this patch is no longer the right way to go. After the next Test-Simple is released we can update the Test-Simple cpan dist in core. |
From @rjbsClosed by request of OP. -- |
@rjbs - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#127000 (status was 'rejected')
Searchable as RT127000$
The text was updated successfully, but these errors were encountered: