diff options
author | Jesse Luehrs <doy@tozt.net> | 2016-08-30 01:39:07 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2016-08-30 01:39:07 -0400 |
commit | 07edf5e4760c25baedc1e911221802918744d8f1 (patch) | |
tree | 104e663a7c01d808b5f133a2524a9db0bc58d216 /t/lib/TestHelpers.pm | |
parent | c69ab718b2cd8a2e18da56c3dd49fae2d247c2a7 (diff) | |
download | carp-always-color-07edf5e4760c25baedc1e911221802918744d8f1.tar.gz carp-always-color-07edf5e4760c25baedc1e911221802918744d8f1.zip |
use a consistent implementation of output_like
not all of them were passing along @INC
Diffstat (limited to 't/lib/TestHelpers.pm')
-rw-r--r-- | t/lib/TestHelpers.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/t/lib/TestHelpers.pm b/t/lib/TestHelpers.pm new file mode 100644 index 0000000..c44d045 --- /dev/null +++ b/t/lib/TestHelpers.pm @@ -0,0 +1,26 @@ +package TestHelpers; +use strict; +use warnings; + +BEGIN { + if (!eval { require IO::Pty::Easy; 1 }) { + Test::More::plan skip_all => "IO::Pty::Easy is required for this test" + } +} + +use B; +use Exporter 'import'; + +our @EXPORT_OK = qw(output_like); + +sub output_like { + local $Test::Builder::Level = $Test::Builder::Level + 1; + my ($script, $expected, $desc) = @_; + my $pty = IO::Pty::Easy->new; + my $inc = '(' . join(',', map { B::perlstring($_) } @INC) . ')'; + $script = "BEGIN { \@INC = $inc }$script"; + $pty->spawn("$^X", "-e", $script); + Test::More::like($pty->read, $expected, $desc); +} + +1; |