Test-Output-1.036/0000755000076500000240000000000014777260361012733 5ustar brianstaffTest-Output-1.036/LICENSE0000644000076500000240000002173314777260360013745 0ustar brianstaffThe Test::Output module is licensed under the same terms as perl itself, under the Artistic License 2.0. Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ******** This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions *********** "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution ******************************************************** (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version ****************************************************** (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source ********************************************************** (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified ****************************************************************** Versions without the Source *************************** (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package ********************************** (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version ******************************************************** (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions ****************** (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Test-Output-1.036/Changes0000644000076500000240000001047514777260360014234 0ustar brianstaffRevision history for Perl module Test::Output 1.036 2025-04-14T19:24:32Z * require a newer version.pm for v5.10.1 tests 1.035 2025-01-03T06:45:21Z * distro refresh and move to BRIANDFOY 1.034 2023-07-05T14:46:18Z * Remove unnecessary -T from pod tests. Now that v5.38 allows you to compile without taint support and those perls won't run if they see a -T, these tests needlessly fail there. * Edward Betts corrected some of the docs. 1.033 2021-02-11T00:21:54Z * v1.032 had some regressions because I released 1.031 from an unmerged branch. https://github.com/briandfoy/test-output/issues/8 This was noticed by Tina Müller in https://github.com/os-autoinst/os-autoinst/pull/1622 * I didn't realize that I'd released an experiment in 2017, but no own complained until it was reverted (by releasing from master). The experiment worked I guess? Sub::Exporter is gone, so the dependency tree for this is greatly reduced, and now it's gone again. 1.032 2021-01-28T22:15:07Z * Fix cut-n-paste error in docs (Github #6, hexcoder) 1.031 2017-03-29T21:30:57Z * Get rid of Sub::Exporter. That module has nice features that this module doesn't use and the prereq is causing problems with CPAN Testers. CPAN Grep didn't show anyone using advanced features for exports. 1.03 - 2014-01-03 * Get rid of MYMETA 1.02 - 2013-07-08 * Bump to stable release 1.01_02 - 2012-07-19 * Remove the ::Tie stuff. It should be fully Capture::Tiny now. 1.01_01 - 2012-05-14 * David Golden re-did everything with Capture::Tiny to get around the odd output paths that we couldn't handle with a tie. 1.01 - 2011-04-22 * Bump to a full release. This fixes the tests that failed in the new 5.14 regex stringification 0.16_03 - 2010-10-25 * Fix cat-o with handling $, 0.16_02 - 2010-10-19 * Update tests with hardcoded regex stringification for Perl's new (?^:) stuff 0.16_01 - 2009-06-09 * Added META_MERGE features from chorny 0.13 - 2009-03-08 * brian d foy (bdfoy@cpan.org) is the new maintainer * Updated docs for source code location, license, etc 0.12 - 2008-10-25 * Repacking to remove OS X extended attribute files that were causing tests to fail. 0.11 2008-21-10 * Fixes for STDERR handling under Perl 5.6. Thanks to brian d foy for the patch with tests. 0.10 2005-18-07 * Migrated from Exporter to Sub::Exporter 0.09 2005-09-11 * 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 2005-19-07 * Suppressed most warnings caused by newer versions of Test::Tester 0.07 2005-26-03 * 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 2005-07-03 * Applied patch from David Wheeler to support code blocks within tests as well as coderefs. 0.05 2005-04-03 * 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 2005-02-03 * 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 2005-16-02 * 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 2005-12-02 * 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 2005-12-02 * First version, released on an unsuspecting world. Test-Output-1.036/MANIFEST0000644000076500000240000000117214777260361014065 0ustar brianstaffChanges INSTALL.SKIP lib/Test/Output.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.pod SECURITY.md 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 xt/changes.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Test-Output-1.036/t/0000755000076500000240000000000014777260361013176 5ustar brianstaffTest-Output-1.036/t/pod.t0000644000076500000240000000021114777260360014136 0ustar brianstaff#!perl 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.036/t/stderr_unlike.t0000644000076500000240000000575414777260360016247 0ustar brianstaffuse 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.036/t/output_is.t0000644000076500000240000002516414777260360015425 0ustar brianstaffuse 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.036/t/stderr_isnt.t0000644000076500000240000000322514777260360015724 0ustar brianstaffuse 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.036/t/stderr_like.t0000644000076500000240000000604414777260360015675 0ustar brianstaffuse 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.036/t/carp-5.6.t0000644000076500000240000000056614777260360014624 0ustar brianstaffuse 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.036/t/combined_like.t0000644000076500000240000000670414777260360016155 0ustar brianstaffuse 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.036/t/stdout_unlike.t0000644000076500000240000000565514777260360016266 0ustar brianstaffuse 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.036/t/combined_is.t0000644000076500000240000001406314777260360015641 0ustar brianstaffuse 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.036/t/combined_isnt.t0000644000076500000240000001416714777260360016210 0ustar brianstaffuse 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.036/t/stdout_like.t0000644000076500000240000000564114777260360015716 0ustar brianstaffuse 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.036/t/output_like.t0000644000076500000240000003347314777260360015740 0ustar brianstaffuse 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.036/t/binmode.t0000644000076500000240000000032114777260360014773 0ustar brianstaff#!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.036/t/output_isnt.t0000644000076500000240000002571314777260360015767 0ustar brianstaffuse 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.036/t/stdout_isnt.t0000644000076500000240000000464614777260360015753 0ustar brianstaffuse 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.036/t/stdout_is.t0000644000076500000240000000510314777260360015376 0ustar brianstaffuse 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.036/t/stderr_is.t0000644000076500000240000000471314777260360015365 0ustar brianstaffuse 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.036/t/pod-coverage.t0000644000076500000240000000025114777260360015733 0ustar brianstaff#!perl 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.036/t/00.load.t0000644000076500000240000000017014777260360014515 0ustar brianstaffuse Test::More tests => 1; BEGIN { use_ok( 'Test::Output' ); } diag( "Testing Test::Output $Test::Output::VERSION" ); Test-Output-1.036/t/combined_unlike.t0000644000076500000240000000675214777260360016523 0ustar brianstaffuse 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.036/t/output_unlike.t0000644000076500000240000002442514777260360016300 0ustar brianstaffuse 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.036/xt/0000755000076500000240000000000014777260361013366 5ustar brianstaffTest-Output-1.036/xt/changes.t0000644000076500000240000000020314777260360015155 0ustar brianstaffuse Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); Test-Output-1.036/README.pod0000644000076500000240000001127114777260360014375 0ustar brianstaff=pod =encoding utf8 =for HTML =for HTML =for HTML =for HTML =for HTML Coverage Status =for HTML =for HTML =head1 The Test::Output module This is the I for the L Perl module. You're probably looking at this because you don't know where else to find what you're looking for. Read this once and you might never have to read one again for any Perl module. =head2 Documentation To read about L, look at the embedded documentation in the module itself. Inside the distribution, you can format it with L: % perldoc lib/Test/Output.pm If you have already installed the module, you can specify the module name instead of the file location: % perldoc Test::Output You can read the documentation and inspect the meta data at L. The standard module documentation has example uses in the SYNOPSIS section, but you can also look in the I directory (if it's there), or look at the test files in I. =head2 Installation You can install this module with a CPAN client, which will resolve and install the dependencies: % cpan Test::Output % cpanm Test::Output You can also install directly from the distribution directory, which will also install the dependencies: % cpan . % cpanm . You could install just this module manually: % perl Makefile.PL % make % make test % make install You probably don't want to do that unless you're fiddling with the module and only want to run the tests without installing anything. =head2 Source location The meta data, such as the source repository and bug tracker, is in I or the I files it creates. You can find that on those CPAN web interfaces, but you can also look at files directly in the source repository: L If you find a problem, file a ticket in the L. There are also backup repositories hosted on other services. These reflect the state of the main repo and exist only for redundancy: =over 4 =item * L =item * L =item * L =back =head2 GitHub Attestations This distribution now uses L, which allow you to verify that the archive file you have was made from the official repo. You need a GitHub account and the L. # download the distro file from GitHub, MetaCPAN, or a CPAN mirror $ gh auth login ...follow instructions... $ gh attestation verify Test-Output-1.23.tar.gz --owner briandfoy =head2 Getting help Although I'm happy to hear from module users in private email, that's the best way for me to forget to do something. Besides the issue trackers, you can find help at L or L, both of which have many competent Perlers who can answer your question, almost in real time. They might not know the particulars of this module, but they can help you diagnose your problem. You might like to read L. =head2 Copyright and License You should have received a I file, but the license is also noted in the module files. About the only thing you can't do is pretend that you wrote code that you didn't. =head2 Good luck! Enjoy, brian d foy, briandfoy@pobox.com =cut Test-Output-1.036/MANIFEST.SKIP0000644000076500000240000000212414777260360014627 0ustar brianstaff #!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 \.?appveyor.yml \.releaserc \.lwpcookies Test-.* TODO \bMANIFEST\s\d \bChanges\s\d \.icloud$ \A\.github\b \.gitattributes\b Test-Output-1.036/META.yml0000664000076500000240000000162114777260361014206 0ustar brianstaff--- abstract: 'Utilities to test STDOUT and STDERR messages.' author: - 'brian d foy ' build_requires: Test::More: '1' Test::Tester: '0.107' version: '0.86' configure_requires: ExtUtils::MakeMaker: '6.64' File::Spec::Functions: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010' keywords: - testing - STDOUT - STDERR license: artistic_2 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' perl: '5.008' resources: bugtracker: https://github.com/briandfoy/test-output/issues homepage: https://github.com/briandfoy/test-output repository: https://github.com/briandfoy/test-output version: '1.036' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Test-Output-1.036/lib/0000755000076500000240000000000014777260361013501 5ustar brianstaffTest-Output-1.036/lib/Test/0000755000076500000240000000000014777260361014420 5ustar brianstaffTest-Output-1.036/lib/Test/Output.pm0000644000076500000240000005355614777260360016273 0ustar brianstaffuse 5.008; package Test::Output; use warnings; use strict; use Test::Builder; use Capture::Tiny qw/capture capture_stdout capture_stderr capture_merged/; use Exporter qw(import); our %EXPORT_TAGS = ( 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 ) ], all => [ 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 ) ], ); our @EXPORT = keys %{ { map { $_ => 1 } map { @{ $EXPORT_TAGS{$_} } } keys %EXPORT_TAGS } }; my $Test = Test::Builder->new; =encoding utf8 =head1 NAME Test::Output - Utilities to test STDOUT and STDERR messages. =cut our $VERSION = '1.036'; =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 C or C. A number of different utilities are included to try and be as flexible as possible to the tester. Likewise, L provides a much more robust capture mechanism without than the original L. =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'; C captures output sent to C from C<$coderef> and compares it against C<$expected>. The test passes if equal. C passes if C is not equal to C<$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'; C captures the output sent to C from C<$coderef> and compares it to the regex in C<$expected>. The test passes if the regex matches. C 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'; C is similar to C, except that it captures C. The test passes if C from C<$coderef> equals C<$expected>. C passes if C is not equal to C<$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'; C is similar to C except that it compares the regex C<$expected> to C captured from C<$codref>. The test passes if the regex matches. C passes if C 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'; C directs C to C then captures C. This is equivalent to UNIXs C<< 2>&1 >>. The test passes if the combined C and C from $coderef equals $expected. C passes if combined C and C are not equal to C<$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'; C is similar to C except that it compares a regex (C<$expected)> to C and C captured from C<$codref>. The test passes if the regex matches. C passes if the combined C and C 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 C function is a combination of the C and C 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 C<$coderef> is only executed once. Unlike C and C which ignore STDERR and STDOUT respectively, C requires both C and C to match in order to pass. Setting either C<$expected_stdout> or C<$expected_stderr> to C ignores C or C respectively. output_is(sub {print "foo"; print STDERR "bar";},'foo',undef); is the same as stdout_is(sub {print "foo";},'foo') C provides the opposite function of C. It is a combination of C and C. output_isnt(sub {print "foo"; print STDERR "bar";},'bar','foo'); is functionally equivalent to stdout_isnt(sub {print "foo";},'bar') && stderr_isnt(sub {print STDERR "bar";},'foo'); As with C, setting either C<$expected_stdout> or C<$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'; C and C follow the same principles as C and C except they use a regular expression for matching. C attempts to match C<$regex_stdout> and C<$regex_stderr> against C and C 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 C, setting either C<$regex_stdout> or C<$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/); C test pass if output from C<$coderef> doesn't match C<$regex_stdout> and C<$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 subroutines are exported by default. =over 4 =item * :stdout - the subs with C in the name. =item * :stderr - the subs with C in the name. =item * :functions - the subs with C<_from> at the end. =item * :output - the subs with C in the name. =item * :combined - the subs with C in the name. =item * :tests - everything that outputs TAP =item * :all - everything (which is the same as the default) =back =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 { ... }; C executes C<$coderef> and captures C. =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 {...}; C executes C<$coderef> one time capturing both C and C. =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 {...}; C executes C<$coderef> one time combines C and C, and captures them. C is equivalent to using C<< 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 =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. (This feature has been removed since it uses none of L's strengths). Thanks to David Wheeler for providing code block support and tests. Thanks to Michael G Schwern for the solution to combining C and C. =head1 COPYRIGHT & LICENSE Copyright 2005-2021 Shawn Sorichetti, All Rights Reserved. This module is licensed under the Artistic License 2.0. =cut 1; # End of Test::Output Test-Output-1.036/Makefile.PL0000644000076500000240000000537714777260360014720 0ustar brianstaffpackage Test::Output; use strict; use warnings; =encoding utf8 =head1 The build file for Test::Output This build file is a modulino; it works as both a build script and a module. To build the distribution, run this file normally: % perl Makefile.PL But, it's more interesting than that. You can load it with C and call C to get the data structure it passes to C: my $package = require '/path/to/Makefile.PL'; my $arguments = $package->arguments; Note that C-ing a file makes an entry in C<%INC> for exactly that name. If you try to C another file with the same name, even from a different path, C thinks it has already loaded the file. As such, I recommend you always require the full path to the file. The return value of the C is a package name (in this case, the name of the main module. Use that to call the C method. Even if this distribution needs a higher version of Perl, this bit only needs v5.8. You can play with the data structure with a primitive Perl. =cut use File::Spec::Functions qw(catfile); my $module = __PACKAGE__; ( my $dist = $module ) =~ s/::/-/g; my $github = 'https://github.com/briandfoy/test-output'; my $main_file = catfile( 'lib', split /::/, "$module.pm" ); my %WriteMakefile = ( 'MIN_PERL_VERSION' => '5.008', 'NAME' => $module, 'AUTHOR' => 'brian d foy ', 'ABSTRACT_FROM' => $main_file, 'VERSION_FROM' => $main_file, 'LICENSE' => 'artistic_2', 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.64', 'File::Spec::Functions' => '0', }, 'BUILD_REQUIRES' => { }, 'TEST_REQUIRES' => { 'Test::More' => '1', 'Test::Tester' => '0.107', 'version' => '0.86', }, 'PREREQ_PM' => { 'File::Temp' => '0.17', # needs :seekable 'Capture::Tiny' => '0.17', }, 'META_MERGE' => { 'meta-spec' => { version => 2 }, keywords => ['testing','STDOUT','STDERR'], resources => { repository => { type => 'git', url => $github, web => $github, }, bugtracker => { web => "$github/issues", }, homepage => $github, }, }, clean => { FILES => "$dist-*" }, ); sub arguments { \%WriteMakefile } do_it() unless caller; sub do_it { require File::Spec; my $MM ='ExtUtils::MakeMaker'; my $MM_version = eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } || "$MM 6.64"; eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; eval "use Test::Manifest 1.21" if -e File::Spec->catfile( qw(t test_manifest) ); my $arguments = arguments(); my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; eval "require $minimum_perl;" or die $@; WriteMakefile( %$arguments ); } no warnings; __PACKAGE__; Test-Output-1.036/INSTALL.SKIP0000644000076500000240000000015614777260360014532 0ustar brianstaffREADME\.pod README.* # things that might be in local directories after fooling # around with them \.DS_Store Test-Output-1.036/SECURITY.md0000644000076500000240000000230514777260360014523 0ustar brianstaff# Security Policy for Test::Output ## Reporting security issues **Do not report security problems on public forums or in repository issues.** Privately report vulnerabilities to the maintainers listed at the end of this document. Include as many details as possible to reproduce the issue, including code samples or test cases. Check that your report does not expose any of your sensitive data, such as passwords, tokens, or other secrets. You do not need to have a solution or fix. Depending on the issue, CPANSec may be notified. Depending on the issue, CPANSec may be notified. You can also privately report issues to the CPAN Security Group (CPANSec) . This is especially important if you think a vulnerability is being actively exploited. CPANSec may report the issue to the relevant authorities. See [Report a Security Issue](https://security.metacpan.org/docs/report.html). ## Response to reports The maintainers aim to respond to all reports within one day, but this may be affected by life and other things that happen to people who maintain open source code. A new release will be provided as soon as possible. ## Maintainers * brian d foy, Test-Output-1.036/META.json0000664000076500000240000000312114777260361014353 0ustar brianstaff{ "abstract" : "Utilities to test STDOUT and STDERR messages.", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010", "keywords" : [ "testing", "STDOUT", "STDERR" ], "license" : [ "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Test-Output", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.64", "File::Spec::Functions" : "0" } }, "runtime" : { "requires" : { "Capture::Tiny" : "0.17", "File::Temp" : "0.17", "perl" : "5.008" } }, "test" : { "requires" : { "Test::More" : "1", "Test::Tester" : "0.107", "version" : "0.86" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/briandfoy/test-output/issues" }, "homepage" : "https://github.com/briandfoy/test-output", "repository" : { "type" : "git", "url" : "https://github.com/briandfoy/test-output", "web" : "https://github.com/briandfoy/test-output" } }, "version" : "1.036", "x_serialization_backend" : "JSON::PP version 4.16" }