diff --git a/Build.PL b/Build.PL index 886b160f..8d2ec618 100644 --- a/Build.PL +++ b/Build.PL @@ -1,4 +1,4 @@ -# This Build.PL for App-perlbrew was generated by mbtiny 0.041. +# This Build.PL for App-perlbrew was generated by mbtiny 0.047. use 5.008; use Module::Build::Tiny 0.039; Build_PL(); diff --git a/META.json b/META.json index 70ccac25..565133d6 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Kang-min Liu C<< >>" ], "dynamic_config" : 0, - "generated_by" : "App::ModuleBuildTiny version 0.041", + "generated_by" : "App::ModuleBuildTiny version 0.047", "license" : [ "mit" ], @@ -21,7 +21,7 @@ }, "develop" : { "requires" : { - "App::ModuleBuildTiny" : "0.041", + "App::ModuleBuildTiny" : "0.047", "Pod::Markdown" : "2.002" } }, @@ -48,7 +48,6 @@ "Test2::V0" : "0.000163", "Test::More" : "1.001002", "Test::NoWarnings" : "1.04", - "Test::Output" : "1.03", "Test::Simple" : "1.001002", "Test::TempDir::Tiny" : "0.016" } diff --git a/META.yml b/META.yml index 2d5cbf97..1a29ea43 100644 --- a/META.yml +++ b/META.yml @@ -11,13 +11,12 @@ build_requires: Test2::V0: '0.000163' Test::More: '1.001002' Test::NoWarnings: '1.04' - Test::Output: '1.03' Test::Simple: '1.001002' Test::TempDir::Tiny: '0.016' configure_requires: Module::Build::Tiny: '0.039' dynamic_config: 0 -generated_by: 'App::ModuleBuildTiny version 0.041, CPAN::Meta::Converter version 2.150010' +generated_by: 'App::ModuleBuildTiny version 0.047, CPAN::Meta::Converter version 2.150010' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html diff --git a/cpanfile b/cpanfile index 7571b47d..e6eb8c73 100644 --- a/cpanfile +++ b/cpanfile @@ -17,7 +17,6 @@ on test => sub { requires 'Path::Class' => '0.33'; requires 'Test::More' => '1.001002'; requires 'Test::NoWarnings' => '1.04'; - requires 'Test::Output' => '1.03'; requires 'Test::Simple' => '1.001002'; requires 'Test::TempDir::Tiny' => '0.016'; requires 'Test2::V0' => '0.000163'; diff --git a/t/PerlbrewTestHelpers.pm b/t/PerlbrewTestHelpers.pm new file mode 100644 index 00000000..b7cb0ccc --- /dev/null +++ b/t/PerlbrewTestHelpers.pm @@ -0,0 +1,48 @@ +package PerlbrewTestHelpers; +use Test2::V0; +use Test2::Plugin::IOEvents; + +use Exporter 'import'; +our @EXPORT_OK = qw(stderr_from stderr_is stderr_like stdout_from stdout_is stdout_like); + +# Replacements of Test::Output made by using Test2::Plugin::IOEvents + +sub ioevents_from { + my ($cb) = @_; + return grep { $_->tag eq 'STDOUT' || $_->tag eq 'STDERR' } + map { @{ $_->facets->{info} } } + @{ intercept(sub { $cb->() }) }; +} + +sub stderr_from (&) { + my ($cb) = @_; + join "", map { $_->details } grep { $_->tag eq 'STDERR' } ioevents_from($cb); +} + +sub stderr_is (&$;$) { + my ($cb, $expected, $desc) = @_; + is(stderr_from(sub { $cb->() }), $expected, $desc); +} + +sub stderr_like (&$;$) { + my ($cb, $re, $desc) = @_; + like(stderr_from(sub { $cb->() }), $re, $desc); +} + +sub stdout_from (&) { + my ($cb) = @_; + return join "", map { $_->details } grep { $_->tag eq 'STDOUT' } ioevents_from($cb); +} + +sub stdout_is (&$;$) { + my ($cb, $expected, $desc) = @_; + is(stdout_from(sub { $cb->() }), $expected, $desc); +} + +sub stdout_like (&$;$) { + my ($cb, $re, $desc) = @_; + like(stdout_from(sub { $cb->() }), $re, $desc); +} + + +1; diff --git a/t/command-alias.t b/t/command-alias.t index 62b5e894..049625bb 100644 --- a/t/command-alias.t +++ b/t/command-alias.t @@ -1,6 +1,7 @@ #!/usr/bin/env perl use Test2::V0; use Test2::Tools::Spec; +use Config; BEGIN { $ENV{SHELL} = "/bin/bash" } @@ -8,9 +9,7 @@ use FindBin; use lib $FindBin::Bin; use App::perlbrew; require "test2_helpers.pl"; - -use Test::Output; -use Config; +use PerlbrewTestHelpers qw(stderr_like); mock_perlbrew_install("perl-5.14.1"); mock_perlbrew_lib_create('perl-5.14.1@nobita'); diff --git a/t/command-available.t b/t/command-available.t index d9223925..d6a29011 100644 --- a/t/command-available.t +++ b/t/command-available.t @@ -2,9 +2,14 @@ use Test2::V0; use Test2::Tools::Spec; use File::Temp qw( tempdir ); -use Test::Output; +use FindBin; +use lib $FindBin::Bin; use App::perlbrew; +require "test2_helpers.pl"; + +use PerlbrewTestHelpers qw(stdout_like); + $App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 ); $App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 ); diff --git a/t/command-compgen.t b/t/command-compgen.t index d4affa3c..be39f5de 100644 --- a/t/command-compgen.t +++ b/t/command-compgen.t @@ -6,8 +6,7 @@ use FindBin; use lib $FindBin::Bin; use App::perlbrew; require "test2_helpers.pl"; - -use Test::Output qw( stdout_from ); +use PerlbrewTestHelpers qw( stdout_from ); $ENV{PERLBREW_DEBUG_COMPLETION} = 0; diff --git a/t/command-env.t b/t/command-env.t index 1be3e4e5..48e8f61d 100644 --- a/t/command-env.t +++ b/t/command-env.t @@ -1,6 +1,7 @@ #!/usr/bin/env perl use Test2::V0; use Test2::Tools::Spec; +use Config; BEGIN { $ENV{SHELL} = "/bin/bash" } @@ -8,9 +9,7 @@ use FindBin; use lib $FindBin::Bin; use App::perlbrew; require "test2_helpers.pl"; - -use Test::Output; -use Config; +use PerlbrewTestHelpers qw(stdout_is); mock_perlbrew_install("perl-5.14.1"); mock_perlbrew_lib_create('perl-5.14.1@nobita'); diff --git a/t/command-exec.t b/t/command-exec.t index 855e1b7d..47657c71 100644 --- a/t/command-exec.t +++ b/t/command-exec.t @@ -6,8 +6,7 @@ use FindBin; use lib $FindBin::Bin; use App::perlbrew; require 'test2_helpers.pl'; - -use Test::Output; +use PerlbrewTestHelpers qw(stderr_is); mock_perlbrew_install("perl-5.12.3"); mock_perlbrew_install("perl-5.12.4"); diff --git a/t/command-info.t b/t/command-info.t index feacd7fa..78fd116b 100644 --- a/t/command-info.t +++ b/t/command-info.t @@ -1,11 +1,14 @@ #!/usr/bin/env perl use Test2::V0; use Test2::Tools::Spec; -use Test::Output; use File::Spec; use Config; +use FindBin; +use lib $FindBin::Bin; use App::perlbrew; +require "test2_helpers.pl"; +use PerlbrewTestHelpers qw(stdout_like); describe "info command" => sub { it "should display info if under perlbrew perl" => sub { diff --git a/t/test2_helpers.pl b/t/test2_helpers.pl index 8d41ff69..4708b9bf 100644 --- a/t/test2_helpers.pl +++ b/t/test2_helpers.pl @@ -15,9 +15,13 @@ =cut use Test2::V0; +use Test2::Plugin::IOEvents; use IO::All; use File::Temp qw( tempdir ); +use App::Perlbrew::Path; +use App::Perlbrew::Path::Root; + no warnings 'redefine'; sub dir { App::Perlbrew::Path->new(@_);