Hello community,
here is the log from the commit of package perl-Test-Script for
openSUSE:Factory checked in at 2019-10-28 16:59:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Test-Script (Old)
and /work/SRC/openSUSE:Factory/.perl-Test-Script.new.2990 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-Script"
Mon Oct 28 16:59:27 2019 rev:28 rq:743502 version:1.26
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Test-Script/perl-Test-Script.changes
2018-10-01 08:19:21.409893536 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Test-Script.new.2990/perl-Test-Script.changes
2019-10-28 17:00:23.857760117 +0100
@@ -1,0 +2,10 @@
+Mon Oct 28 11:03:32 UTC 2019 - <[email protected]>
+
+- updated to 1.26
+ see /usr/share/doc/packages/perl-Test-Script/Changes
+
+ 1.26 2019-10-25 21:22:03 -0700
+ - Add program_runs and related functions for testing programs
+ that do not run under Perl (gh#26, gh#27)
+
+-------------------------------------------------------------------
Old:
----
Test-Script-1.25.tar.gz
New:
----
Test-Script-1.26.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Test-Script.spec ++++++
--- /var/tmp/diff_new_pack.Bk5C7w/_old 2019-10-28 17:00:25.053761554 +0100
+++ /var/tmp/diff_new_pack.Bk5C7w/_new 2019-10-28 17:00:25.057761559 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Test-Script
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,13 +17,13 @@
Name: perl-Test-Script
-Version: 1.25
+Version: 1.26
Release: 0
%define cpan_name Test-Script
Summary: Basic cross-platform tests for scripts
License: Artistic-1.0 OR GPL-1.0-or-later
Group: Development/Libraries/Perl
-Url: http://search.cpan.org/dist/Test-Script/
+Url: https://metacpan.org/release/%{cpan_name}
Source0:
https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
BuildArch: noarch
@@ -44,6 +44,9 @@
the testing you will need to do for scripts in the _script_ (or _bin_ as is
also commonly used) paths of your Perl distribution.
+It also provides similar functions for testing programs that are not Perl
+scripts.
+
Further, it aims to provide this functionality with perfect
platform-compatibility, and in a way that is as unobtrusive as possible.
@@ -60,13 +63,14 @@
%prep
%setup -q -n %{cpan_name}-%{version}
+find . -type f ! -path "*/t/*" ! -name "*.pl" ! -name "*.sh" -print0 | xargs
-0 chmod 644
%build
-%{__perl} Makefile.PL INSTALLDIRS=vendor
-%{__make} %{?_smp_mflags}
+perl Makefile.PL INSTALLDIRS=vendor
+make %{?_smp_mflags}
%check
-%{__make} test
+make test
%install
%perl_make_install
++++++ Test-Script-1.25.tar.gz -> Test-Script-1.26.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/Changes new/Test-Script-1.26/Changes
--- old/Test-Script-1.25/Changes 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/Changes 2019-10-26 06:22:06.000000000 +0200
@@ -1,5 +1,9 @@
Revision history for Perl extension Test-Script
+1.26 2019-10-25 21:22:03 -0700
+ - Add program_runs and related functions for testing programs
+ that do not run under Perl (gh#26, gh#27)
+
1.25 2018-09-27 15:33:19 -0400
- Production release identical to 1.24_01 release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/INSTALL new/Test-Script-1.26/INSTALL
--- old/Test-Script-1.25/INSTALL 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/INSTALL 2019-10-26 06:22:06.000000000 +0200
@@ -48,6 +48,19 @@
"configure_requires" key of META.yml or the
"{prereqs}{configure}{requires}" key of META.json.
+## Other Prerequisites
+
+This distribution may require additional modules to be installed after running
+Makefile.PL.
+Look for prerequisites in the following phases:
+
+* to run make, PHASE = build
+* to use the module code itself, PHASE = runtime
+* to run tests, PHASE = test
+
+They can all be found in the "PHASE_requires" key of MYMETA.yml or the
+"{prereqs}{PHASE}{requires}" key of MYMETA.json.
+
## Documentation
Test-Script documentation is available as POD.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/LICENSE new/Test-Script-1.26/LICENSE
--- old/Test-Script-1.25/LICENSE 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/LICENSE 2019-10-26 06:22:06.000000000 +0200
@@ -1,4 +1,4 @@
-This software is copyright (c) 2017 by Adam Kennedy.
+This software is copyright (c) 2019 by Adam Kennedy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
@@ -12,7 +12,7 @@
--- The GNU General Public License, Version 1, February 1989 ---
-This software is Copyright (c) 2017 by Adam Kennedy.
+This software is Copyright (c) 2019 by Adam Kennedy.
This is free software, licensed under:
@@ -272,7 +272,7 @@
--- The Artistic License 1.0 ---
-This software is Copyright (c) 2017 by Adam Kennedy.
+This software is Copyright (c) 2019 by Adam Kennedy.
This is free software, licensed under:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/MANIFEST
new/Test-Script-1.26/MANIFEST
--- old/Test-Script-1.25/MANIFEST 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/MANIFEST 2019-10-26 06:22:06.000000000 +0200
@@ -24,6 +24,9 @@
t/bug_gh9.t
t/test_script__exports.t
t/test_script__import.t
+t/test_script__program_runs.t
+t/test_script__program_stderr.t
+t/test_script__program_stdout.t
t/test_script__script_compiles.t
t/test_script__script_runs.t
t/test_script__script_stderr.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/META.json
new/Test-Script-1.26/META.json
--- old/Test-Script-1.25/META.json 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/META.json 2019-10-26 06:22:06.000000000 +0200
@@ -26,7 +26,7 @@
"FindBin" : "0",
"Test::EOL" : "0",
"Test::Fixme" : "0.07",
- "Test::More" : "0.94",
+ "Test::More" : "0.98",
"Test::NoTabs" : "0",
"Test::Pod" : "0",
"Test::Pod::Coverage" : "0",
@@ -56,7 +56,7 @@
"provides" : {
"Test::Script" : {
"file" : "lib/Test/Script.pm",
- "version" : "1.25"
+ "version" : "1.26"
}
},
"release_status" : "stable",
@@ -71,14 +71,15 @@
"web" : "https://github.com/plicease/Test-Script"
}
},
- "version" : "1.25",
+ "version" : "1.26",
"x_contributors" : [
"Adam Kennedy",
"Graham Ollis <[email protected]>",
- "Brendan Byrd"
+ "Brendan Byrd",
+ "Chris White <[email protected]>"
],
- "x_generated_by_perl" : "v5.29.2",
- "x_serialization_backend" : "Cpanel::JSON::XS version 4.05",
+ "x_generated_by_perl" : "v5.28.1",
+ "x_serialization_backend" : "Cpanel::JSON::XS version 4.12",
"x_use_unsafe_inc" : 0
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/META.yml
new/Test-Script-1.26/META.yml
--- old/Test-Script-1.25/META.yml 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/META.yml 2019-10-26 06:22:06.000000000 +0200
@@ -19,7 +19,7 @@
provides:
Test::Script:
file: lib/Test/Script.pm
- version: '1.25'
+ version: '1.26'
requires:
Capture::Tiny: '0'
File::Spec: '0.80'
@@ -32,11 +32,12 @@
bugtracker: https://github.com/plicease/Test-Script/issues
homepage: https://metacpan.org/pod/Test::Script
repository: git://github.com/plicease/Test-Script.git
-version: '1.25'
+version: '1.26'
x_contributors:
- 'Adam Kennedy'
- 'Graham Ollis <[email protected]>'
- 'Brendan Byrd'
-x_generated_by_perl: v5.29.2
+ - 'Chris White <[email protected]>'
+x_generated_by_perl: v5.28.1
x_serialization_backend: 'YAML::Tiny version 1.73'
x_use_unsafe_inc: 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/Makefile.PL
new/Test-Script-1.26/Makefile.PL
--- old/Test-Script-1.25/Makefile.PL 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/Makefile.PL 2019-10-26 06:22:06.000000000 +0200
@@ -1,11 +1,11 @@
-use strict; use warnings;
BEGIN {
+ use strict; use warnings;
unless(eval q{ use 5.008001; 1}) {
print "Perl 5.008001 or better required\n";
exit;
}
}
-# This file was automatically generated by
Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.28.
+# This file was automatically generated by
Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.38.
use strict;
use warnings;
use 5.008001;
@@ -35,10 +35,10 @@
"TEST_REQUIRES" => {
"Test2::V0" => "0.000060"
},
- "VERSION" => "1.25",
+ "VERSION" => "1.26",
"test" => {
"TESTS" => "t/*.t"
- }
+ }
);
my %FallbackPrereqs = (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/README new/Test-Script-1.26/README
--- old/Test-Script-1.25/README 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/README 2019-10-26 06:22:06.000000000 +0200
@@ -4,7 +4,7 @@
VERSION
- version 1.25
+ version 1.26
SYNOPSIS
@@ -14,6 +14,8 @@
script_compiles('script/myscript.pl');
script_runs(['script/myscript.pl', '--my-argument']);
+ program_runs(['ls', '/dev']);
+
done_testing;
DESCRIPTION
@@ -22,6 +24,9 @@
of the testing you will need to do for scripts in the script (or bin as
is also commonly used) paths of your Perl distribution.
+ It also provides similar functions for testing programs that are not
+ Perl scripts.
+
Further, it aims to provide this functionality with perfect
platform-compatibility, and in a way that is as unobtrusive as
possible.
@@ -186,10 +191,84 @@
Tests if the output to stderr from the previous "script_runs" does NOT
match the regular expression.
+ program_runs
+
+ program_runs( $program, $test_name );
+ program_runs( \@program_and_arguments, $test_name );
+ program_runs( $program, \%options, $test_name );
+ program_runs( \@program_and_arguments, \%options, $test_name );
+
+ The "program_runs" test executes the given program and checks that it
+ returns success. This function works like "script_runs" except:
+
+ * The path $program or @program_and_arguments is passed as-is to
+ system() <https://perldoc.perl.org/functions/system.html>. This means
+ program_runs can test any program, not just Perl scripts.
+
+ * The %options do not support the interpreter_options key.
+
+ See File::Spec or Path::Class for routines useful in building pathnames
+ in a cross-platform way.
+
+ program_stdout_is
+
+ program_stdout_is $expected_stdout, $test_name;
+
+ Tests if the output to stdout from the previous "program_runs" matches
+ the expected value exactly.
+
+ program_stdout_isnt
+
+ program_stdout_is $expected_stdout, $test_name;
+
+ Tests if the output to stdout from the previous "program_runs" does NOT
+ match the expected value exactly.
+
+ program_stdout_like
+
+ program_stdout_like $regex, $test_name;
+
+ Tests if the output to stdout from the previous "program_runs" matches
+ the regular expression.
+
+ program_stdout_unlike
+
+ program_stdout_unlike $regex, $test_name;
+
+ Tests if the output to stdout from the previous "program_runs" does NOT
+ match the regular expression.
+
+ program_stderr_is
+
+ program_stderr_is $expected_stderr, $test_name;
+
+ Tests if the output to stderr from the previous "program_runs" matches
+ the expected value exactly.
+
+ program_stderr_isnt
+
+ program_stderr_is $expected_stderr, $test_name;
+
+ Tests if the output to stderr from the previous "program_runs" does NOT
+ match the expected value exactly.
+
+ program_stderr_like
+
+ program_stderr_like $regex, $test_name;
+
+ Tests if the output to stderr from the previous "program_runs" matches
+ the regular expression.
+
+ program_stderr_unlike
+
+ program_stderr_unlike $regex, $test_name;
+
+ Tests if the output to stderr from the previous "program_runs" does NOT
+ match the regular expression.
+
CAVEATS
- This module is fully supported back to Perl 5.8.1. In the near future,
- support for the older pre-Test2 Test::Builer will be dropped.
+ This module is fully supported back to Perl 5.8.1.
The STDIN handle will be closed when using script_runs with the stdin
option. An older version used IPC::Run3, which attempted to save STDIN,
@@ -211,9 +290,11 @@
Brendan Byrd
+ Chris White <[email protected]>
+
COPYRIGHT AND LICENSE
- This software is copyright (c) 2017 by Adam Kennedy.
+ This software is copyright (c) 2019 by Adam Kennedy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/dist.ini
new/Test-Script-1.26/dist.ini
--- old/Test-Script-1.25/dist.ini 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/dist.ini 2019-10-26 06:22:06.000000000 +0200
@@ -3,8 +3,8 @@
author = Adam Kennedy
license = Perl_5
copyright_holder = Adam Kennedy
-copyright_year = 2017
-version = 1.25
+copyright_year = 2019
+version = 1.26
[@Author::Plicease]
:version = 2.28
@@ -42,6 +42,7 @@
current = Graham Ollis <[email protected]>
original = Adam Kennedy
contributor = Brendan Byrd
+contributor = Chris White <[email protected]>
[PruneFiles]
filename = xt/release/changes.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/lib/Test/Script.pm
new/Test-Script-1.26/lib/Test/Script.pm
--- old/Test-Script-1.25/lib/Test/Script.pm 2018-09-27 21:33:23.000000000
+0200
+++ new/Test-Script-1.26/lib/Test/Script.pm 2019-10-26 06:22:06.000000000
+0200
@@ -1,7 +1,7 @@
package Test::Script;
# ABSTRACT: Basic cross-platform tests for scripts
-our $VERSION = '1.25'; # VERSION
+our $VERSION = '1.26'; # VERSION
use 5.008001;
@@ -30,6 +30,15 @@
script_stderr_isnt
script_stderr_like
script_stderr_unlike
+ program_runs
+ program_stdout_is
+ program_stdout_isnt
+ program_stdout_like
+ program_stdout_unlike
+ program_stderr_is
+ program_stderr_isnt
+ program_stderr_like
+ program_stderr_unlike
};
sub import {
@@ -81,7 +90,7 @@
}
#####################################################################
-# Test Functions
+# Test Functions for Scripts
sub script_compiles {
@@ -144,7 +153,7 @@
sub script_runs {
my $args = _script(shift);
- my $opt = _options(\@_);
+ my $opt = _options(\$stdout, \$stderr, 1, \@_);
my $unix = shift @$args;
my $path = path( $unix );
my $pargs = [ @{ _perl_args($path) }, @{ $opt->{interpreter_options} } ];
@@ -153,6 +162,16 @@
$stdout = '';
$stderr = '';
+ unshift @_, "Script $unix runs" unless $_[0];
+ unshift @_, $cmd, $opt;
+ goto &_run;
+}
+
+# Run a script or program and provide test events corresponding to the results.
+# Call as _run(\@cmd, \%opt, "Test description")
+sub _run {
+ my ($cmd, $opt, $description) = @_;
+
if($opt->{stdin})
{
my $filename;
@@ -183,15 +202,15 @@
}
(${$opt->{stdout}}, ${$opt->{stderr}}) = capture { system(@$cmd) };
-
+
my $error = $@;
my $exit = $? ? ($? >> 8) : 0;
my $signal = $? ? ($? & 127) : 0;
my $ok = !! ( $error eq '' and $exit == $opt->{exit} and $signal ==
$opt->{signal} );
my $ctx = context();
- $ctx->ok( $ok, $_[0] || "Script $unix runs" );
- $ctx->diag( "$exit - $stderr" ) unless $ok;
+ $ctx->ok( $ok, $description );
+ $ctx->diag( "$exit - " . ${$opt->{stderr}} ) unless $ok;
$ctx->diag( "exception: $error" ) if $error;
$ctx->diag( "signal: $signal" ) unless $signal == $opt->{signal};
$ctx->release;
@@ -287,6 +306,89 @@
goto &_like;
}
+#####################################################################
+# Test Functions for Programs
+
+my $program_stdout;
+my $program_stderr;
+
+
+sub program_runs {
+ my $cmd = _script(shift);
+ my $opt = _options(\$program_stdout, \$program_stderr, 0, \@_);
+ $program_stdout = '';
+ $program_stderr = '';
+
+ unshift @_, "Program $$cmd[0] runs" unless $_[0];
+ unshift @_, $cmd, $opt;
+ goto &_run;
+}
+
+
+sub program_stdout_is
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stdout, $pattern, 0, 0, $name || 'stdout matches' );
+ goto &_like;
+}
+
+
+sub program_stdout_isnt
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stdout, $pattern, 0, 1, $name || 'stdout does not match' );
+ goto &_like;
+}
+
+
+sub program_stdout_like
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stdout, $pattern, 1, 0, $name || 'stdout matches' );
+ goto &_like;
+}
+
+
+sub program_stdout_unlike
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stdout, $pattern, 1, 1, $name || 'stdout does not match' );
+ goto &_like;
+}
+
+
+sub program_stderr_is
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stderr, $pattern, 0, 0, $name || 'stderr matches' );
+ goto &_like;
+}
+
+
+sub program_stderr_isnt
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stderr, $pattern, 0, 1, $name || 'stderr does not match' );
+ goto &_like;
+}
+
+
+sub program_stderr_like
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stderr, $pattern, 1, 0, $name || 'stderr matches' );
+ goto &_like;
+}
+
+
+sub program_stderr_unlike
+{
+ my($pattern, $name) = @_;
+ @_ = ($program_stderr, $pattern, 1, 1, $name || 'stderr does not match' );
+ goto &_like;
+}
+
+
######################################################################
# Support Functions
@@ -322,17 +424,21 @@
# Inline some basic Params::Util functions
sub _options {
+ my $ref_stdout = shift;
+ my $ref_stderr = shift;
+ my $permit_interpreter_options = shift;
my %options = ref($_[0]->[0]) eq 'HASH' ? %{ shift @{ $_[0] } }: ();
$options{exit} = 0 unless defined $options{exit};
$options{signal} = 0 unless defined $options{signal};
my $stdin = '';
#$options{stdin} = \$stdin unless defined $options{stdin};
- $options{stdout} = \$stdout unless defined $options{stdout};
- $options{stderr} = \$stderr unless defined $options{stderr};
+ $options{stdout} = $ref_stdout unless defined $options{stdout};
+ $options{stderr} = $ref_stderr unless defined $options{stderr};
if(defined $options{interpreter_options})
{
+ die "interpreter_options not supported" unless $permit_interpreter_options;
unless(ref $options{interpreter_options} eq 'ARRAY')
{
require Text::ParseWords;
@@ -374,7 +480,7 @@
=head1 VERSION
-version 1.25
+version 1.26
=head1 SYNOPSIS
@@ -384,6 +490,8 @@
script_compiles('script/myscript.pl');
script_runs(['script/myscript.pl', '--my-argument']);
+ program_runs(['ls', '/dev']);
+
done_testing;
=head1 DESCRIPTION
@@ -392,6 +500,9 @@
of the testing you will need to do for scripts in the F<script> (or F<bin>
as is also commonly used) paths of your Perl distribution.
+It also provides similar functions for testing programs that are not
+Perl scripts.
+
Further, it aims to provide this functionality with perfect
platform-compatibility, and in a way that is as unobtrusive as possible.
@@ -564,10 +675,92 @@
Tests if the output to stderr from the previous L</script_runs> does NOT match
the regular
expression.
+=head2 program_runs
+
+ program_runs( $program, $test_name );
+ program_runs( \@program_and_arguments, $test_name );
+ program_runs( $program, \%options, $test_name );
+ program_runs( \@program_and_arguments, \%options, $test_name );
+
+The L</program_runs> test executes the given program and checks
+that it returns success. This function works like L</script_runs> except:
+
+=over 4
+
+=item *
+
+The path C<$program> or C<@program_and_arguments> is passed as-is to
+L<system()|https://perldoc.perl.org/functions/system.html>. This means
+C<program_runs> can test any program, not just Perl scripts.
+
+=item *
+
+The C<%options> do not support the C<interpreter_options> key.
+
+=back
+
+See L<File::Spec> or L<Path::Class> for routines useful in building pathnames
+in a cross-platform way.
+
+=head2 program_stdout_is
+
+ program_stdout_is $expected_stdout, $test_name;
+
+Tests if the output to stdout from the previous L</program_runs> matches the
+expected value exactly.
+
+=head2 program_stdout_isnt
+
+ program_stdout_is $expected_stdout, $test_name;
+
+Tests if the output to stdout from the previous L</program_runs> does NOT
match the
+expected value exactly.
+
+=head2 program_stdout_like
+
+ program_stdout_like $regex, $test_name;
+
+Tests if the output to stdout from the previous L</program_runs> matches the
regular
+expression.
+
+=head2 program_stdout_unlike
+
+ program_stdout_unlike $regex, $test_name;
+
+Tests if the output to stdout from the previous L</program_runs> does NOT
match the regular
+expression.
+
+=head2 program_stderr_is
+
+ program_stderr_is $expected_stderr, $test_name;
+
+Tests if the output to stderr from the previous L</program_runs> matches the
+expected value exactly.
+
+=head2 program_stderr_isnt
+
+ program_stderr_is $expected_stderr, $test_name;
+
+Tests if the output to stderr from the previous L</program_runs> does NOT
match the
+expected value exactly.
+
+=head2 program_stderr_like
+
+ program_stderr_like $regex, $test_name;
+
+Tests if the output to stderr from the previous L</program_runs> matches the
regular
+expression.
+
+=head2 program_stderr_unlike
+
+ program_stderr_unlike $regex, $test_name;
+
+Tests if the output to stderr from the previous L</program_runs> does NOT
match the regular
+expression.
+
=head1 CAVEATS
-This module is fully supported back to Perl 5.8.1. In the near future, support
-for the older pre-Test2 Test::Builer will be dropped.
+This module is fully supported back to Perl 5.8.1.
The STDIN handle will be closed when using script_runs with the stdin option.
An older version used L<IPC::Run3>, which attempted to save STDIN, but
@@ -588,9 +781,11 @@
Brendan Byrd
+Chris White E<lt>[email protected]<gt>
+
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2017 by Adam Kennedy.
+This software is copyright (c) 2019 by Adam Kennedy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/00_diag.t
new/Test-Script-1.26/t/00_diag.t
--- old/Test-Script-1.25/t/00_diag.t 2018-09-27 21:33:23.000000000 +0200
+++ new/Test-Script-1.26/t/00_diag.t 2019-10-26 06:22:06.000000000 +0200
@@ -1,7 +1,7 @@
use Test2::V0 -no_srand => 1;
use Config;
-eval q{ require Test::More };
+eval { require 'Test/More.pm' };
# This .t file is generated.
# make changes instead to dist.ini
@@ -35,7 +35,7 @@
my $max = 1;
$max = $_ > $max ? $_ : $max for map { length $_ } @modules;
-our $format = "%-${max}s %s";
+our $format = "%-${max}s %s";
spacer;
@@ -44,13 +44,13 @@
if(@keys > 0)
{
diag "$_=$ENV{$_}" for @keys;
-
+
if($ENV{PERL5LIB})
{
spacer;
diag "PERL5LIB path";
diag $_ for split $Config{path_sep}, $ENV{PERL5LIB};
-
+
}
elsif($ENV{PERLLIB})
{
@@ -58,7 +58,7 @@
diag "PERLLIB path";
diag $_ for split $Config{path_sep}, $ENV{PERLLIB};
}
-
+
spacer;
}
@@ -66,9 +66,11 @@
foreach my $module (sort @modules)
{
- if(eval qq{ require $module; 1 })
+ my $pm = "$module.pm";
+ $pm =~ s{::}{/}g;
+ if(eval { require $pm; 1 })
{
- my $ver = eval qq{ \$$module\::VERSION };
+ my $ver = eval { $module->VERSION };
$ver = 'undef' unless defined $ver;
diag sprintf $format, $module, $ver;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__exports.t
new/Test-Script-1.26/t/test_script__exports.t
--- old/Test-Script-1.25/t/test_script__exports.t 2018-09-27
21:33:23.000000000 +0200
+++ new/Test-Script-1.26/t/test_script__exports.t 2019-10-26
06:22:06.000000000 +0200
@@ -15,6 +15,15 @@
script_stderr_isnt
script_stderr_like
script_stderr_unlike
+ program_runs
+ program_stdout_is
+ program_stdout_isnt
+ program_stdout_like
+ program_stdout_unlike
+ program_stderr_is
+ program_stderr_isnt
+ program_stderr_like
+ program_stderr_unlike
);
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__program_runs.t
new/Test-Script-1.26/t/test_script__program_runs.t
--- old/Test-Script-1.25/t/test_script__program_runs.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Test-Script-1.26/t/test_script__program_runs.t 2019-10-26
06:22:06.000000000 +0200
@@ -0,0 +1,230 @@
+use Test2::V0 -no_srand => 1;
+use Test::Script;
+use File::Temp qw( tempdir );
+use Data::Dumper qw( Dumper );
+use Probe::Perl;
+
+# Use the Perl interpreter as the program since it's the only one we know
+# exists. The files in t/bin do not use any modules, so we don't have
+# to worry about passing @INC down.
+my $perl = Probe::Perl->find_perl_interpreter() or die "Can't find perl";
+
+subtest 'no interpreter_options' => sub {
+ like(
+ dies { program_runs $perl, { interpreter_options => 1 } },
+ qr{interpreter_options},
+ 'program_runs rejects {interpreter_options => ...}'
+ );
+};
+
+subtest 'good' => sub {
+
+ subtest 'default name' => sub {
+
+ my $rv;
+ my $events;
+
+ is(
+ $events = intercept { $rv = program_runs [$perl, 't/bin/good.pl'] },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => "Program $perl runs";
+ };
+ end;
+ },
+ 'program_runs: perl t/bin/good.pl',
+ );
+
+ diag Dumper($events) unless $rv;
+
+ is $rv, T(), 'program_runs returns true as convenience';
+
+ };
+
+ subtest 'custom name' => sub {
+
+ my $rv;
+ my $events;
+
+ is(
+ $events = intercept { $rv = program_runs [$perl, 't/bin/good.pl'], 'It
worked' },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'It worked';
+ };
+ end;
+ },
+ 'program_runs perl t/bin/good.pl It worked',
+ );
+
+ diag Dumper($events) unless $rv;
+
+ is $rv, T(), 'program_runs returns true as convenience';
+
+ };
+
+};
+
+subtest 'bad: returns 4' => sub {
+
+ subtest 'default name' => sub {
+
+ my $rv;
+ my $events;
+
+ my $rv2 = is(
+ $events = intercept { $rv = program_runs [$perl, 't/bin/four.pl'] },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => "Program $perl runs";
+ };
+ event Diag => sub {};
+ event Diag => sub {
+ call message => match qr{4 - (?:Using.*\n# )?Standard Error\n};
+ };
+ end;
+ },
+ 'program_runs perl t/bin/good.pl',
+ );
+
+ diag Dumper($events) unless $rv2;
+
+ is $rv, F(), 'program_runs returns false as convenience';
+
+ };
+
+ subtest 'custom name' => sub {
+
+ my $rv;
+ my $events;
+
+ my $rv2 = is(
+ $events = intercept { $rv = program_runs [$perl, 't/bin/four.pl'], 'It
worked' },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'It worked';
+ };
+ event Diag => sub {};
+ event Diag => sub {
+ call message => match qr{4 - (?:Using.*\n# )?Standard Error\n};
+ };
+ end;
+ },
+ 'program_runs perl t/bin/good.pl It worked',
+ );
+
+ diag Dumper($events) unless $rv2;
+
+ is $rv, F(), 'program_runs returns false as convenience';
+
+ };
+
+};
+
+subtest 'stdin' => sub {
+
+ # see https://github.com/plicease/Test-Script/issues/23
+
+ subtest 'filename' => sub {
+
+ program_runs [$perl, 't/bin/stdin.pl'], { stdin => 't/bin/stdin.txt' };
+ program_stdout_like qr{fbbbaz};
+
+ };
+
+ subtest 'scalar ref' => sub {
+
+ program_runs [$perl, 't/bin/stdin.pl'], { stdin => \'helloooo there' };
+ program_stdout_like qr{hellbbbb there};
+
+ };
+
+};
+
+subtest exception => sub {
+
+ my $events;
+
+ is(
+ $events = intercept { program_runs( [$perl, 't/bin/missing.pl'] ) },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => "Program $perl runs";
+ };
+ event Diag => sub {};
+ event Diag => sub { call message => match(qr{^2 - })};
+ end;
+ },
+ );
+
+};
+
+subtest 'signal' => sub {
+
+ skip_all 'not on Winows' if $^O eq 'MSWin32';
+
+ my $events;
+
+ is(
+ $events = intercept { program_runs( [$perl, 't/bin/signal.pl'] ) },
+ array {
+ event Ok => sub {
+ call pass => F();
+ };
+ event Diag => sub {};
+ event Diag => sub { call message => '0 - ' };
+ event Diag => sub { call message => 'signal: 9' };
+ end;
+ },
+ );
+
+};
+
+subtest 'non-zero exit' => sub {
+
+ is(
+ intercept { program_runs [$perl, 't/bin/four.pl'], { exit => 4 } },
+ array {
+ event Ok => sub {
+ call pass => T();
+ };
+ end;
+ },
+ );
+
+};
+
+subtest 'signal' => sub {
+
+ skip_all 'not for windows' if $^O eq 'MSWin32';
+
+ is(
+ intercept { program_runs [$perl, 't/bin/signal.pl'], { signal => 9 } },
+ array {
+ event Ok => sub {
+ call pass => T();
+ };
+ end;
+ },
+ );
+
+};
+
+subtest 'scalar ref' => sub {
+
+ my $stdout = '';
+ my $stderr = '';
+
+ program_runs [$perl, 't/bin/print.pl'], { stdout => \$stdout, stderr =>
\$stderr };
+
+ is $stdout, "Standard Out\nsecond line\n";
+ is $stderr, "Standard Error\nanother line\n";
+
+};
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__program_stderr.t
new/Test-Script-1.26/t/test_script__program_stderr.t
--- old/Test-Script-1.25/t/test_script__program_stderr.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Test-Script-1.26/t/test_script__program_stderr.t 2019-10-26
06:22:06.000000000 +0200
@@ -0,0 +1,130 @@
+use Test2::V0 -no_srand => 1;
+use Test::Script;
+use Probe::Perl;
+
+my $perl = Probe::Perl->find_perl_interpreter() or die "Can't find perl";
+
+program_runs [$perl, 't/bin/print.pl'];
+
+is(
+ intercept { program_stderr_is "Standard Error\nanother line\n" },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stderr matches';
+ };
+ end;
+ },
+ 'program_stderr_is',
+);
+
+is(
+ intercept { program_stderr_isnt "XXXX" },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stderr does not match';
+ };
+ end;
+ },
+ 'program_stderr_isnt',
+);
+
+is(
+ intercept { program_stderr_is "XXX" },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stderr matches';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stderr_is fail',
+);
+
+is(
+ intercept { program_stderr_isnt "Standard Error\nanother line\n" },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stderr does not match';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stderr_isnt fail',
+);
+
+is(
+ intercept { program_stderr_like qr{tandard Er} },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stderr matches';
+ };
+ end;
+ },
+ 'program_stderr_like',
+);
+
+is(
+ intercept { program_stderr_like qr{XXXX} },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stderr matches';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stderr_like fail',
+);
+
+is(
+ intercept { program_stderr_unlike qr{XXXX} },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stderr does not match';
+ };
+ end;
+ },
+ 'program_stderr_unlike',
+);
+
+is(
+ intercept { program_stderr_unlike qr{tandard Er} },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stderr does not match';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stderr_unlike fail',
+);
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__program_stdout.t
new/Test-Script-1.26/t/test_script__program_stdout.t
--- old/Test-Script-1.25/t/test_script__program_stdout.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Test-Script-1.26/t/test_script__program_stdout.t 2019-10-26
06:22:06.000000000 +0200
@@ -0,0 +1,130 @@
+use Test2::V0 -no_srand => 1;
+use Test::Script;
+use Probe::Perl;
+
+my $perl = Probe::Perl->find_perl_interpreter() or die "Can't find perl";
+
+program_runs [$perl, 't/bin/print.pl'];
+
+is(
+ intercept { program_stdout_is "Standard Out\nsecond line\n" },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stdout matches';
+ };
+ end;
+ },
+ 'program_stdout_is',
+);
+
+is(
+ intercept { program_stdout_isnt "XXXX" },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stdout does not match';
+ };
+ end;
+ },
+ 'program_stdout_isnt',
+);
+
+is(
+ intercept { program_stdout_is "XXX" },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stdout matches';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stdout_is fail',
+);
+
+is(
+ intercept { program_stdout_isnt "Standard Out\nsecond line\n" },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stdout does not match';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stdout_isnt fail',
+);
+
+is(
+ intercept { program_stdout_like qr{tandard Ou} },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stdout matches';
+ };
+ end;
+ },
+ 'program_stdout_like',
+);
+
+is(
+ intercept { program_stdout_like qr{XXXX} },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stdout matches';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stdout_like fail',
+);
+
+is(
+ intercept { program_stdout_unlike qr{XXXX} },
+ array {
+ event Ok => sub {
+ call pass => T();
+ call name => 'stdout does not match';
+ };
+ end;
+ },
+ 'program_stdout_unlike',
+);
+
+is(
+ intercept { program_stdout_unlike qr{tandard Ou} },
+ array {
+ event Ok => sub {
+ call pass => F();
+ call name => 'stdout does not match';
+ };
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ event Diag => sub {};
+ end;
+ },
+ 'program_stdout_unlike fail'
+);
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__script_compiles.t
new/Test-Script-1.26/t/test_script__script_compiles.t
--- old/Test-Script-1.25/t/test_script__script_compiles.t 2018-09-27
21:33:23.000000000 +0200
+++ new/Test-Script-1.26/t/test_script__script_compiles.t 2019-10-26
06:22:06.000000000 +0200
@@ -3,7 +3,6 @@
use File::Spec;
use File::Temp qw( tempdir );
use Data::Dumper qw( Dumper );
-
# the first subtest replaces t/02_compiles_good.t
@@ -24,14 +23,14 @@
},
'script_compiles t/bin/good.pl',
);
-
+
diag Dumper($events) unless $rv;
is $rv, T(), 'script_compiles_ok returns true as convenience';
};
subtest 'with different name' => sub {
-
+
my $events;
my $rv;
@@ -88,14 +87,14 @@
diag Dumper($events) unless $rv2;
is $rv, F(), 'script_compiles_ok returns false as convenience';
-
+
};
subtest 'custom name' => sub {
-
+
my $rv;
my $events;
-
+
my $rv2 = is(
$events = intercept { $rv = script_compiles 't/bin/bad.pl', 'It worked'
},
array {
@@ -118,7 +117,7 @@
diag Dumper($events) unless $rv2;
is $rv, F(), 'script_compiles_ok returns false as convenience';
-
+
};
};
@@ -144,7 +143,7 @@
subtest exception => sub {
my $events;
-
+
is(
$events = intercept { script_compiles( 't/bin/missing.pl' ) },
array {
@@ -184,4 +183,3 @@
script_compiles 't/bin/taint.pl';
done_testing;
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__script_runs.t
new/Test-Script-1.26/t/test_script__script_runs.t
--- old/Test-Script-1.25/t/test_script__script_runs.t 2018-09-27
21:33:23.000000000 +0200
+++ new/Test-Script-1.26/t/test_script__script_runs.t 2019-10-26
06:22:06.000000000 +0200
@@ -23,7 +23,7 @@
},
'script_runs t/bin/good.pl',
);
-
+
diag Dumper($events) unless $rv;
is $rv, T(), 'script_compiles_ok returns true as convenience';
@@ -50,9 +50,8 @@
diag Dumper($events) unless $rv;
is $rv, T(), 'script_compiles_ok returns true as convenience';
-
- };
+ };
};
@@ -82,9 +81,9 @@
diag Dumper($events) unless $rv2;
is $rv, F(), 'script_compiles_ok returns false as convenience';
-
+
};
-
+
subtest 'custom name' => sub {
my $rv;
@@ -109,9 +108,8 @@
diag Dumper($events) unless $rv2;
is $rv, F(), 'script_compiles_ok returns false as convenience';
-
- };
+ };
};
@@ -141,22 +139,22 @@
script_runs 't/bin/stdin.pl', { stdin => 't/bin/stdin.txt' };
script_stdout_like qr{fbbbaz};
-
+
};
subtest 'scalar ref' => sub {
script_runs 't/bin/stdin.pl', { stdin => \'helloooo there' };
script_stdout_like qr{hellbbbb there};
-
+
};
-
+
};
subtest exception => sub {
my $events;
-
+
is(
$events = intercept { script_runs( 't/bin/missing.pl' ) },
array {
@@ -177,7 +175,7 @@
skip_all 'not on Winows' if $^O eq 'MSWin32';
my $events;
-
+
is(
$events = intercept { script_runs( 't/bin/signal.pl' ) },
array {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/t/test_script__script_stdout.t
new/Test-Script-1.26/t/test_script__script_stdout.t
--- old/Test-Script-1.25/t/test_script__script_stdout.t 2018-09-27
21:33:23.000000000 +0200
+++ new/Test-Script-1.26/t/test_script__script_stdout.t 2019-10-26
06:22:06.000000000 +0200
@@ -14,7 +14,7 @@
},
'script_stdout_is',
);
-
+
is(
intercept { script_stdout_isnt "XXXX" },
array {
@@ -44,7 +44,7 @@
},
'script_stdout_is fail',
);
-
+
is(
intercept { script_stdout_isnt "Standard Out\nsecond line\n" },
array {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Test-Script-1.25/xt/author/pod_coverage.t
new/Test-Script-1.26/xt/author/pod_coverage.t
--- old/Test-Script-1.25/xt/author/pod_coverage.t 2018-09-27
21:33:23.000000000 +0200
+++ new/Test-Script-1.26/xt/author/pod_coverage.t 2019-10-26
06:22:06.000000000 +0200
@@ -8,6 +8,8 @@
unless eval q{ use Test::Pod::Coverage; 1 };
plan skip_all => 'test requires YAML'
unless eval q{ use YAML; 1; };
+ plan skip_all => 'test does not always work in cip check'
+ if defined $ENV{CIPSTATIC} && $ENV{CIPSTATIC} eq 'true';
};
use Test::Pod::Coverage;
use YAML qw( LoadFile );