summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2016-10-13 08:29:16 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2016-10-13 08:29:16 +0100
commit061828b3b8df6f38383ada8703fd195cd2f6ef74 (patch)
tree736eab434c066af139016bd08b58855119013c3b /cpan/Test-Simple/t
parent39250dd4375e1aed90b8a926fd4c0e343b83a4d8 (diff)
downloadperl-061828b3b8df6f38383ada8703fd195cd2f6ef74.tar.gz
Upgrade Test::Simple from version 1.302056 to 1.302059
Diffstat (limited to 'cpan/Test-Simple/t')
-rw-r--r--cpan/Test-Simple/t/Legacy/is_deeply_fail.t10
-rw-r--r--cpan/Test-Simple/t/Test2/behavior/special_names.t32
-rw-r--r--cpan/Test-Simple/t/Test2/legacy/TAP.t32
-rw-r--r--cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t20
-rw-r--r--cpan/Test-Simple/t/regression/721-nested-streamed-subtest.t96
-rw-r--r--cpan/Test-Simple/t/tools.pl34
6 files changed, 148 insertions, 76 deletions
diff --git a/cpan/Test-Simple/t/Legacy/is_deeply_fail.t b/cpan/Test-Simple/t/Legacy/is_deeply_fail.t
index 26036fb960..21efe87a25 100644
--- a/cpan/Test-Simple/t/Legacy/is_deeply_fail.t
+++ b/cpan/Test-Simple/t/Legacy/is_deeply_fail.t
@@ -25,7 +25,7 @@ package main;
my $TB = Test::Builder->create;
-$TB->plan(tests => 100);
+$TB->plan(tests => 102);
# Utility testing functions.
sub ok ($;$) {
@@ -419,3 +419,11 @@ ERR
ok !is_deeply( {x => ''}, {x => undef}, "{x => ''} != {x => undef}" );
is( $out, "not ok 41 - {x => ''} != {x => undef}\n" );
}
+
+# this will also happily fail before 5.10, even though there's no VSTRING ref type
+{
+ my $version1 = v1.2.3;
+ my $version2 = v1.2.4;
+ ok !is_deeply( [\\$version1], [\\$version2], "version objects");
+ is( $out, "not ok 42 - version objects\n" );
+}
diff --git a/cpan/Test-Simple/t/Test2/behavior/special_names.t b/cpan/Test-Simple/t/Test2/behavior/special_names.t
index 90882f5b72..b748cfac27 100644
--- a/cpan/Test-Simple/t/Test2/behavior/special_names.t
+++ b/cpan/Test-Simple/t/Test2/behavior/special_names.t
@@ -12,38 +12,6 @@ BEGIN { require "t/tools.pl" };
use Test2::API 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,
- };
-}
-
# Ensure the top hub is generated
test2_stack->top;
diff --git a/cpan/Test-Simple/t/Test2/legacy/TAP.t b/cpan/Test-Simple/t/Test2/legacy/TAP.t
index 971849f560..84bb18a170 100644
--- a/cpan/Test-Simple/t/Test2/legacy/TAP.t
+++ b/cpan/Test-Simple/t/Test2/legacy/TAP.t
@@ -14,38 +14,6 @@ BEGIN { require "t/tools.pl" };
use Test2::API qw/test2_stack/;
use Test::Builder::Formatter;
-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.
diff --git a/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t b/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t
index 1691751f1c..6ede9df45a 100644
--- a/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t
+++ b/cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t
@@ -6,7 +6,7 @@ use List::Util qw/shuffle/;
use strict;
use warnings;
-sub capture(&) {
+sub simple_capture(&) {
my $code = shift;
my ($err, $out) = ("", "");
@@ -136,7 +136,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
my @lines;
my $file = __FILE__;
- my $out = capture {
+ my $out = simple_capture {
local $ENV{T2_KEEP_TEMPDIR} = 1;
my $ipc = Test2::IPC::Driver::Files->new();
@@ -175,7 +175,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
like($out->{STDERR}, qr/^IPC Fatal Error: File for hub '12345-1-1' already exists/m, "Got message for duplicate hub");
like($out->{STDERR}, qr/^IPC Fatal Error: File for hub '12345-1-1' does not exist/m, "Cannot remove hub twice");
- $out = capture {
+ $out = simple_capture {
my $ipc = Test2::IPC::Driver::Files->new();
$ipc->add_hub($hid);
my $trace = Test2::Util::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__, 'foo']);
@@ -190,7 +190,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
like($out->{STDERR}, qr/Origin PID:\s+$$/, "Got pid");
like($out->{STDERR}, qr/Error: Can't store GLOB items/, "Got cause");
- $out = capture {
+ $out = simple_capture {
my $ipc = Test2::IPC::Driver::Files->new();
local $@;
eval { $ipc->send($hid, bless({ foo => 1 }, 'Foo')) };
@@ -199,7 +199,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
};
like($out->{STDERR}, qr/IPC Fatal Error: hub '12345-1-1' is not available, failed to send event!/, "Cannot send to missing hub");
- $out = capture {
+ $out = simple_capture {
my $ipc = Test2::IPC::Driver::Files->new();
$tmpdir = $ipc->tempdir;
$ipc->add_hub($hid);
@@ -212,7 +212,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
like($out->{STDERR}, qr/IPC Fatal Error: Not all files from hub '12345-1-1' have been collected/, "Leftover files");
like($out->{STDERR}, qr/IPC Fatal Error: Leftover files in the directory \(.*\.ready\)/, "What file");
- $out = capture {
+ $out = simple_capture {
my $ipc = Test2::IPC::Driver::Files->new();
$ipc->add_hub($hid);
@@ -233,7 +233,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
close($fh);
Storable::store({}, $fn);
- $out = capture { eval { $ipc->read_event_file($fn) } };
+ $out = simple_capture { eval { $ipc->read_event_file($fn) } };
like(
$out->{STDERR},
qr/IPC Fatal Error: Got an unblessed object: 'HASH\(.*\)'/,
@@ -241,7 +241,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
);
Storable::store(bless({}, 'Test2::Event::FakeEvent'), $fn);
- $out = capture { eval { $ipc->read_event_file($fn) } };
+ $out = simple_capture { eval { $ipc->read_event_file($fn) } };
like(
$out->{STDERR},
qr{IPC Fatal Error: Event has unknown type \(Test2::Event::FakeEvent\), tried to load 'Test2/Event/FakeEvent\.pm' but failed: Can't locate Test2/Event/FakeEvent\.pm},
@@ -249,7 +249,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
);
Storable::store(bless({}, 'Test2::API'), $fn);
- $out = capture { eval { $ipc->read_event_file($fn) } };
+ $out = simple_capture { eval { $ipc->read_event_file($fn) } };
like(
$out->{STDERR},
qr{'Test2::API=HASH\(.*\)' is not a 'Test2::Event' object},
@@ -257,7 +257,7 @@ ok(!-d $tmpdir, "cleaned up temp dir");
);
Storable::store(bless({}, 'Foo'), $fn);
- $out = capture {
+ $out = simple_capture {
local @INC;
push @INC => ('t/lib', 'lib');
eval { $ipc->read_event_file($fn) };
diff --git a/cpan/Test-Simple/t/regression/721-nested-streamed-subtest.t b/cpan/Test-Simple/t/regression/721-nested-streamed-subtest.t
new file mode 100644
index 0000000000..d83ed18186
--- /dev/null
+++ b/cpan/Test-Simple/t/regression/721-nested-streamed-subtest.t
@@ -0,0 +1,96 @@
+use strict;
+use warnings;
+
+BEGIN { require "t/tools.pl" }
+
+# This module's exports interfere with the ones in t/tools.pl
+use Test::More ();
+use Test2::API qw/run_subtest test2_stack/;
+
+{
+ test2_stack->top;
+ my $temp_hub = test2_stack->new_hub();
+
+ my $output = capture {
+ run_subtest(
+ 'parent',
+ sub {
+ run_subtest(
+ 'buffered',
+ sub {
+ ok(1, 'b1');
+ ok(1, 'b2');
+ },
+ {buffered => 1},
+ );
+ run_subtest(
+ 'streamed',
+ sub {
+ ok(1, 's1');
+ ok(1, 's2');
+ },
+ {buffered => 0},
+ );
+ },
+ {buffered => 1},
+ );
+ };
+
+ test2_stack->pop($temp_hub);
+
+ Test::More::subtest(
+ 'Test2::API::run_subtest',
+ sub {
+ is($output->{STDERR}, q{}, 'no output on stderr');
+ like($output->{STDOUT}, qr/ +ok 1 - b1/, 'got ok output for tests in buffered subtest');
+ like($output->{STDOUT}, qr/ +ok 2 - b2/, 'got ok output for tests in buffered subtest');
+ like($output->{STDOUT}, qr/ +ok 1 - s1/, 'got ok output for tests in streamed subtest');
+ like($output->{STDOUT}, qr/ +ok 2 - s2/, 'got ok output for tests in streamed subtest');
+ }
+ );
+}
+
+{
+ test2_stack->top;
+ my $temp_hub = test2_stack->new_hub();
+
+ my $output = capture {
+ run_subtest(
+ 'parent',
+ sub {
+ run_subtest(
+ 'buffered',
+ sub {
+ ok(1, 'b1');
+ ok(1, 'b2');
+ },
+ {buffered => 1},
+ );
+ Test::More::subtest(
+ 'streamed',
+ sub {
+ ok(1, 's1');
+ ok(1, 's2');
+ },
+ {buffered => 0},
+ );
+ },
+ {buffered => 1},
+ );
+ };
+
+ test2_stack->pop($temp_hub);
+
+ Test::More::subtest(
+ 'Test::More::subtest and Test2::API::run_subtest',
+ sub {
+ is($output->{STDERR}, q{}, 'no output on stderr');
+ like($output->{STDOUT}, qr/ +ok 1 - b1/, 'got ok output for tests in buffered subtest');
+ like($output->{STDOUT}, qr/ +ok 2 - b2/, 'got ok output for tests in buffered subtest');
+ like($output->{STDOUT}, qr/ +ok 1 - s1/, 'got ok output for tests in streamed subtest');
+ like($output->{STDOUT}, qr/ +ok 2 - s2/, 'got ok output for tests in streamed subtest');
+ }
+ );
+}
+
+done_testing;
diff --git a/cpan/Test-Simple/t/tools.pl b/cpan/Test-Simple/t/tools.pl
index e683121413..e97bc78707 100644
--- a/cpan/Test-Simple/t/tools.pl
+++ b/cpan/Test-Simple/t/tools.pl
@@ -1,7 +1,7 @@
use Scalar::Util qw/blessed/;
use Test2::Util qw/try/;
-use Test2::API qw/context run_subtest/;
+use Test2::API qw/context run_subtest test2_stack/;
use Test2::Hub::Interceptor();
use Test2::Hub::Interceptor::Terminator();
@@ -214,4 +214,36 @@ sub tests {
return $bool;
}
+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,
+ };
+}
+
1;