Test-Output-1.033/ 000755 000765 000024 00000000000 14011074543 014172 5 ustar 00brian staff 000000 000000 Test-Output-1.033/LICENSE 000644 000765 000024 00000017403 14011074541 015202 0 ustar 00brian staff 000000 000000 The 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.
http://www.perlfoundation.org/artistic_license_2_0
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
Test-Output-1.033/Changes 000644 000765 000024 00000007662 14011074541 015476 0 ustar 00brian staff 000000 000000 Revision history for Perl module Test::Output
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 coudn'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
* Supressed 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.033/MANIFEST 000644 000765 000024 00000001156 14011074543 015326 0 ustar 00brian staff 000000 000000 Changes
INSTALL.SKIP
lib/Test/Output.pm
LICENSE
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
README.pod
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.033/t/ 000755 000765 000024 00000000000 14011074542 014434 5 ustar 00brian staff 000000 000000 Test-Output-1.033/xt/ 000755 000765 000024 00000000000 14011074542 014624 5 ustar 00brian staff 000000 000000 Test-Output-1.033/README.pod 000644 000765 000024 00000007734 14011074541 015644 0 ustar 00brian staff 000000 000000 =pod
=encoding utf8
=for HTML
=for HTML
=for HTML
=for HTML
=for HTML
=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:
=over 4
=item * L
=back
If you find a problem, file a ticket in the L:
=over 4
=item * L
=back
=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, bdfoy@cpan.org
=cut
Test-Output-1.033/MANIFEST.SKIP 000644 000765 000024 00000002102 14011074541 016061 0 ustar 00brian staff 000000 000000
#!start included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP
# Avoid version control files.
\bRCS\b
\bCVS\b
\bSCCS\b
,v$
\B\.svn\b
\B\.git\b
\B\.gitignore\b
\b_darcs\b
\B\.cvsignore$
# Avoid VMS specific MakeMaker generated files
\bDescrip.MMS$
\bDESCRIP.MMS$
\bdescrip.mms$
# Avoid Makemaker generated and utility files.
\bMANIFEST\.bak
\bMakefile$
\bblib/
\bMakeMaker-\d
\bpm_to_blib\.ts$
\bpm_to_blib$
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/
\bBuild.bat$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$
# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$
\.tmp$
\.#
\.rej$
# Avoid OS-specific files/dirs
# Mac OSX metadata
\B\.DS_Store
# Mac OSX SMB mount metadata files
\B\._
# Avoid Devel::Cover and Devel::CoverX::Covered files.
\bcover_db\b
\bcovered\b
# Avoid MYMETA files
^MYMETA\.
#!end included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP
\.?appveyor.yml
\.releaserc
\.lwpcookies
Test-.*
TODO
\bMANIFEST\s\d
\bChanges\s\d
\.icloud$
\A\.github\b
Test-Output-1.033/META.yml 000664 000765 000024 00000001576 14011074542 015455 0 ustar 00brian staff 000000 000000 ---
abstract: 'Utilities to test STDOUT and STDERR messages.'
author:
- 'brian d foy '
build_requires:
Test::More: '1'
Test::Tester: '0.107'
configure_requires:
ExtUtils::MakeMaker: '6.64'
File::Spec::Functions: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.44, 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.git
version: '1.033'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Test-Output-1.033/lib/ 000755 000765 000024 00000000000 14011074542 014737 5 ustar 00brian staff 000000 000000 Test-Output-1.033/Makefile.PL 000644 000765 000024 00000005343 14011074541 016147 0 ustar 00brian staff 000000 000000 package 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',
},
'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.git",
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.033/INSTALL.SKIP 000644 000765 000024 00000000156 14011074541 015770 0 ustar 00brian staff 000000 000000 README\.pod
README.*
# things that might be in local directories after fooling
# around with them
\.DS_Store
Test-Output-1.033/META.json 000664 000765 000024 00000003060 14011074543 015614 0 ustar 00brian staff 000000 000000 {
"abstract" : "Utilities to test STDOUT and STDERR messages.",
"author" : [
"brian d foy "
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.44, 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"
}
}
},
"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.git",
"web" : "https://github.com/briandfoy/test-output"
}
},
"version" : "1.033",
"x_serialization_backend" : "JSON::PP version 4.04"
}
Test-Output-1.033/lib/Test/ 000755 000765 000024 00000000000 14011074542 015656 5 ustar 00brian staff 000000 000000 Test-Output-1.033/lib/Test/Output.pm 000644 000765 000024 00000053551 14011074541 017524 0 ustar 00brian staff 000000 000000 use 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.033';
=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