Test-Output-1.03/000755 000765 000024 00000000000 12261570460 014113 5ustar00brianstaff000000 000000 Test-Output-1.03/Changes000644 000765 000024 00000006657 12261570456 015431 0ustar00brianstaff000000 000000 Revision history for Test-Output 1.03 - Fri Jan 3 12:19:35 2014 * Get rid of MYMETA 1.02_01 - Tue Dec 17 12:39:15 2013 * Get rid of MYMETA 1.02 - Mon Jul 8 21:15:30 2013 * Bump to stable release 1.01_02 - Thu Jul 19 06:18:35 2012 * Remove the ::Tie stuff. It should be fully Capture::Tiny now. 1.01_01 - Mon May 14 16:05:22 2012 * David Golden re-did everything with Capture::Tiny to get around the odd output paths that we coudn't handle with a tie. 1.01 - Fri Apr 22 07:58:19 2011 * Bump to a full release. This fixes the tests that failed in the new 5.14 regex stringification 0.16_03 - Mon Oct 25 23:10:41 2010 * Fix cat-o with handling $, 0.16_02 - Tue Oct 19 03:26:14 2010 * Update tests with hardcoded regex stringification for Perl's new (?^:) stuff 0.16_01 - Tue Jun 9 22:58:58 2009 * Added META_MERGE features from chorny 0.13 - Sun Mar 8 23:00:11 2009 * brian d foy (bdfoy@cpan.org) is the new maintainer * Updated docs for source code location, license, etc 0.12 - Sat Oct 25 09:59:18 2008 Repacking to remove OS X extended attribute files that were causing tests to fail. 0.11 10/21/2008 Fixes for STDERR handling under Perl 5.6. Thanks to brian d foy for the patch with tests. 0.10 07/18/2005 Migrated from Exporter to Sub::Exporter 0.09 11/09/2005 New version of Test::Tester added a depth test which was causing tests to fail. Thanks to neildp for the patch. Fixed warning messages during perl Makefile.PL caused by Test::Tester not being loaded first. 0.08 07/19/2005 Supressed most warnings caused by newer versions of Test::Tester 0.07 03/26/2005 Added methods: combined_is, combined_isnt, combined_like and combined_unlike. This combine STDOUT and STDERR into one filehandle and capture their output for testing. 0.06 03/07/2005 Applied patch from David Wheeler to support code blocks within tests as well as coderefs. 0.05 03/04/2005 Added chromatic's patch fixing diag messages printing even when tests pass. Updated stdout_unlike.t to test for success. Updated all tests for successful tests to include diag => ''. 0.04 03/02/2005 Added methods: output_like, output_unlike Moved output_from stdout_from and stderr_from out of @EXPORT and into @EXPORT_OK. Reworked diag messages for output_is and output_isnt to only show the output that doesn't match. replaced "comment" with "description" More tests Much refactoring 0.03 02/16/2005 Reworked entire POD. Thanks to rjbs for his suggestions. Additional POD fixes (date to data thanks to everyone who caught that). New methods: stderr_like, stderr_unlike, stdout_like, stdout_unlike Updated README from the default one created by Module::Starter. Moved private methods _err,_out, and _errandout to stderr_from stdout_from and output_from respectively. Allowing access from the test file. Thanks to rjbs for this suggestion. 0.02 02/12/2005 New methods: output_isnt, stderr_inst, stdout_isnt Removed requirement for Filehandle Removed errant leftover Test::Builder::Tester::Color from tests Migrated all tests to Test::Tester (Test::Tester now a prereq) 0.01 02/12/2005 First version, released on an unsuspecting world. Test-Output-1.03/lib/000755 000765 000024 00000000000 12261570457 014667 5ustar00brianstaff000000 000000 Test-Output-1.03/LICENSE000644 000765 000024 00000000076 12261570456 015130 0ustar00brianstaff000000 000000 You can use Test::Output under the same terms as Perl itself. Test-Output-1.03/Makefile.PL000644 000765 000024 00000001554 12261570456 016077 0ustar00brianstaff000000 000000 use 5.006; use strict; use warnings; use ExtUtils::MakeMaker; eval "use Test::Tester"; WriteMakefile( NAME => 'Test::Output', AUTHOR => 'brian d foy ', VERSION_FROM => 'lib/Test/Output.pm', LICENSE => 'perl', ABSTRACT_FROM => 'lib/Test/Output.pm', PL_FILES => {}, PREREQ_PM => { 'Test::Tester' => '0.107', 'Test::More' => '0', 'Sub::Exporter' => '0', 'File::Temp' => '0.17', # needs :seekable 'Capture::Tiny' => '0.17', }, ( $ExtUtils::MakeMaker::VERSION ge '6.48' ? ( MIN_PERL_VERSION => 5.006, META_MERGE => { resources => { repository => 'git://github.com/briandfoy/test-output.git', }, keywords => ['testing','STDOUT','STDERR'], }, ) : () ), dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Test-Output-*' }, ); Test-Output-1.03/MANIFEST000644 000765 000024 00000001120 12261570460 015236 0ustar00brianstaff000000 000000 Changes lib/Test/Output.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README t/00.load.t t/binmode.t t/carp-5.6.t t/combined_is.t t/combined_isnt.t t/combined_like.t t/combined_unlike.t t/output_is.t t/output_isnt.t t/output_like.t t/output_unlike.t t/pod-coverage.t t/pod.t t/stderr_is.t t/stderr_isnt.t t/stderr_like.t t/stderr_unlike.t t/stdout_is.t t/stdout_isnt.t t/stdout_like.t t/stdout_unlike.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Test-Output-1.03/MANIFEST.SKIP000644 000765 000024 00000001776 12261570456 016031 0ustar00brianstaff000000 000000 #!start included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP \.travis\.yml \.releaserc Test-.* TODO Test-Output-1.03/META.json000664 000765 000024 00000002336 12261570460 015542 0ustar00brianstaff000000 000000 { "abstract" : "Utilities to test STDOUT and STDERR messages.", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150", "keywords" : [ "testing", "STDOUT", "STDERR" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-Output", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "runtime" : { "requires" : { "Capture::Tiny" : "0.17", "File::Temp" : "0.17", "Sub::Exporter" : 0, "Test::More" : 0, "Test::Tester" : "0.107", "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "repository" : { "url" : "git://github.com/briandfoy/test-output.git" } }, "version" : "1.03" } Test-Output-1.03/META.yml000664 000765 000024 00000001304 12261570457 015372 0ustar00brianstaff000000 000000 --- abstract: 'Utilities to test STDOUT and STDERR messages.' author: - 'brian d foy ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150' keywords: - testing - STDOUT - STDERR license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Test-Output no_index: directory: - t - inc requires: Capture::Tiny: 0.17 File::Temp: 0.17 Sub::Exporter: 0 Test::More: 0 Test::Tester: 0.107 perl: 5.006 resources: repository: git://github.com/briandfoy/test-output.git version: 1.03 Test-Output-1.03/README000644 000765 000024 00000001522 12261570456 015000 0ustar00brianstaff000000 000000 Test-Output Test-Output provides a simple interface for testing output send to STDOUT or STDERR. A number of different utilies are included to try and be as flexible as possible to the tester. While Test::Output requires Test::Tester during installation, this requirement is only for it's own tests, not for what it's testing. One of the main ideas behind Test::Output is to make it as self contained as possible so it can be included with other's modules. As of this release the only requirement is to include Test::Output::Tie along with it. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install COPYRIGHT AND LICENCE Copyright (C) 2005 Shawn Sorichetti This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Test-Output-1.03/t/000755 000765 000024 00000000000 12261570457 014364 5ustar00brianstaff000000 000000 Test-Output-1.03/t/00.load.t000644 000765 000024 00000000170 12261570456 015703 0ustar00brianstaff000000 000000 use Test::More tests => 1; BEGIN { use_ok( 'Test::Output' ); } diag( "Testing Test::Output $Test::Output::VERSION" ); Test-Output-1.03/t/binmode.t000644 000765 000024 00000000321 12261570456 016161 0ustar00brianstaff000000 000000 #!perl use Test::Tester; use Test::More tests => 1; use Test::Output; use strict; use warnings; eval { stdout_is( sub { binmode STDOUT; print 'foo'; }, 'foo', "The binmode doesn't blow up" ); }; Test-Output-1.03/t/carp-5.6.t000644 000765 000024 00000000566 12261570456 016012 0ustar00brianstaff000000 000000 use Test::More tests => 3; my $class = 'Test::Output'; my $sub = 'stderr_from'; use_ok( $class ); can_ok( $class, $sub ); use Carp qw(carp); my $message = "This is from carp"; my $output = do { no strict 'refs'; &{ "${class}::$sub" }( sub { carp $message } ); }; like( $output, qr/^\Q$message\E at .* line \d+/, "stderr_from captures carp message" );Test-Output-1.03/t/combined_is.t000644 000765 000024 00000014063 12261570456 017027 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 98; use Test::Output; use strict; use warnings; check_test( sub { combined_is(sub { print "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { combined_is(sub { print STDERR "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { combined_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; print "TEST AGAIN\n"; }, "TEST OUT\nTEST ERR\nTEST AGAIN\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { combined_is(sub { printf("TEST OUT - %d\n",25); }, "TEST OUT - 25\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { combined_is(sub { print "TEST OUT"; }, "TEST OUT STDOUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { combined_is(sub { print STDERR "TEST OUT"}, "TEST OUT STDERR", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { combined_is(sub { print "TEST ERR\n"; print STDERR "TEST OUT\n"}, "TEST ERR STDOUT\nTEST OUT STDERR\n", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST ERR\nTEST OUT\n\nnot:\nTEST ERR STDOUT\nTEST OUT STDERR\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { combined_is { print "TEST OUT\n"; } "TEST OUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'codeblock STDOUT matches success' ); check_test( sub { combined_is { print STDERR "TEST OUT\n"; } "TEST OUT\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { combined_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; print "TEST OUT AGAIN\n"; } "TEST OUT\nTEST ERR\nTEST OUT AGAIN\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { combined_is { printf("TEST OUT - %d\n",25); } "TEST OUT - 25\n", 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { combined_is { print "TEST OUT"; } "TEST OUT STDOUT", 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { combined_is { print STDERR "TEST OUT"} "TEST OUT STDERR", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { combined_is { print "TEST ERR\n"; print STDERR "TEST OUT\n"} "TEST ERR STDOUT\nTEST OUT STDERR\n", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST ERR\nTEST OUT\n\nnot:\nTEST ERR STDOUT\nTEST OUT STDERR\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); Test-Output-1.03/t/combined_isnt.t000644 000765 000024 00000014167 12261570456 017376 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 98; use Test::Output; use strict; use warnings; check_test( sub { combined_isnt(sub { print "TEST OUT\n"; }, "TEST STDOUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); check_test( sub { combined_isnt(sub { print STDERR "TEST OUT\n"; }, "TEST STDERR\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not matching success' ); check_test( sub { combined_isnt(sub { print "TEST STDOUT\n"; print STDERR "TEST STDERR\n"; print "TEST STDOUT AGAIN\n"; }, "TEST OUT\nTEST ERR\nTEST AGAIN\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR not matching success' ); check_test( sub { combined_isnt(sub { printf("TEST OUT - %d\n",25); }, "TEST OUT - 42\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not matching success' ); check_test( sub { combined_isnt(sub { print "TEST OUT"; }, "TEST OUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matching failure' ); check_test( sub { combined_isnt(sub { print STDERR "TEST OUT"}, "TEST OUT", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDERR matching failure' ); check_test( sub { combined_isnt(sub { print "TEST ERR\n"; print STDERR "TEST OUT\n"}, "TEST ERR\nTEST OUT\n", 'Testing STDOUT & STDERR failure' ) }, { ok => 0, name => 'Testing STDOUT & STDERR failure', diag => "STDOUT & STDERR:\nTEST ERR\nTEST OUT\n\nmatching:\nTEST ERR\nTEST OUT\n\nnot expected\n", },'STDOUT and STDERR matching failure' ); check_test( sub { combined_isnt { print "TEST OUT\n"; } "TEST STDOUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'codeblock STDOUT not matching success' ); check_test( sub { combined_isnt { print STDERR "TEST OUT\n"; } "TEST STDERR\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'codeblock STDERR not matching success' ); check_test( sub { combined_isnt { print "TEST STDOUT\n"; print STDERR "TEST STDERR\n"; print "TEST STDOUT AGAIN\n"; } "TEST OUT\nTEST ERR\nTEST OUT AGAIN\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'codeblock STDOUT & STDERR not matching success' ); check_test( sub { combined_isnt { printf("TEST OUT - %d\n",25); } "TEST OUT - 42\n", 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'codeblock STDOUT printf not matching success' ); check_test( sub { combined_isnt { print "TEST OUT"; } "TEST OUT", 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'codeblock STDOUT matching failure' ); check_test( sub { combined_isnt { print STDERR "TEST OUT"} "TEST OUT", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'codeblock STDERR not matching failure' ); check_test( sub { combined_isnt { print "TEST ERR\n"; print STDERR "TEST OUT\n"} "TEST ERR\nTEST OUT\n", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR:\nTEST ERR\nTEST OUT\n\nmatching:\nTEST ERR\nTEST OUT\n\nnot expected\n", },'codeblock STDOUT and STDERR matching failure' ); Test-Output-1.03/t/combined_like.t000644 000765 000024 00000006704 12261570456 017343 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 49; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { combined_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/ERR/i; check_test( sub { combined_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_like(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'combined_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\ndon't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { combined_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_like { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'combined_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\ndon't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } Test-Output-1.03/t/combined_unlike.t000644 000765 000024 00000006752 12261570456 017711 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 49; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/err/; check_test( sub { combined_unlike(sub { print "TEST OUT\n"; print "TEST ERR\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_unlike(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'combined_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/; check_test( sub { combined_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\nmatching:\n$regex\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'codeblock STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_unlike { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'combined_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'codeblock bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/; check_test( sub { combined_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\nmatching:\n$regex\nnot expected\n", },'codeblock STDOUT matching failure' ); } Test-Output-1.03/t/output_is.t000644 000765 000024 00000025164 12261570456 016613 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 168; use Test::Output; use strict; use warnings; check_test( sub { output_is(sub { print "TEST OUT\n"; }, "TEST OUT\n", '', 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { output_is(sub { print STDERR "TEST OUT\n"; }, '', "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { output_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, "TEST OUT\n", "TEST ERR\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { output_is(sub { printf("TEST OUT - %d\n",25); }, "TEST OUT - 25\n", '', 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { output_is(sub { print "TEST OUT"; }, "TEST OUT STDOUT", '', 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT is:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { output_is(sub { print STDERR "TEST OUT"}, '', "TEST OUT STDERR", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { output_is(sub { print "TEST ERR"; print STDERR "TEST OUT"}, 'TEST ERR STDOUT', "TEST OUT STDERR", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\nTEST ERR STDOUT\nas expected\nSTDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, undef, "TEST ERR\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT undef match success' ); check_test( sub { output_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, "TEST OUT\n", undef, 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT match success STDERR undef' ); check_test( sub { output_is(sub { }, undef, undef, 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR undef match success' ); check_test( sub { output_is(sub { print "TEST ERR"; print STDERR "TEST OUT"}, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\n\nas expected\nSTDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is(sub { print STDERR "TEST OUT"}, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT undef and STDERR not matching failure' ); check_test( sub { output_is { print "TEST OUT\n"; } "TEST OUT\n", '', 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { output_is { print STDERR "TEST OUT\n"; } '', "TEST OUT\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { output_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } "TEST OUT\n", "TEST ERR\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { output_is { printf("TEST OUT - %d\n",25); } "TEST OUT - 25\n", '', 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { output_is { print "TEST OUT"; } "TEST OUT STDOUT", '', 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT is:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { output_is { print STDERR "TEST OUT"} '', "TEST OUT STDERR", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { output_is { print "TEST ERR"; print STDERR "TEST OUT"} 'TEST ERR STDOUT', "TEST OUT STDERR", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\nTEST ERR STDOUT\nas expected\nSTDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } undef, "TEST ERR\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT undef match success' ); check_test( sub { output_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } "TEST OUT\n", undef, 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT match success STDERR undef' ); check_test( sub { output_is { } undef, undef, 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR undef match success' ); check_test( sub { output_is { print "TEST ERR"; print STDERR "TEST OUT"} undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\n\nas expected\nSTDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is { print STDERR "TEST OUT"} undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT undef and STDERR not matching failure' ); Test-Output-1.03/t/output_isnt.t000644 000765 000024 00000025713 12261570456 017155 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 168; use Test::Output; use strict; use warnings; check_test( sub { output_isnt(sub { print "TEST OUT\n"; print STDERR "TEST OUT"}, "TEST OUT STDOUT\n", undef, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { output_isnt(sub { print "TEST OUT\n"; print STDERR "TEST OUT\n"; }, undef, "TEST OUT STDERR\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { output_isnt(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, "TEST OUT STDOUT\n", "TEST ERR STDERR\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR not equal success' ); check_test( sub { output_isnt(sub { printf("TEST OUT - %d\n",25); print STDERR "TEST OUT"}, "TEST OUT - 42\n", undef, 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { output_isnt(sub { printf STDERR ("TEST OUT - %d\n",25); }, undef, "TEST OUT - 42\n", 'Testing STDERR printf' ) },{ ok => 1, name => 'Testing STDERR printf', diag => '', },'STDERR printf not equal success' ); check_test( sub { output_isnt(sub { print "TEST OUT - 25"; printf STDERR "TEST OUT - 25"; }, "TEST OUT - 25", "TEST OUT - 25", 'Testing STDOUT & STDERR print' ) },{ ok => 0, name => 'Testing STDOUT & STDERR print', diag => "STDOUT:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\nSTDERR:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\n", },'STDOUT & STDERR matches failure' ); check_test( sub { output_isnt(sub { print "TEST OUT"; print STDERR "TEST OUT"}, "TEST OUT", '', 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt(sub { print "TEST OUT"; print STDERR "TEST OUT"}, '', "TEST OUT", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt(sub { print "TEST OUT"; print STDERR "TEST OUT"}, undef, undef, 'Testing STDERR failure' ) }, { ok => 1, name => 'Testing STDERR failure', diag => '', },'STDOUT & STDERR not matching success' ); check_test( sub { output_isnt(sub { print "TEST OUT"; }, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\n\nmatching:\n\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt(sub { print STDERR "TEST OUT"; }, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt(sub { }, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\nSTDERR:\n\nmatching:\n\nnot expected\n", },'STDOUT & STDERR matches failure' ); check_test( sub { output_isnt { print "TEST OUT\n"; print STDERR "TEST OUT"} "TEST OUT STDOUT\n", undef, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { output_isnt { print "TEST OUT\n"; print STDERR "TEST OUT\n"; } undef, "TEST OUT STDERR\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { output_isnt { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } "TEST OUT STDOUT\n", "TEST ERR STDERR\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR not equal success' ); check_test( sub { output_isnt { printf("TEST OUT - %d\n",25); print STDERR "TEST OUT"} "TEST OUT - 42\n", undef, 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { output_isnt { printf STDERR ("TEST OUT - %d\n",25); } undef, "TEST OUT - 42\n", 'Testing STDERR printf' },{ ok => 1, name => 'Testing STDERR printf', diag => '', },'STDERR printf not equal success' ); check_test( sub { output_isnt { print "TEST OUT - 25"; printf STDERR "TEST OUT - 25"; } "TEST OUT - 25", "TEST OUT - 25", 'Testing STDOUT & STDERR print' },{ ok => 0, name => 'Testing STDOUT & STDERR print', diag => "STDOUT:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\nSTDERR:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\n", },'STDOUT & STDERR matches failure' ); check_test( sub { output_isnt { print "TEST OUT"; print STDERR "TEST OUT"} "TEST OUT", '', 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt { print "TEST OUT"; print STDERR "TEST OUT"} '', "TEST OUT", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt { print "TEST OUT"; print STDERR "TEST OUT"} undef, undef, 'Testing STDERR failure' }, { ok => 1, name => 'Testing STDERR failure', diag => '', },'STDOUT & STDERR not matching success' ); check_test( sub { output_isnt { print "TEST OUT"; } undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\n\nmatching:\n\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt { print STDERR "TEST OUT"; } undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt { } undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\nSTDERR:\n\nmatching:\n\nnot expected\n", },'STDOUT & STDERR matches failure' ); Test-Output-1.03/t/output_like.t000644 000765 000024 00000033473 12261570456 017126 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 154; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = qr/ERR/i; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT matching STDERR ignored success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/; my $regex_err = qr/ERR/; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT is:\nTEST OUT\n\nnot:\n\nas expected\nSTDERR is:\nTEST ERR\n\nnot:\n\nas expected\n", },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/ERR/i; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_like_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_like_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/err/; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\nSTDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDOUT & STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like(sub { }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT & STDERR undef matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like(sub { print STDERR "TEST OUT\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR is:\nTEST OUT\n\nnot:\n\nas expected\n", },'STDOUT & STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT matching STDERR ignored success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT is:\nTEST OUT\n\nnot:\n\nas expected\nSTDERR is:\nTEST ERR\n\nnot:\n\nas expected\n", },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_like_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_like_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/err/; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\nSTDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDOUT & STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like { } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT & STDERR undef matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like { print STDERR "TEST OUT\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR is:\nTEST OUT\n\nnot:\n\nas expected\n", },'STDOUT & STDERR not matching failure' ); } Test-Output-1.03/t/output_unlike.t000644 000765 000024 00000024425 12261570456 017466 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 112; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/i; my $regex_err = qr/OUT/i; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err = qr/OUT/i; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/i; my $regex_err; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/err/; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_unlike_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_unlike_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/; my $regex_err = qr/ERR/; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\nSTDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/; my $regex_err = qr/OUT/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err = qr/OUT/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/i; my $regex_err; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/err/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_unlike_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_unlike_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/; my $regex_err = qr/ERR/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\nSTDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } Test-Output-1.03/t/pod-coverage.t000644 000765 000024 00000000254 12261570456 017124 0ustar00brianstaff000000 000000 #!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Test-Output-1.03/t/pod.t000644 000765 000024 00000000214 12261570456 015327 0ustar00brianstaff000000 000000 #!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Test-Output-1.03/t/stderr_is.t000644 000765 000024 00000004713 12261570456 016553 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; check_test( sub { stderr_is(sub { print STDERR "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is(sub { print STDERR "TEST", " ", "OUT", "\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is(sub { local $, = " "; print STDERR "TEST", "OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is(sub { print STDERR "TEST OUT\n"; }, "TEST OUT STDERR\n", 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR is:\nTEST OUT\n\nnot:\nTEST OUT STDERR\n\nas expected\n", },'STDERR not matching failure' ); check_test( sub { stderr_is { print STDERR "TEST OUT\n"; } "TEST OUT\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is { print STDERR "TEST OUT\n"; } "TEST OUT STDERR\n", 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR is:\nTEST OUT\n\nnot:\nTEST OUT STDERR\n\nas expected\n", },'STDERR not matching failure' ); Test-Output-1.03/t/stderr_isnt.t000644 000765 000024 00000003225 12261570456 017112 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 28; use Test::Output; use strict; use warnings; check_test( sub { stderr_isnt(sub { print STDERR "TEST OUT\n"; }, "TEST OUT STDERR\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { stderr_isnt(sub { print STDERR "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\nTEST OUT\n\nnot expected\n", },'STDERR matches failure' ); check_test( sub { stderr_isnt { print STDERR "TEST OUT\n"; } "TEST OUT STDERR\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { stderr_isnt { print STDERR "TEST OUT\n"; } "TEST OUT\n", 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\nTEST OUT\n\nnot expected\n", },'STDERR matches failure' ); Test-Output-1.03/t/stderr_like.t000644 000765 000024 00000006044 12261570456 017063 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stderr_like(sub { print STDERR "TEST OUT\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = 'OUT'; check_test( sub { stderr_like(sub { print STDERR "TEST OUT\n"; }, 'OUT', 'Testing STDERR' ) },{ ok => 0, depth => 2, name => 'stderr_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stderr_like(sub { print STDERR "TEST OUT\n"; }, qr/out/, 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stderr_like { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = 'OUT'; check_test( sub { stderr_like { print STDERR "TEST OUT\n"; } 'OUT', 'Testing STDERR' },{ ok => 0, depth => 2, name => 'stderr_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stderr_like { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDERR not matching failure' ); } Test-Output-1.03/t/stderr_unlike.t000644 000765 000024 00000005754 12261570456 017435 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stderr_unlike(sub { print STDERR "TEST OUT\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stderr_unlike(sub { print STDERR "TEST OUT\n"; }, 'OUT', 'Testing STDERR' ) },{ ok => 0, depth => 2, name => 'stderr_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR matching success' ); { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # my $regex = qr/OUT/; check_test( sub { stderr_unlike(sub { print STDERR "TEST OUT\n"; }, $regex, 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDERR not matching failure' ); } { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # my $regex = qr/out/; check_test( sub { stderr_unlike { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stderr_unlike { print STDERR "TEST OUT\n"; } 'OUT', 'Testing STDERR' },{ ok => 0, depth => 2, name => 'stderr_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR matching success' ); { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # my $regex = qr/OUT/; check_test( sub { stderr_unlike { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDERR not matching failure' ); } Test-Output-1.03/t/stdout_is.t000644 000765 000024 00000005103 12261570456 016564 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 35; use Test::Output; use strict; use warnings; check_test( sub { stdout_is(sub { print "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { stdout_is(sub { print "TEST", " ", "OUT", "\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { stdout_is(sub { local $, = " "; print "TEST", "OUT\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { stdout_is(sub { printf("TEST OUT - %d\n",42); }, "TEST OUT - 42\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf matches success' ); check_test( sub { stdout_is(sub { print "TEST OUT"; }, "TEST OUT STDOUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT is:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); __END__ # This doesn't work yet SKIP: { skip 'Perl 5.10 required for this test', 7 unless $] >= 5.010; BEGIN { eval "use feature qw(say)" if $] >= 5.010 }; check_test( sub { stdout_is { eval 'say( "TEST OUT" );'; } "TEST OUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); }; Test-Output-1.03/t/stdout_isnt.t000644 000765 000024 00000004646 12261570456 017141 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; check_test( sub { stdout_isnt(sub { print "TEST OUT\n"; }, "TEST OUT STDOUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { stdout_isnt(sub { printf("TEST OUT - %d\n",42); }, "TEST OUT - 25\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { stdout_isnt(sub { print "TEST OUT"; }, "TEST OUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { stdout_isnt { print "TEST OUT\n"; } "TEST OUT STDOUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { stdout_isnt { printf("TEST OUT - %d\n",42); } "TEST OUT - 25\n", 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { stdout_isnt { print "TEST OUT"; } "TEST OUT", 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); Test-Output-1.03/t/stdout_like.t000644 000765 000024 00000005641 12261570456 017104 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stdout_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_like(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'stdout_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stdout_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_like { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'stdout_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } Test-Output-1.03/t/stdout_unlike.t000644 000765 000024 00000005655 12261570456 017454 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_unlike(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'stdout_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/(?-xism:OUT)/; check_test( sub { stdout_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_unlike { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'stdout_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/; check_test( sub { stdout_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDOUT matching failure' ); } Test-Output-1.03/lib/Test/000755 000765 000024 00000000000 12261570457 015606 5ustar00brianstaff000000 000000 Test-Output-1.03/lib/Test/Output.pm000644 000765 000024 00000054067 12261570456 017457 0ustar00brianstaff000000 000000 package Test::Output; use vars qw($VERSION); use warnings; use strict; use Test::Builder; use Capture::Tiny qw/capture capture_stdout capture_stderr capture_merged/; use Sub::Exporter -setup => { exports => [ qw(output_is output_isnt output_like output_unlike stderr_is stderr_isnt stderr_like stderr_unlike stdout_is stdout_isnt stdout_like stdout_unlike combined_is combined_isnt combined_like combined_unlike output_from stderr_from stdout_from combined_from ) ], groups => { stdout => [ qw( stdout_is stdout_isnt stdout_like stdout_unlike ) ], stderr => [ qw( stderr_is stderr_isnt stderr_like stderr_unlike ) ], output => [ qw( output_is output_isnt output_like output_unlike ) ], combined => [ qw( combined_is combined_isnt combined_like combined_unlike ) ], functions => [ qw( output_from stderr_from stdout_from combined_from ) ], tests => [ qw( output_is output_isnt output_like output_unlike stderr_is stderr_isnt stderr_like stderr_unlike stdout_is stdout_isnt stdout_like stdout_unlike combined_is combined_isnt combined_like combined_unlike ) ], default => [ '-tests' ], }, }; my $Test = Test::Builder->new; =head1 NAME Test::Output - Utilities to test STDOUT and STDERR messages. =head1 VERSION Version 0.16 =cut $VERSION = '1.03'; =head1 SYNOPSIS use Test::More tests => 4; use Test::Output; sub writer { print "Write out.\n"; print STDERR "Error out.\n"; } stdout_is(\&writer,"Write out.\n",'Test STDOUT'); stderr_isnt(\&writer,"No error out.\n",'Test STDERR'); combined_is( \&writer, "Write out.\nError out.\n", 'Test STDOUT & STDERR combined' ); output_is( \&writer, "Write out.\n", "Error out.\n", 'Test STDOUT & STDERR' ); # Use bare blocks. stdout_is { print "test" } "test", "Test STDOUT"; stderr_isnt { print "bad test" } "test", "Test STDERR"; output_is { print 'STDOUT'; print STDERR 'STDERR' } "STDOUT", "STDERR", "Test output"; =head1 DESCRIPTION Test::Output provides a simple interface for testing output sent to STDOUT or STDERR. A number of different utilities are included to try and be as flexible as possible to the tester. Originally this module was designed not to have external requirements, however, the features provided by L over what L provides is just to great to pass up. Likewise, Capture::Tiny provides a much more robust capture mechanism without than the original Test::Output::Tie. =cut =head1 TESTS =cut =head2 STDOUT =over 4 =item B =item B stdout_is ( $coderef, $expected, 'description' ); stdout_is { ... } $expected, 'description'; stdout_isnt( $coderef, $expected, 'description' ); stdout_isnt { ... } $expected, 'description'; stdout_is() captures output sent to STDOUT from $coderef and compares it against $expected. The test passes if equal. stdout_isnt() passes if STDOUT is not equal to $expected. =cut sub stdout_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stdout = stdout_from($test); my $ok = ( $stdout eq $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT is:\n$stdout\nnot:\n$expected\nas expected"); return $ok; } sub stdout_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stdout = stdout_from($test); my $ok = ( $stdout ne $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\nmatching:\n$expected\nnot expected"); return $ok; } =item B =item B stdout_like ( $coderef, qr/$expected/, 'description' ); stdout_like { ... } qr/$expected/, 'description'; stdout_unlike( $coderef, qr/$expected/, 'description' ); stdout_unlike { ... } qr/$expected/, 'description'; stdout_like() captures the output sent to STDOUT from $coderef and compares it to the regex in $expected. The test passes if the regex matches. stdout_unlike() passes if STDOUT does not match the regex. =back =cut sub stdout_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stdout_like' => $expected ) ) { return $regextest; } my $stdout = stdout_from($test); my $ok = ( $stdout =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\ndoesn't match:\n$expected\nas expected"); return $ok; } sub stdout_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stdout_unlike' => $expected ) ) { return $regextest; } my $stdout = stdout_from($test); my $ok = ( $stdout !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\nmatches:\n$expected\nnot expected"); return $ok; } =head2 STDERR =over 4 =item B =item B stderr_is ( $coderef, $expected, 'description' ); stderr_is {... } $expected, 'description'; stderr_isnt( $coderef, $expected, 'description' ); stderr_isnt {... } $expected, 'description'; stderr_is() is similar to stdout_is, except that it captures STDERR. The test passes if STDERR from $coderef equals $expected. stderr_isnt() passes if STDERR is not equal to $expected. =cut sub stderr_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stderr = stderr_from($test); my $ok = ( $stderr eq $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR is:\n$stderr\nnot:\n$expected\nas expected"); return $ok; } sub stderr_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stderr = stderr_from($test); my $ok = ( $stderr ne $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); return $ok; } =item B =item B stderr_like ( $coderef, qr/$expected/, 'description' ); stderr_like { ...} qr/$expected/, 'description'; stderr_unlike( $coderef, qr/$expected/, 'description' ); stderr_unlike { ...} qr/$expected/, 'description'; stderr_like() is similar to stdout_like() except that it compares the regex $expected to STDERR captured from $codref. The test passes if the regex matches. stderr_unlike() passes if STDERR does not match the regex. =back =cut sub stderr_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stderr_like' => $expected ) ) { return $regextest; } my $stderr = stderr_from($test); my $ok = ( $stderr =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\ndoesn't match:\n$expected\nas expected"); return $ok; } sub stderr_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stderr_unlike' => $expected ) ) { return $regextest; } my $stderr = stderr_from($test); my $ok = ( $stderr !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); return $ok; } =head2 COMBINED OUTPUT =over 4 =item B =item B combined_is ( $coderef, $expected, 'description' ); combined_is {... } $expected, 'description'; combined_isnt ( $coderef, $expected, 'description' ); combined_isnt {... } $expected, 'description'; combined_is() directs STDERR to STDOUT then captures STDOUT. This is equivalent to UNIXs 2>&1. The test passes if the combined STDOUT and STDERR from $coderef equals $expected. combined_isnt() passes if combined STDOUT and STDERR are not equal to $expected. =cut sub combined_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $combined = combined_from($test); my $ok = ( $combined eq $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR are:\n$combined\nnot:\n$expected\nas expected"); return $ok; } sub combined_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $combined = combined_from($test); my $ok = ( $combined ne $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); return $ok; } =item B =item B combined_like ( $coderef, qr/$expected/, 'description' ); combined_like { ...} qr/$expected/, 'description'; combined_unlike ( $coderef, qr/$expected/, 'description' ); combined_unlike { ...} qr/$expected/, 'description'; combined_like() is similar to combined_is() except that it compares a regex ($expected) to STDOUT and STDERR captured from $codref. The test passes if the regex matches. combined_unlike() passes if the combined STDOUT and STDERR does not match the regex. =back =cut sub combined_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'combined_like' => $expected ) ) { return $regextest; } my $combined = combined_from($test); my $ok = ( $combined =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\ndon't match:\n$expected\nas expected"); return $ok; } sub combined_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'combined_unlike' => $expected ) ) { return $regextest; } my $combined = combined_from($test); my $ok = ( $combined !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); return $ok; } =head2 OUTPUT =over 4 =item B =item B output_is ( $coderef, $expected_stdout, $expected_stderr, 'description' ); output_is {... } $expected_stdout, $expected_stderr, 'description'; output_isnt( $coderef, $expected_stdout, $expected_stderr, 'description' ); output_isnt {... } $expected_stdout, $expected_stderr, 'description'; The output_is() function is a combination of the stdout_is() and stderr_is() functions. For example: output_is(sub {print "foo"; print STDERR "bar";},'foo','bar'); is functionally equivalent to stdout_is(sub {print "foo";},'foo') && stderr_is(sub {print STDERR "bar";'bar'); except that $coderef is only executed once. Unlike, stdout_is() and stderr_is() which ignore STDERR and STDOUT respectively, output_is() requires both STDOUT and STDERR to match in order to pass. Setting either $expected_stdout or $expected_stderr to C ignores STDOUT or STDERR respectively. output_is(sub {print "foo"; print STDERR "bar";},'foo',undef); is the same as stdout_is(sub {print "foo";},'foo') output_isnt() provides the opposite function of output_is(). It is a combination of stdout_isnt() and stderr_isnt(). output_isnt(sub {print "foo"; print STDERR "bar";},'bar','foo'); is functionally equivalent to stdout_is(sub {print "foo";},'bar') && stderr_is(sub {print STDERR "bar";'foo'); As with output_is(), setting either $expected_stdout or $expected_stderr to C ignores the output to that facility. output_isnt(sub {print "foo"; print STDERR "bar";},undef,'foo'); is the same as stderr_is(sub {print STDERR "bar";},'foo') =cut sub output_is (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; my $diag; if ( defined($experr) && defined($expout) ) { unless ( $stdout eq $expout ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; } unless ( $stderr eq $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout eq $expout ); $diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; } elsif ( defined($experr) ) { $ok = ( $stderr eq $experr ); $diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; } else { unless ( $stdout eq '' ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; } unless ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } sub output_isnt (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; my $diag; if ( defined($experr) && defined($expout) ) { if ( $stdout eq $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; } if ( $stderr eq $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout ne $expout ); $diag = "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; } elsif ( defined($experr) ) { $ok = ( $stderr ne $experr ); $diag = "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; } else { if ( $stdout eq '' ) { $ok = 0; $diag = "STDOUT:\n$stdout\nmatching:\n\nnot expected"; } if ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatching:\n\nnot expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } =item B =item B output_like ( $coderef, $regex_stdout, $regex_stderr, 'description' ); output_like { ... } $regex_stdout, $regex_stderr, 'description'; output_unlike( $coderef, $regex_stdout, $regex_stderr, 'description' ); output_unlike { ... } $regex_stdout, $regex_stderr, 'description'; output_like() and output_unlike() follow the same principles as output_is() and output_isnt() except they use a regular expression for matching. output_like() attempts to match $regex_stdout and $regex_stderr against STDOUT and STDERR produced by $coderef. The test passes if both match. output_like(sub {print "foo"; print STDERR "bar";},qr/foo/,qr/bar/); The above test is successful. Like output_is(), setting either $regex_stdout or $regex_stderr to C ignores the output to that facility. output_like(sub {print "foo"; print STDERR "bar";},qr/foo/,undef); is the same as stdout_like(sub {print "foo"; print STDERR "bar";},qr/foo/); output_unlike() test pass if output from $coderef doesn't match $regex_stdout and $regex_stderr. =back =cut sub output_like (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; unless ( my $regextest = _chkregex( 'output_like_STDERR' => $experr, 'output_like_STDOUT' => $expout ) ) { return $regextest; } my $diag; if ( defined($experr) && defined($expout) ) { unless ( $stdout =~ $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; } unless ( $stderr =~ $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout =~ $expout ); $diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; } elsif ( defined($experr) ) { $ok = ( $stderr =~ $experr ); $diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; } else { unless ( $stdout eq '' ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; } unless ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } sub output_unlike (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; unless ( my $regextest = _chkregex( 'output_unlike_STDERR' => $experr, 'output_unlike_STDOUT' => $expout ) ) { return $regextest; } my $diag; if ( defined($experr) && defined($expout) ) { if ( $stdout =~ $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; } if ( $stderr =~ $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout !~ $expout ); $diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; } elsif ( defined($experr) ) { $ok = ( $stderr !~ $experr ); $diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } =head1 EXPORTS By default, all tests are exported, however with the switch to L export groups are now available to better limit imports. To import tests for STDOUT: use Test::Output qw(:stdout); To import tests STDERR: use Test::Output qw(:stderr); To import just the functions: use Test::Output qw(:functions); And to import all tests: use Test::Output; The following is a list of group names and which functions are exported: =over 4 =item stdout stdout_is stdout_isnt stdout_like stdout_unlike =item stderr stderr_is stderr_isnt stderr_like stderr_unlike =item output output_is output_isnt output_like output_unlike =item combined combined_is combined_isnt combined_like combined_unlike =item tests All of the above, this is the default when no options are given. =back L allows for many other options, I encourage reading its documentation. =cut =head1 FUNCTIONS =cut =head2 stdout_from my $stdout = stdout_from($coderef) my $stdout = stdout_from { ... }; stdout_from() executes $coderef and captures STDOUT. =cut sub stdout_from (&) { my $test = shift; my $stdout = capture_stdout { select( ( select(STDOUT), $| = 1 )[0] ); $test->() }; return $stdout; } =head2 stderr_from my $stderr = stderr_from($coderef) my $stderr = stderr_from { ... }; stderr_from() executes $coderef and captures STDERR. =cut sub stderr_from (&) { my $test = shift; # XXX why is this here and not in output_from or combined_from -- xdg, 2012-05-13 local $SIG{__WARN__} = sub { print STDERR @_ } if $] < 5.008; my $stderr = capture_stderr { select( ( select(STDERR), $| = 1 )[0] ); $test->() }; return $stderr; } =head2 output_from my ($stdout, $stderr) = output_from($coderef) my ($stdout, $stderr) = output_from {...}; output_from() executes $coderef one time capturing both STDOUT and STDERR. =cut sub output_from (&) { my $test = shift; my ($stdout, $stderr) = capture { select( ( select(STDOUT), $| = 1 )[0] ); select( ( select(STDERR), $| = 1 )[0] ); $test->(); }; return ( $stdout, $stderr ); } =head2 combined_from my $combined = combined_from($coderef); my $combined = combined_from {...}; combined_from() executes $coderef one time combines STDOUT and STDERR, and captures them. combined_from() is equivalent to using 2>&1 in UNIX. =cut sub combined_from (&) { my $test = shift; my $combined = capture_merged { select( ( select(STDOUT), $| = 1 )[0] ); select( ( select(STDERR), $| = 1 )[0] ); $test->(); }; return $combined; } sub _chkregex { my %regexs = @_; foreach my $test ( keys(%regexs) ) { next unless ( defined( $regexs{$test} ) ); my $usable_regex = $Test->maybe_regex( $regexs{$test} ); unless ( defined($usable_regex) ) { my $ok = $Test->ok( 0, $test ); $Test->diag("'$regexs{$test}' doesn't look much like a regex to me."); # unless $ok; return $ok; } } return 1; } =head1 AUTHOR Currently maintained by brian d foy, C. Shawn Sorichetti, C<< >> =head1 SOURCE AVAILABILITY This module is in Github: http://github.com/briandfoy/test-output/tree/master =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 ACKNOWLEDGEMENTS Thanks to chromatic whose TieOut.pm was the basis for capturing output. Also thanks to rjbs for his help cleaning the documentation, and pushing me to L. Thanks to David Wheeler for providing code block support and tests. Thanks to Michael G Schwern for the solution to combining STDOUT and STDERR. =head1 COPYRIGHT & LICENSE Copyright 2005-2013 Shawn Sorichetti, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Test::Output