Run-Parts-0.06000755001750001750 012173277225 12002 5ustar00abetar000000000000Run-Parts-0.06/Build.PL000444001750001750 220712173277225 13434 0ustar00abetar000000000000use Modern::Perl; use Module::Build; my $builder = Module::Build->new( module_name => 'Run::Parts', license => 'Perl_5', dist_author => q{Axel Beckert }, dist_version_from => 'lib/Run/Parts.pm', release_status => 'stable', create_readme => 1, meta_merge => { resources => { repository => 'https://github.com/xtaran/run-parts', bugtracker => "https://rt.cpan.org/Dist/Display.html?Name=Run-Parts", } }, configure_requires => { 'Module::Build' => '0.4004', 'Modern::Perl' => 0, }, test_requires => { 'Test::More' => 0, 'Test::Differences' => 0, 'Test::NoWarnings' => 0, 'File::Slurp' => 9999.06, }, requires => { perl => '5.10.0', autodie => 0, 'Taint::Util' => 0, 'File::Slurp' => 0, 'Exporter::Easy' => 0, 'Scalar::Util' => 0, }, develop_requires => { 'Pod::Readme' => 0, }, add_to_cleanup => [ 'Run-Parts-*', 'README', ], ); $builder->create_build_script(); Run-Parts-0.06/META.yml000444001750001750 212312173277225 13406 0ustar00abetar000000000000--- abstract: "Offers functionality of Debian's run-parts tool in Perl." author: - 'Axel Beckert ' build_requires: {} configure_requires: Modern::Perl: 0 Module::Build: 0.4004 dynamic_config: 1 generated_by: 'Module::Build version 0.4005, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Run-Parts provides: Run::Parts: file: lib/Run/Parts.pm version: 0.06 Run::Parts::Common: file: lib/Run/Parts/Common.pm version: 0.01 Run::Parts::Debian: file: lib/Run/Parts/Debian.pm version: 0.01 Run::Parts::Perl: file: lib/Run/Parts/Perl.pm version: 0.02 requires: Exporter::Easy: 0 File::Slurp: 0 Scalar::Util: 0 Taint::Util: 0 autodie: 0 perl: v5.10.0 resources: bugtracker: https://rt.cpan.org/Dist/Display.html?Name=Run-Parts license: http://dev.perl.org/licenses/ repository: https://github.com/xtaran/run-parts version: 0.06 x_test_requires: File::Slurp: 9999.06 Test::Differences: 0 Test::More: 0 Test::NoWarnings: 0 Run-Parts-0.06/META.json000444001750001750 341712173277225 13565 0ustar00abetar000000000000{ "abstract" : "Offers functionality of Debian's run-parts tool in Perl.", "author" : [ "Axel Beckert " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4005, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Run-Parts", "prereqs" : { "configure" : { "requires" : { "Modern::Perl" : "0", "Module::Build" : "0.4004" } }, "runtime" : { "requires" : { "Exporter::Easy" : "0", "File::Slurp" : "0", "Scalar::Util" : "0", "Taint::Util" : "0", "autodie" : "0", "perl" : "v5.10.0" } } }, "provides" : { "Run::Parts" : { "file" : "lib/Run/Parts.pm", "version" : "0.06" }, "Run::Parts::Common" : { "file" : "lib/Run/Parts/Common.pm", "version" : "0.01" }, "Run::Parts::Debian" : { "file" : "lib/Run/Parts/Debian.pm", "version" : "0.01" }, "Run::Parts::Perl" : { "file" : "lib/Run/Parts/Perl.pm", "version" : "0.02" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Dist/Display.html?Name=Run-Parts" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "https://github.com/xtaran/run-parts" } }, "version" : "0.06", "x_test_requires" : { "File::Slurp" : "9999.06", "Test::Differences" : "0", "Test::More" : "0", "Test::NoWarnings" : "0" } } Run-Parts-0.06/Changes000444001750001750 246412173277225 13440 0ustar00abetar000000000000Revision history for Run-Parts 0.06 Mon Jul 22 20:47:16 CEST 2013 Bump Module::Build requirement to 0.4004 for test_requires. Remove all environment variables listed as relevant for taint mode in perlsec(1) from the affected tests. 0.05 Sun 21 Jul 17:56:01 CEST 2013 Fix test skipping numbers in t/basic-functionality.t. Documentation deduplication. 0.04 Wed Jul 10 19:55:57 CEST 2013 New method concat. New helper module Run::Parts::Common. Run::Parts::Perl now works properly on DOS-ish platforms Some refactoring which pulls in new dependencies. 0.03 Fri Jul 5 21:01:59 CEST 2013 Run::Parts has been split up into frontend and backend modules. A pure Perl backend module has been added. Run::Parts now can either choose the appropriate backend itself or use a given backend. 0.02 Sat 8 Jun 20:04:53 CEST 2013 Skip functionality tests if /bin/run-parts is not there or not executable. Add POD encoding to make Test::Pod happy State in Build.PL that the test suite needs Test::Differences and that Run::Parts itself needs Perl >= 5.10. Disable Makefile.PL compatibility. 0.01 Fri 7 Jun 20:26:57 CEST 2013 Initial release. More or less a proof of concept. Run-Parts-0.06/MANIFEST000444001750001750 116712173277225 13275 0ustar00abetar000000000000Build.PL Changes MANIFEST This list of files META.json META.yml README lib/Run/Parts.pm lib/Run/Parts/Common.pm lib/Run/Parts/Debian.pm lib/Run/Parts/Perl.pm t/00-load.t t/basic-dummy/bar t/basic-dummy/fnord~ t/basic-dummy/foo t/basic-dummy/script t/basic-dummy/script2 t/basic-dummy/script~ t/basic-functionality.t t/boilerplate.t t/compare-functionality.t t/manifest.t t/pod-coverage.t t/pod.t t/win-dummy/bar.com t/win-dummy/bla.bat t/win-dummy/foo.exe t/win-dummy/pfff.scr t/win-dummy/puff.pif t/win-dummy/unix.sh t/win-exec-dummy/bla.bat t/win-exec-dummy/fnord.sh t/win-exec-dummy/foo.bat t/win-exec.t t/win-functionality.t Run-Parts-0.06/README000444001750001750 656212173277225 13030 0ustar00abetar000000000000NAME Run::Parts - Offers functionality of Debian's run-parts tool in Perl. VERSION Version 0.06 SYNOPSIS Run::Parts offers functionality of Debian's run-parts tool in Perl. run-parts runs all the executable files named within constraints described in run-parts(8) and Run::Parts::Perl, found in the given directory. Other files and directories are silently ignored. Additionally it can just print the names of the all matching files (not limited to executables, but ignores blacklisted files like e.g. backup files), but don't actually run them. This is useful when functionality or configuration is split over multiple files in one directory. A typical convention is that the directory name ends in ".d". Common examples for such splittet configuration directories: /etc/cron.d/ /etc/apt/apt.conf.d/ /etc/apt/sources.list.d/, /etc/aptitude-robot/pkglist.d/ /etc/logrotate.d/ /etc/rsyslog.d/ Perhaps a little code snippet. use Run::Parts; my $rp = Run::Parts->new('directory'); # chooses backend automatically my $rpp = Run::Parts->new('directory', 'perl'); # pure perl backend my $rpd = Run::Parts->new('directory', 'debian'); # uses /bin/run-parts my @file_list = $rp->list; my @executables_list = $rpp->test; my $commands_output = $rpd->run; ... INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install BACKENDS Run::Parts contains two backend implementation. Run::Parts::Debian actually uses /bin/run-parts and Run::Parts::Perl is a pure Perl implementation of a basic set of run-parts' functionality. Run::Parts::Debian may or may not work with RedHat's simplified shell-script based reimplementation of Debian's run-parts. By default Run::Parts uses Run::Parts::Debian if /bin/run-parts exists, Run::Parts::Perl otherwise. But you can also choose any of the backends explicitly. SEE ALSO run-parts(8), Run::Parts::Debian, Run::Parts::Perl AUTHOR Axel Beckert, `' BUGS Please report any bugs or feature requests to `bug-run-parts at rt.cpan.org', or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Run-Parts. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. CODE You can find a git repository of Run::Parts' code at https://github.com/xtaran/run-parts. SUPPORT You can find documentation for this module with the perldoc command. perldoc Run::Parts You can also look for information at: * RT: CPAN's request tracker (report bugs here) http://rt.cpan.org/NoAuth/Bugs.html?Dist=Run-Parts * AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Run-Parts * CPAN Ratings http://cpanratings.perl.org/d/Run-Parts * Search CPAN http://search.cpan.org/dist/Run-Parts/ LICENSE AND COPYRIGHT Copyright 2013 Axel Beckert. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. Run-Parts-0.06/lib000755001750001750 012173277225 12550 5ustar00abetar000000000000Run-Parts-0.06/lib/Run000755001750001750 012173277225 13314 5ustar00abetar000000000000Run-Parts-0.06/lib/Run/Parts.pm000444001750001750 1311012173277225 15114 0ustar00abetar000000000000package Run::Parts; use Modern::Perl; =encoding utf8 =head1 NAME Run::Parts - Offers functionality of Debian's run-parts tool in Perl. =head1 VERSION Version 0.06 =cut our $VERSION = '0.06'; use File::Slurp; use Run::Parts::Common; =head1 SYNOPSIS Run::Parts offers functionality of Debian's run-parts tool in Perl. run-parts runs all the executable files named within constraints described in L and L, found in the given directory. Other files and directories are silently ignored. Additionally it can just print the names of the all matching files (not limited to executables, but ignores blacklisted files like e.g. backup files), but don't actually run them. This is useful when functionality or configuration is split over multiple files in one directory. A typical convention is that the directory name ends in ".d". Common examples for such splittet configuration directories: /etc/cron.d/ /etc/apt/apt.conf.d/ /etc/apt/sources.list.d/, /etc/aptitude-robot/pkglist.d/ /etc/logrotate.d/ /etc/rsyslog.d/ Perhaps a little code snippet. use Run::Parts; my $rp = Run::Parts->new('directory'); # chooses backend automatically my $rpp = Run::Parts->new('directory', 'perl'); # pure perl backend my $rpd = Run::Parts->new('directory', 'debian'); # uses /bin/run-parts my @file_list = $rp->list; my @executables_list = $rpp->test; my $commands_output = $rpd->run; ... =begin readme =head1 INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install =end readme =head1 BACKENDS Run::Parts contains two backend implementation. Run::Parts::Debian actually uses /bin/run-parts and Run::Parts::Perl is a pure Perl implementation of a basic set of run-parts' functionality. Run::Parts::Debian may or may not work with RedHat's simplified shell-script based reimplementation of Debian's run-parts. By default Run::Parts uses Run::Parts::Debian if /bin/run-parts exists, Run::Parts::Perl otherwise. But you can also choose any of the backends explicitly. =for readme stop =head1 METHODS =head2 new (Constructor) Creates a new Run::Parts object. Takes one parameter, the directory on which run-parts should work. =cut sub new { my $self = {}; bless($self, shift); $self->{dir} = shift; my $backend = shift; if (defined $backend) { if (ref $backend) { $self->{backend} = $backend->new($self->{dir}); } elsif ($backend eq 'debian' or $backend eq 'run-parts') { use Run::Parts::Debian; $self->{backend} = Run::Parts::Debian->new($self->{dir}); } elsif ($backend eq 'perl' or $backend eq 'module') { use Run::Parts::Perl; $self->{backend} = Run::Parts::Perl->new($self->{dir}); } else { warn "Unknown backend $backend in use"; require $backend; $self->{backend} = $backend->new($self->{dir}); } } else { if (-x '/bin/run-parts') { $self->{backend} = Run::Parts::Debian->new($self->{dir}); } else { $self->{backend} = Run::Parts::Perl->new($self->{dir}); } } return $self; } =head2 run_parts_command Returns the run-parts to run with the given command parameter =cut sub run_parts_command { my $self = shift; return $self->{backend}->run_parts_command(@_); } =head2 list Lists all relevant files in the given directory. Equivalent to "run-parts --list". =cut sub list { my $self = shift; return $self->run_parts_command('list'); } =head2 test Lists all relevant executables in the given directory. Equivalent to "run-parts --test". =cut sub test { my $self = shift; return $self->run_parts_command('test'); } =head2 run Runs all relevant executables in the given directory. Equivalent to "run-parts". =cut sub run { my $self = shift; return $self->run_parts_command(); } =head2 concat Returns the concatenated contents of all relevant files in the given directory. Equivalent to "cat `run-parts --list`". =cut sub concat { my $self = shift; return lines(map { read_file($_, { chomp => 1 }) } $self->list()); } =for readme continue =head1 SEE ALSO run-parts(8), Run::Parts::Debian, Run::Parts::Perl =head1 AUTHOR Axel Beckert, C<< >> =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 CODE You can find a git repository of Run::Parts' code at L. =head1 SUPPORT =begin readme You can find documentation for this module with the perldoc command. perldoc Run::Parts You can also look for information at: =end readme =over 4 =item * RT: CPAN's request tracker (report bugs here) L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 LICENSE AND COPYRIGHT Copyright 2013 Axel Beckert. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See L for more information. =cut 1; # End of Run::Parts Run-Parts-0.06/lib/Run/Parts000755001750001750 012173277225 14405 5ustar00abetar000000000000Run-Parts-0.06/lib/Run/Parts/Debian.pm000444001750001750 442512173277225 16267 0ustar00abetar000000000000package Run::Parts::Debian; use Modern::Perl; use Run::Parts::Common; =encoding utf8 =head1 NAME Run::Parts::Debian - Perl interface to Debian's run-parts tool =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS Perl interface to Debian's run-parts tool. run-parts runs all the executable files named within constraints described below, found in the given directory. Other files and directories are silently ignored. Additionally it can just print the names of the all matching files (not limited to executables, but ignores blacklisted files like e.g. backup files), but don't actually run them. This is useful when functionality or configuration is split over multiple files in one directory. This module is not thought to be used directly and its interface may change. See Run::Parts for a stable user interface. =head1 METHODS =head2 new (Constructor) Creates a new Run::Parts object. Takes one parameter, the directory on which run-parts should work. =cut sub new { my $self = {}; bless($self, shift); $self->{dir} = shift; return $self; } =head2 run_parts_command Returns the run-parts to run with the given command parameter =cut sub run_parts_command { my $self = shift; my $rp_cmd = shift; my $command = "/bin/run-parts " . ((defined($rp_cmd) and $rp_cmd ne '') ? "'--$rp_cmd'" : '') . " '".$self->{dir}."'"; return chomped_lines(`$command`); } =head1 SEE ALSO Run::Parts, run-parts(8) =head1 AUTHOR Axel Beckert, C<< >> =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 SUPPORT You can find documentation for this module with the perldoc command. perldoc Run::Parts::Debian =head1 LICENSE AND COPYRIGHT Copyright 2013 Axel Beckert. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See L for more information. =cut 1; # End of Run::Parts Run-Parts-0.06/lib/Run/Parts/Common.pm000444001750001750 357112173277225 16336 0ustar00abetar000000000000package Run::Parts::Common; use Modern::Perl; use Exporter::Easy ( EXPORT => [qw[lines chomped_lines]] ); use Scalar::Util qw(blessed); =encoding utf8 =head1 NAME Run::Parts::Common - Common helpers for Run::Parts and its backends =head1 VERSION Version 0.01 =cut our $VERSION = '0.01'; =head1 SYNOPSIS Exports helper functions used by Run::Parts as well as its backends. =head1 EXPORTED FUNCTIONS =head2 lines Gets an array of strings as parameter. In scalar context returns a string with all lines concatenated. In array context it passes through the array. =cut sub lines { # Sanity check die "lines is no method" if blessed $_[0]; return wantarray ? @_ : join("\n", @_)."\n"; } =head2 chomped_lines Gets an array of strings as parameter and calls chomp() on it. In scalar context returns a string with all lines concatenated. In array context it passes through the array. =cut sub chomped_lines { # Sanity check die "chomped_lines is no method" if blessed $_[0]; chomp(@_); return lines(@_); } =head1 SEE ALSO Run::Parts =head1 AUTHOR Axel Beckert, C<< >> =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 SUPPORT You can find documentation for this module with the perldoc command. perldoc Run::Parts::Common =head1 LICENSE AND COPYRIGHT Copyright 2013 Axel Beckert. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See L for more information. =cut 1; # End of Run::Parts::Common Run-Parts-0.06/lib/Run/Parts/Perl.pm000444001750001750 1027412173277225 16026 0ustar00abetar000000000000package Run::Parts::Perl; use Modern::Perl; use autodie; use Taint::Util; use Run::Parts::Common; =encoding utf8 =head1 NAME Run::Parts::Perl - Pure Perl implementation of Debian's run-parts tool =head1 VERSION Version 0.02 =cut our $VERSION = '0.02'; =head1 SYNOPSIS Pure Perl reimplementation of basic functionality of Debian's run-parts tool. run-parts runs all the executable files named within constraints described below, found in the given directory. Other files and directories are silently ignored. Additionally it can just print the names of the all matching files (not limited to executables, but ignores blacklisted files like e.g. backup files), but don't actually run them. This is useful when functionality or configuration is split over multiple files in one directory. This module is not thought to be used directly and its interface may change. See Run::Parts for a stable user interface. =head1 FILE NAME CONSTRAINTS On unix-ish operating systems, the file name (but not the path) must match ^[-A-Za-z0-9_]+$, i.e. may not contain a dot. On dos-ish operating systems, the file name without suffix must match ^[-A-Za-z0-9_]+$, i.e. may not contain a dot. The suffix may contain alphanumeric characters and is not mandatory. The full regular expression the file name including the suffix must match is ^[-A-Za-z0-9_]+(\.[A-Za-z0-9]+)?$. Debian's run-parts tool also offers to use alternative regular expressions as file name constraints. This is not yet implemented in Run::Parts::Perl. =cut # On DOS and Windows, run-parts' regular expressions are not really # applicable. Allow an arbitrary alphanumerical suffix there. my $win_suffix = dosish() ? qr/\.[a-z0-9]+/i : qr''; my $file_re = qr/^[-A-Za-z0-9_]+($win_suffix)?$/; =head1 METHODS =head2 new (Constructor) Creates a new Run::Parts object. Takes one parameter, the directory on which run-parts should work. =cut sub new { my $self = {}; bless($self, shift); $self->{dir} = shift; return $self; } =head2 run_parts_command Executes the given action with the given parameters =cut sub run_parts_command { my $self = shift; my $rp_cmd = shift // 'run'; my @result = $self->$rp_cmd(@_); return lines(@result); } =head2 list Lists all relevant files in the given directory. Equivalent to "run-parts --list". Returns an array. =cut sub list { my $self = shift; my $dir = $self->{dir}; opendir(my $dh, $dir); my @list = sort map { if (defined($dir) and $dir ne '') { "$dir/$_"; } else { $_; } } grep { /$file_re/ } readdir($dh); } =head2 test Lists all relevant executables in the given directory. Equivalent to "run-parts --tests". Returns an array. =cut sub test { my $self = shift; my $dir = $self->{dir}; return grep { -x } $self->list($dir); } =head2 run Executes all relevant executables in the given directory. Equivalent to "run-parts --tests". Returns an array. =cut sub run { my $self = shift; my $dir = $self->{dir}; return map { untaint($_); s(/)(\\)g if dosish(); my $output = `$_`; chomp($output); $output; } $self->test($dir); } =head1 INTERNAL FUNCTIONS =head2 dosish Returns true if ran on a dos-ish platform, i.e. MS-DOS, Windows or OS/2. =cut sub dosish { return $^O =~ /^(dos|os2|MSWin32)$/; } =head1 SEE ALSO Run::Parts, run-parts(8) =head1 AUTHOR Axel Beckert, C<< >> =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 SUPPORT You can find documentation for this module with the perldoc command. perldoc Run::Parts::Perl =head1 LICENSE AND COPYRIGHT Copyright 2013 Axel Beckert. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See L for more information. =cut 1; # End of Run::Parts Run-Parts-0.06/t000755001750001750 012173277225 12245 5ustar00abetar000000000000Run-Parts-0.06/t/manifest.t000444001750001750 44512173277225 14360 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } my $min_tcm = 0.9; eval "use Test::CheckManifest $min_tcm"; plan skip_all => "Test::CheckManifest $min_tcm required" if $@; ok_manifest(); Run-Parts-0.06/t/pod-coverage.t000444001750001750 105112173277225 15137 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); Run-Parts-0.06/t/win-exec.t000444001750001750 144512173277225 14312 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; use Test::Differences; if ($^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32' ) { plan skip_all => 'Tests irrelevant on non-dos-ish systems'; } else { plan tests => 4; } delete @ENV{qw{PATH ENV IFS CDPATH BASH_ENV}}; my $d = 't\win-exec-dummy'; my @exe_files = qw[bla.bat foo.bat]; use Run::Parts; # Testing the perl backend run_test_on_rp($d, 'perl'); # Testing the automatically chosen backend run_test_on_rp($d); sub run_test_on_rp { my ($d, $desc) = @_; my $rp = Run::Parts->new($d, $desc); $desc ||= 'default'; ok($rp, 'Run::Parts->new($desc) returned non-nil'); # Executes executable files eq_or_diff(''.$rp->run, "foobla\nfoofoo\n", "Returns output of ran executables ($desc)"); } Run-Parts-0.06/t/00-load.t000444001750001750 31512173277225 13702 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More tests => 2; use Test::NoWarnings; BEGIN { use_ok( 'Run::Parts' ) || print "Bail out!\n"; } diag( "Testing Run::Parts $Run::Parts::VERSION, Perl $], $^X" ); Run-Parts-0.06/t/boilerplate.t000444001750001750 214012173277225 15066 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; sub not_in_file_ok { my ($filename, %regex) = @_; open( my $fh, '<', $filename ) or die "couldn't open $filename for reading: $!"; my %violated; while (my $line = <$fh>) { while (my ($desc, $regex) = each %regex) { if ($line =~ $regex) { push @{$violated{$desc}||=[]}, $.; } } } if (%violated) { fail("$filename contains boilerplate text"); diag "$_ appears on lines @{$violated{$_}}" for keys %violated; } else { pass("$filename contains no boilerplate text"); } } sub module_boilerplate_ok { my ($module) = @_; not_in_file_ok($module => 'the great new $MODULENAME' => qr/ - The great new /, 'boilerplate description' => qr/Quick summary of what the module/, 'stub function definition' => qr/function[12]/, ); } not_in_file_ok(Changes => "placeholder date/time" => qr(Date/time) ); foreach my $pm (, ) { module_boilerplate_ok($pm); } done_testing(); Run-Parts-0.06/t/pod.t000444001750001750 33712173277225 13334 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Run-Parts-0.06/t/basic-functionality.t000444001750001750 421512173277225 16540 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More tests => 25; use Test::NoWarnings; use Test::Differences; use File::Slurp 9999.06; delete @ENV{qw{PATH ENV IFS CDPATH BASH_ENV}}; my $runpartsbin = '/bin/run-parts'; my $d = 't/basic-dummy'; my $expected_output = read_file(\*DATA); my @expected_output = read_file(\*DATA, { chomp => 1 }); use Run::Parts; # Testing the Debian backend SKIP: { skip("$runpartsbin not found or not executable", 8) unless -x $runpartsbin; run_test_on_rp($d, 'debian') } # Testing the perl backend run_test_on_rp($d, 'perl'); # Testing the automatically chosen backend run_test_on_rp($d); sub run_test_on_rp { my ($d, $desc) = @_; my $rp = Run::Parts->new($d, $desc); $desc ||= 'default'; ok($rp, 'Run::Parts->new($desc) returned non-nil'); # List files eq_or_diff([$rp->list], [map { "$d/$_" } qw[bar foo script script2]], "Returns list of files in array context ($desc)"); eq_or_diff(''.$rp->list, "$d/bar\n$d/foo\n$d/script\n$d/script2\n", "Returns list of files in string context ($desc)"); # Concatenate files eq_or_diff([$rp->concat], \@expected_output, "Returns concatenated contents of all files in array context ($desc)"); eq_or_diff(''.$rp->concat, $expected_output, "Returns concatenated contents of all files in string context ($desc)"); SKIP: { skip("Listing unix executables on DOS or Windows does not work", 3) if ($^O eq 'dos' or $^O eq 'os2' or $^O eq 'MSWin32'); # List executable files eq_or_diff([$rp->test], [map { "$d/$_" } qw[script script2]], "Returns list of executables in array context ($desc)"); eq_or_diff(''.$rp->test, "$d/script\n$d/script2\n", "Returns list of executables in string context ($desc)"); # Executes executable files eq_or_diff(''.$rp->run, "Works\nWorks, too!\n", "Returns output of ran executables ($desc)"); } } __DATA__ Bar Foo #!/usr/bin/perl print "Works\n"; #!/usr/bin/perl print "Works, too!\n"; Run-Parts-0.06/t/compare-functionality.t000444001750001750 220012173277225 17075 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; use Test::Differences; delete @ENV{qw{PATH ENV IFS CDPATH BASH_ENV}}; my $runpartsbin = '/bin/run-parts'; unless (-x $runpartsbin) { plan skip_all => "$runpartsbin not found or not executable"; exit 0; } use Run::Parts; my $d = 't/basic-dummy'; my $rpd = Run::Parts->new($d, 'debian'); my $rpp = Run::Parts->new($d, 'perl'); ok($rpd, 'Run::Parts->new(debian) returned non-nil'); ok($rpp, 'Run::Parts->new(perl) returned non-nil'); # List files eq_or_diff([$rpd->list], [$rpp->list], "Both return same list of files in array context"); eq_or_diff(''.$rpd->list, ''.$rpp->list, "Both return same list of files in string context"); # List executable files eq_or_diff([$rpd->test], [$rpp->test], "Both return same list of executables in array context"); eq_or_diff(''.$rpd->test, ''.$rpp->test, "Both return same list of executables in string context"); # Executes executable files eq_or_diff(''.$rpd->run, ''.$rpp->run, "Both return same output of ran executables"); done_testing(); Run-Parts-0.06/t/win-functionality.t000444001750001750 250612173277225 16255 0ustar00abetar000000000000#!perl -T use Modern::Perl; use Test::More; use Test::Differences; if ($^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32' ) { plan skip_all => 'Tests irrelevant on non-dos-ish systems'; } else { plan tests => 10; } delete @ENV{qw{PATH ENV IFS CDPATH BASH_ENV}}; my $d = 't/win-dummy'; my @files = qw[bar.com bla.bat foo.exe pfff.scr puff.pif unix.sh]; my @exe_files = qw[bar.com bla.bat foo.exe]; use Run::Parts; # Testing the perl backend run_test_on_rp($d, 'perl'); # Testing the automatically chosen backend run_test_on_rp($d); sub run_test_on_rp { my ($d, $desc) = @_; my $rp = Run::Parts->new($d, $desc); $desc ||= 'default'; ok($rp, 'Run::Parts->new($desc) returned non-nil'); # List files eq_or_diff([$rp->list], [map { "$d/$_" } @files], "Returns list of files in array context ($desc)"); eq_or_diff(''.$rp->list, join('', map { "$d/$_\n" } @files), "Returns list of files in string context ($desc)"); # List executable files eq_or_diff([$rp->test], [map { "$d/$_" } @exe_files], "Returns list of executables in array context ($desc)"); eq_or_diff(''.$rp->test, join('', map { "$d/$_\n" } @exe_files), "Returns list of executables in string context ($desc)"); } Run-Parts-0.06/t/win-dummy000755001750001750 012173277225 14173 5ustar00abetar000000000000Run-Parts-0.06/t/win-dummy/puff.pif000444001750001750 012173277225 15676 0ustar00abetar000000000000Run-Parts-0.06/t/win-dummy/foo.exe000444001750001750 012173277225 15524 0ustar00abetar000000000000Run-Parts-0.06/t/win-dummy/bar.com000444001750001750 012173277225 15502 0ustar00abetar000000000000Run-Parts-0.06/t/win-dummy/unix.sh000555001750001750 2712173277225 15611 0ustar00abetar000000000000#!/bin/sh echo foobar Run-Parts-0.06/t/win-dummy/bla.bat000444001750001750 012173277225 15464 0ustar00abetar000000000000Run-Parts-0.06/t/win-dummy/pfff.scr000444001750001750 012173277225 15670 0ustar00abetar000000000000Run-Parts-0.06/t/basic-dummy000755001750001750 012173277225 14457 5ustar00abetar000000000000Run-Parts-0.06/t/basic-dummy/script2000555001750001750 5012173277225 16063 0ustar00abetar000000000000#!/usr/bin/perl print "Works, too!\n"; Run-Parts-0.06/t/basic-dummy/foo000444001750001750 412173277225 15234 0ustar00abetar000000000000Foo Run-Parts-0.06/t/basic-dummy/bar000444001750001750 412173277225 15215 0ustar00abetar000000000000Bar Run-Parts-0.06/t/basic-dummy/script000555001750001750 4212173277225 16002 0ustar00abetar000000000000#!/usr/bin/perl print "Works\n"; Run-Parts-0.06/t/basic-dummy/script~000555001750001750 5312173277225 16202 0ustar00abetar000000000000#!perl print "Should not be executed!\n"; Run-Parts-0.06/t/basic-dummy/fnord~000444001750001750 612173277225 15761 0ustar00abetar000000000000Fnord Run-Parts-0.06/t/win-exec-dummy000755001750001750 012173277225 15115 5ustar00abetar000000000000Run-Parts-0.06/t/win-exec-dummy/fnord.sh000444001750001750 3012173277225 16647 0ustar00abetar000000000000#!/bin/sh echo foofnord Run-Parts-0.06/t/win-exec-dummy/foo.bat000444001750001750 1512173277225 16461 0ustar00abetar000000000000@echo foofoo Run-Parts-0.06/t/win-exec-dummy/bla.bat000444001750001750 1512173277225 16434 0ustar00abetar000000000000@echo foobla