Test-Requires-Git-1.008/0000755000175000017500000000000013057610703013427 5ustar bookbookTest-Requires-Git-1.008/Changes0000644000175000017500000000304613057610703014725 0ustar bookbookRevision history for Test-Requires-Git 1.008 2017-03-07 BOOK - Make sure the test suite works as expected when @INC does not contain '.' (closes RT #120537, thanks to KENTNL for the report) 1.007 2016-10-02 BOOK - Add an extra diagnostic reporting the git version used for testing (with a scheme to limit the number of times it's output, so as not to pollute test output too much) 1.006 2016-05-08 BOOK - Documentation improvements - Code improvements - Add tests for git versions with comments 1.005 2016-04-02 BOOK - Add support for a lone version argument (with implicit 'version_ge') - Minor documentation updates - Added a test using a git.git tag name 1.004 2016-02-29 BOOK - Use Git::Version::Compare to compare versions - Tests now cover 100% of the code - Rewrite the Changes file according to CPAN::Changes::Spec 1.003 2015-05-31 BOOK - A bare `use Test::Requires::Git` now checks if git is available - The -nocheck option skips that check when there are not other arguments to `use Test::Requires::Git` - The 'git' option makes it possible to set the path to git 1.002 2015-05-25 BOOK - Added supports for many aliases - Improved support for skipping "all remaining tests" - Made the test suite more reliable by not mangling the system (thanks to Christian Walde (MITHALDU) for the idea) 1.001 2015-05-12 BOOK - A bare test_requires_git will skip if git is not available - Improved test coverage 1.000 2015-05-10 BOOK - First published version Test-Requires-Git-1.008/LICENSE0000644000175000017500000004371313057610703014444 0ustar bookbookThis software is copyright (c) 2017 by Philippe Bruhat (BooK). This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2017 by Philippe Bruhat (BooK). This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2017 by Philippe Bruhat (BooK). This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Test-Requires-Git-1.008/t/0000755000175000017500000000000013057610703013672 5ustar bookbookTest-Requires-Git-1.008/t/skip_remaining.t0000644000175000017500000000037113057610703017057 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.6.5'; use Test::Requires::Git; plan tests => 3; pass('initial pass'); test_requires_git version_gt => '1.7.0'; fail( 'cannot happen' ); fail( 'cannot happen either' ); Test-Requires-Git-1.008/t/skip_one.t0000644000175000017500000001114613057610703015671 0ustar bookbookuse strict; use warnings; use Test::More; use List::Util qw( sum ); use Scalar::Util qw( looks_like_number ); use lib 't/lib'; use FakeGit; use Test::Requires::Git -nocheck; # pick a random git version to work with my @version = ( [ 1, 2 ]->[ rand 2 ], [ 0 .. 12 ]->[ rand 13 ], [ 0 .. 12 ]->[ rand 13 ], [ 0 .. 12 ]->[ rand 13 ], ); my $version = join '.', @version; diag "fake version: $version"; fake_git($version); # generate other versions based on the current one my ( @lesser, @greater ); for ( 0 .. $#version ) { local $" = '.'; my @v = @version; next if !looks_like_number( $v[$_] ); $v[$_]++; push @greater, "@v"; next if 0 > ( $v[$_] -= 2 ); push @lesser, "@v"; } # an rc is always lesser push @lesser, join '.', @version[ 0 .. 2 ], 'rc1'; # build up test data my ( @pass, @skip ); for my $t ( # [ op => [ pass ], [ skip ] ] [ version_eq => [$version], [ @lesser, @greater ] ], #[ version_ne => [ @lesser, @greater ], [$version] ], [ version_lt => [@greater], [ @lesser, $version ] ], [ version_gt => [@lesser], [ $version, @greater ] ], #[ version_le => [ $version, @greater ], [@lesser] ], #[ version_ge => [ @lesser, $version ], [@greater] ], ) { my ( $op, $pass, $skip ) = @$t; push @pass, map [ $version, $op, $_ ], @$pass; push @skip, map [ $version, $op, $_ ], @$skip; } # more complex cases push @pass, [ '1.7.2.rc0.13.gc9eaaa', 'version_eq', '1.7.2.rc0.13.gc9eaaa' ], [ '1.7.2.rc0.13.gc9eaaa', 'version_ge', '1.7.2.rc0.13.gc9eaaa' ], [ '1.7.2.rc0.13.gc9eaaa', 'version_le', '1.7.2.rc0.13.gc9eaaa' ], [ '1.7.1', 'version_gt', '1.7.1.rc0' ], [ '1.7.1.rc1', 'version_gt', '1.7.1.rc0' ], [ '1.3.2', 'version_gt', '0.99' ], [ '1.7.2.rc0.13.gc9eaaa', 'version_gt', '1.7.0.4' ], [ '1.7.1.rc2', 'version_gt', '1.7.1.rc1' ], [ '1.7.2.rc0.1.g078e', 'version_gt', '1.7.2.rc0' ], [ '1.7.2.rc0.10.g1ba5c', 'version_gt', '1.7.2.rc0.1.g078e' ], [ '1.7.1.1', 'version_gt', '1.7.1.1.gc8c07' ], [ '1.7.1.1', 'version_gt', '1.7.1.1.g5f35a' ], [ '1.0.0b', 'version_gt', '1.0.0a' ], [ '1.0.3', 'version_gt', '1.0.0a' ], [ '1.7.0.4', 'version_ne', '1.7.2.rc0.13.gc9eaaa' ], [ '1.7.1.rc1', 'version_ne', '1.7.1.rc2' ], [ '1.0.0a', 'version_ne', '1.0.0' ], [ '1.4.0.rc1', 'version_le', '1.4.1' ], [ '1.0.0a', 'version_gt', '1.0.0' ], [ '1.0.0a', 'version_lt', '1.0.3' ], [ '1.0.0a', 'version_eq', '1.0.1' ], [ '1.0.0b', 'version_eq', '1.0.2' ], [ '1.7.1.236.g81fa0', 'version_gt', '1.7.1' ], [ '1.7.1.236.g81fa0', 'version_lt', '1.7.1.1' ], [ '1.7.1.211.g54fcb21', 'version_gt', '1.7.1.209.gd60ad81' ], [ '1.7.1.211.g54fcb21', 'version_ge', '1.7.1.209.gd60ad81' ], [ '1.7.1.209.gd60ad81', 'version_lt', '1.7.1.1.1.g66bd8ab' ], [ '1.7.0.2.msysgit.0', 'version_gt', '1.6.6' ], [ '1.6.5.4.52.g952dfc6', 'version_gt', '1.6.5' ], [ '2.6.4 (Apple Git-63)', 'version_gt', '1.6.5' ], ; # operator reversal: $a op $b <=> $b rop $a my %reverse = ( version_eq => 'version_eq', #version_ne => 'version_ne', #version_ge => 'version_le', version_gt => 'version_lt', #version_le => 'version_ge', version_lt => 'version_gt', ); push @pass, map [ $_->[2], $reverse{ $_->[1] }, $_->[0] ], grep exists $reverse{ $_->[1] }, @pass; push @skip, map [ $_->[2], $reverse{ $_->[1] }, $_->[0] ], grep exists $reverse{ $_->[1] }, @skip; # operator negation my %negate = ( version_ne => 'version_eq', version_eq => 'version_ne', version_ge => 'version_lt', version_gt => 'version_le', version_le => 'version_gt', version_lt => 'version_ge', ); push @pass, map [ $_->[0], $negate{ $_->[1] }, $_->[2] ], @skip; push @skip, map [ $_->[0], $negate{ $_->[1] }, $_->[2] ], @pass; # sort test cases by v1 @pass = sort { $a->[0] cmp $b->[0] } @pass; @skip = sort { $a->[0] cmp $b->[0] } @skip; plan tests => 1 + 2 * @pass + @skip; pass('initial pass'); # run all tests in a SKIP block # PASS my $prev = ''; for my $t (@pass) { my ( $v1, $op, $v2 ) = @$t; fake_git($v1) if $v1 ne $prev; my $passed = 0; SKIP: { test_requires_git $op => $v2, skip => 1; pass("$v1 $op $v2"); $passed = 1; } ok( $passed, "$v1 $op $v2" ); $prev = $v1; } # SKIP $prev = ''; for my $t (@skip) { my ( $v1, $op, $v2 ) = @$t; fake_git($v1) if $v1 ne $prev; SKIP: { test_requires_git $op => $v2, skip => 1; fail("$v1 $op $v2"); } $prev = $v1; } Test-Requires-Git-1.008/t/import.t0000644000175000017500000000036113057610703015371 0ustar bookbookuse strict; use warnings; use Test::More; plan tests => 2; my $bad_use = 'use Test::Requires::Git -bonk;'; ok( !eval $bad_use, $bad_use ); like( $@, qr/^-bonk does not look like a Git version /, '... expected error message' ); Test-Requires-Git-1.008/t/odd_args.t0000644000175000017500000000115013057610703015636 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.2.3'; use Test::Requires::Git; # the check always passes, because of t::FakeGit plan tests => 6; # any skip will 'skip all', # this line ensures there will be a 'bad plan' failure in that case pass('initial pass'); test_requires_git '1.2.3'; pass("passed the run-time check '1.2.3'"); test_requires_git '1.2.0'; pass("passed the run-time check '1.2.0'"); SKIP: { test_requires_git '1.6.0', skip => 1; fail('cannot happen'); } SKIP: { test_requires_git skip => 1, '1.6.0'; fail('cannot happen'); } pass('all passed'); Test-Requires-Git-1.008/t/author-pod-coverage.t0000644000175000017500000000056513057610703017740 0ustar bookbook#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Test-Requires-Git-1.008/t/00-report-prereqs.t0000644000175000017500000001271413057610703017273 0ustar bookbook#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.025 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do 't/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: Test-Requires-Git-1.008/t/release-distmeta.t0000644000175000017500000000043013057610703017304 0ustar bookbook#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); Test-Requires-Git-1.008/t/00-report-prereqs.dd0000644000175000017500000000322613057610703017415 0ustar bookbookdo { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' } }, 'develop' => { 'requires' => { 'Pod::Coverage::TrustPod' => '0', 'Test::CPAN::Meta' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'Git::Version::Compare' => '1.003', 'Test::Builder::Module' => '0', 'base' => '0', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'List::Util' => '0', 'Scalar::Util' => '0', 'Test::More' => '0', 'lib' => '0' } } }; $x; }Test-Requires-Git-1.008/t/skip_git.t0000644000175000017500000000037213057610703015672 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit 'broken'; use Test::Requires::Git -nocheck; plan tests => 3; pass('initial pass'); SKIP: { test_requires_git skip => 1; fail('cannot happen'); } pass 'skipped one'; Test-Requires-Git-1.008/t/other_git.t0000644000175000017500000000032413057610703016042 0ustar bookbookuse strict; use warnings; use Test::More; use Test::Requires::Git -nocheck; plan tests => 2; # run some tests before pass('initial test'); test_requires_git git => '/zlonk/bam/kapow'; fail('cannot happen'); Test-Requires-Git-1.008/t/has_plan.t0000644000175000017500000000042013057610703015640 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.2.3'; use Test::Requires::Git; plan tests => 3; # ok test_requires_git version_gt => '1.2.0', version_lt => '1.3.0'; # skip test_requires_git version_lt => '1.2.1'; fail('cannot happen'); Test-Requires-Git-1.008/t/skip_all.t0000644000175000017500000000044213057610703015655 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.2.3'; use Test::Requires::Git; # run some tests before pass('initial test'); # ok test_requires_git version_gt => 'v1.2.0'; # skip test_requires_git version_lt => '1.2.1'; fail('cannot happen'); done_testing; Test-Requires-Git-1.008/t/lib/0000755000175000017500000000000013057610703014440 5ustar bookbookTest-Requires-Git-1.008/t/lib/FakeGit.pm0000644000175000017500000000126413057610703016313 0ustar bookbookpackage FakeGit; use strict; use warnings; # Test::Requires::Git must have been loaded already BEGIN { require Test::Requires::Git if !$INC{'Test/Requires/Git.pm'}; } # import to build one fake git at compile time sub import { my $package = shift; my $caller = caller(0); no strict 'refs'; *{"$caller\::fake_git"} = \&fake_git; fake_git(shift) if @_; } # helper routine to build a fake fit binary sub fake_git { my ($version) = @_; $version =~ s/^(?=[0-9])/git version /; # monkey patch the code that returns git version no strict 'refs'; no warnings 'redefine'; *{'Test::Requires::Git::_git_version'} = sub { "$version\n" }; } 1; Test-Requires-Git-1.008/t/success.t0000644000175000017500000000211313057610703015524 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.2.3'; use Test::Requires::Git; # the check always passes, because of t::FakeGit plan tests => 9; # any skip will 'skip all', # this line ensures there will be a 'bad plan' failure in that case pass('initial pass'); # force run-time evaluation eval "use Test::Requires::Git version_gt => '1.0.0';"; pass("passed the compile-time check version_gt => '1.0.0'"); test_requires_git version => '1.2.3'; pass("passed the run-time check version => '1.2.3'"); test_requires_git version_eq => '1.2.3', version_ne => '1.2.4'; pass("passed the run-time check version_eq => '1.2.3', version_ne => '1.2.4'"); test_requires_git version_lt => '1.3.3'; pass("passed the run-time check version_lt => '1.3.3'"); test_requires_git version_gt => '1.0.0a'; pass("passed the run-time check version_gt => '1.0.0a'"); test_requires_git version_le => '1.2.3'; pass("passed the run-time check version_le => '1.2.3'"); test_requires_git version_ge => '1.2.3'; pass("passed the run-time check version_ge => '1.2.3'"); pass('all passed'); Test-Requires-Git-1.008/t/fail.t0000644000175000017500000000122013057610703014765 0ustar bookbookuse strict; use warnings; use Test::More; use Test::Requires::Git -nocheck; plan tests => 7; ok( !eval { test_requires_git 'zlonk' }, 'odd specification' ); like( $@, qr/^zlonk does not look like a Git version /, '... expected error message' ); ok( !eval { test_requires_git 'zlonk' => 'bam' }, 'bad specification' ); like( $@, qr/^Unknown git specification 'zlonk' /, '... expected error message' ); ok( !eval { test_requires_git skip => 2, skip => 3 }, 'duplicate argument' ); like( $@, qr/^Duplicate 'skip' argument /, '... expected error message' ); $ENV{PATH} = ''; test_requires_git; fail( 'cannot happen'); Test-Requires-Git-1.008/t/no_plan.t0000644000175000017500000000045013057610703015504 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.2.3'; use Test::Requires::Git; plan 'no_plan'; # ok test_requires_git version_gt => '1.2.0'; # skip test_requires_git version_lt => '1.2.1', version_eq => '1.2.3', version_ne => '1.2.3'; fail('cannot happen'); Test-Requires-Git-1.008/t/use_git.t0000644000175000017500000000021513057610703015514 0ustar bookbookuse strict; use warnings; use Test::More; use Test::Requires::Git git => '/zowie/zzzzzwap/ker_plop'; fail('cannot happen'); done_testing; Test-Requires-Git-1.008/t/undef_plan.t0000644000175000017500000000036213057610703016173 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit '1.2.3'; use Test::Requires::Git; # ok test_requires_git version_gt => '1.2.0'; # skip test_requires_git version_lt => '1.2.1'; fail('cannot happen'); done_testing; Test-Requires-Git-1.008/t/no_git.t0000644000175000017500000000026313057610703015337 0ustar bookbookuse strict; use warnings; use Test::More; use lib 't/lib'; use FakeGit 'broken'; use Test::Requires::Git -nocheck; plan tests => 1; test_requires_git; fail('cannot happen'); Test-Requires-Git-1.008/t/author-pod-syntax.t0000644000175000017500000000050313057610703017463 0ustar bookbook#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Test-Requires-Git-1.008/META.yml0000644000175000017500000000167513057610703014711 0ustar bookbook--- abstract: 'Check your test requirements against the available version of Git' author: - 'Philippe Bruhat (BooK) ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' List::Util: '0' Scalar::Util: '0' Test::More: '0' lib: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.047, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-Requires-Git requires: Carp: '0' Git::Version::Compare: '1.003' Test::Builder::Module: '0' base: '0' strict: '0' warnings: '0' resources: bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Requires-Git repository: http://github.com/book/Test-Requires-Git.git version: '1.008' x_contributors: - 'Christian Walde ' - 'Olivier Mengué ' - 'Pine Mizune ' Test-Requires-Git-1.008/META.json0000644000175000017500000000370513057610703015055 0ustar bookbook{ "abstract" : "Check your test requirements against the available version of Git", "author" : [ "Philippe Bruhat (BooK) " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.047, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-Requires-Git", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Meta" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Carp" : "0", "Git::Version::Compare" : "1.003", "Test::Builder::Module" : "0", "base" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "List::Util" : "0", "Scalar::Util" : "0", "Test::More" : "0", "lib" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-test-requires-git@rt.cpan.org", "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Requires-Git" }, "repository" : { "type" : "git", "url" : "http://github.com/book/Test-Requires-Git.git", "web" : "http://github.com/book/Test-Requires-Git" } }, "version" : "1.008", "x_contributors" : [ "Christian Walde ", "Olivier Mengu\u00e9 ", "Pine Mizune " ] } Test-Requires-Git-1.008/dist.ini0000644000175000017500000000214013057610703015070 0ustar bookbookname = Test-Requires-Git author = Philippe Bruhat (BooK) license = Perl_5 copyright_holder = Philippe Bruhat (BooK) ; copyright_year = 2015 [PkgVersion] [@Filter] -bundle = @Basic -remove = Readme [PruneFiles] match = mess/.* filename = .test.requires.git.lock [Prereqs] Git::Version::Compare = 1.003 [AutoPrereqs] [Test::ReportPrereqs] [MetaJSON] [MetaResources] repository.web = http://github.com/book/Test-Requires-Git repository.url = http://github.com/book/Test-Requires-Git.git repository.type = git bugtracker.web = http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Requires-Git bugtracker.mailto = bug-test-requires-git@rt.cpan.org [MetaTests] [PodSyntaxTests] [PodCoverageTests] [NextRelease] format = %v %{yyyy-MM-dd}d %P [@Git] changelog = Changes commit_msg = Changes for version %v tag_format = v%v tag_message = %N v%v push_to = origin push_to = github [Git::NextVersion] first_version = 1.000 [Meta::Contributors] contributor = Christian Walde contributor = Olivier Mengué contributor = Pine Mizune Test-Requires-Git-1.008/MANIFEST0000644000175000017500000000074713057610703014570 0ustar bookbook# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.047. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Test/Requires/Git.pm t/00-report-prereqs.dd t/00-report-prereqs.t t/author-pod-coverage.t t/author-pod-syntax.t t/fail.t t/has_plan.t t/import.t t/lib/FakeGit.pm t/no_git.t t/no_plan.t t/odd_args.t t/other_git.t t/release-distmeta.t t/skip_all.t t/skip_git.t t/skip_one.t t/skip_remaining.t t/success.t t/undef_plan.t t/use_git.t Test-Requires-Git-1.008/Makefile.PL0000644000175000017500000000274513057610703015411 0ustar bookbook# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.047. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Check your test requirements against the available version of Git", "AUTHOR" => "Philippe Bruhat (BooK) ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Test-Requires-Git", "LICENSE" => "perl", "NAME" => "Test::Requires::Git", "PREREQ_PM" => { "Carp" => 0, "Git::Version::Compare" => "1.003", "Test::Builder::Module" => 0, "base" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "List::Util" => 0, "Scalar::Util" => 0, "Test::More" => 0, "lib" => 0 }, "VERSION" => "1.008", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Git::Version::Compare" => "1.003", "List::Util" => 0, "Scalar::Util" => 0, "Test::Builder::Module" => 0, "Test::More" => 0, "base" => 0, "lib" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Test-Requires-Git-1.008/lib/0000755000175000017500000000000013057610703014175 5ustar bookbookTest-Requires-Git-1.008/lib/Test/0000755000175000017500000000000013057610703015114 5ustar bookbookTest-Requires-Git-1.008/lib/Test/Requires/0000755000175000017500000000000013057610703016713 5ustar bookbookTest-Requires-Git-1.008/lib/Test/Requires/Git.pm0000644000175000017500000002137413057610703020003 0ustar bookbookpackage Test::Requires::Git; $Test::Requires::Git::VERSION = '1.008'; use strict; use warnings; use Carp; use Git::Version::Compare (); use base 'Test::Builder::Module'; our $GIT = 'git'; my %check = ( version_eq => \&Git::Version::Compare::eq_git, version_ne => \&Git::Version::Compare::ne_git, version_gt => \&Git::Version::Compare::gt_git, version_le => \&Git::Version::Compare::le_git, version_lt => \&Git::Version::Compare::lt_git, version_ge => \&Git::Version::Compare::ge_git, ); # aliases $check{'=='} = $check{eq} = $check{version} = $check{version_eq}; $check{'!='} = $check{ne} = $check{version_ne}; $check{'>'} = $check{gt} = $check{version_gt}; $check{'<='} = $check{le} = $check{version_le}; $check{'<'} = $check{lt} = $check{version_lt}; $check{'>='} = $check{ge} = $check{version_ge}; my $quiet = 0; my $lock = '.test.requires.git.lock'; sub import { my $class = shift; my $caller = caller(0); # export methods { no strict 'refs'; *{"$caller\::test_requires_git"} = \&test_requires_git; } return if @_ == 1 && $_[0] eq '-nocheck'; # reset the global $GIT value my $args = _extract_arguments(@_); $GIT = $args->{git} if exists $args->{git}; # test arguments test_requires_git(@_); } sub _extract_arguments { my (@args) = @_; my ( %args, @spec ); while (@args) { # assume a lone parameter is a minimum git version unshift @args, 'version_ge' if @args == 1; my ( $key, $val ) = splice @args, 0, 2; if ( $key =~ /^(?:git|skip)/ ) { croak "Duplicate '$key' argument" if exists $args{$key}; $args{$key} = $val; } elsif ( !exists $check{$key} ) { if ( @args % 2 ) { # odd number of arguments (see above) unshift @args, version_ge => $key, $val; redo; } croak "Unknown git specification '$key'"; } else { push @spec, $key, $val; } } return wantarray ? ( \%args, @spec ) : \%args; } sub _git_version { qx{$GIT --version} } sub test_requires_git { my ( $args, @spec ) = _extract_arguments(@_); my $skip = $args->{skip}; local $GIT = $args->{git} if exists $args->{git}; # get the git version my ($version) = do { no warnings 'uninitialized'; __PACKAGE__->_git_version(); # tests may override this }; my $builder = __PACKAGE__->builder; if ( !$quiet && time - ( ( stat $lock )[9] || 0 ) > 60 ) { $builder->diag($version); $quiet++; open my $fh, '>', $lock if !-e $lock; utime( undef, undef, $lock ); } # perform the check my ( $ok, $why ) = ( 1, '' ); if ( defined $version && Git::Version::Compare::looks_like_git($version) ) { while ( my ( $spec, $arg ) = splice @spec, 0, 2 ) { if ( !$check{$spec}->( $version, $arg ) ) { $ok = 0; $version =~ s/^git version|[\012\015]+$//g; $why = "$version $spec $arg"; last; } } } else { $ok = 0; $why = "`$GIT` binary not available or broken"; } # skip if needed if ( !$ok ) { # skip a specified number of tests if ( $skip ) { $builder->skip($why) for 1 .. $skip; no warnings 'exiting'; last SKIP; } # no plan declared yet elsif ( !defined $builder->has_plan ) { if ( $builder->summary ) { $builder->skip($why); $builder->done_testing; exit 0; } else { $builder->skip_all($why); } } # the plan is no_plan elsif ( $builder->has_plan eq 'no_plan' ) { $builder->skip($why); exit 0; } # some plan was declared, skip all tests one by one else { $builder->skip($why) for 1 + $builder->summary .. $builder->has_plan; exit 0; } } } 'git'; __END__ =encoding utf-8 =head1 NAME Test::Requires::Git - Check your test requirements against the available version of Git =head1 SYNOPSIS # will skip all if git is not available use Test::Requires::Git; # needs some git that supports `git init $dir` test_requires_git version_ge => '1.6.5'; =head1 DESCRIPTION Test::Requires::Git checks if the version of Git available for testing meets the given requirements. If the checks fail, then all tests will be I. C always calls C with the given arguments. If you don't want C to be called at import time, write this instead: use Test::Requires::Git -nocheck; Passing the C parameter (see L below) to C will override it for the rest of the program run. =head1 EXPORTED FUNCTIONS =head2 test_requires_git # skip all unless git is available as required test_requires_git version_ge => '1.6.5'; # giving no operator implies 'version_ge' test_requires_git '1.6.5'; # skip 2 if git is not available SKIP: { test_requires_git skip => 2; ...; } # skip 2 unless git is available as required SKIP: { test_requires_git skip => 2, version_ge => '1.7.12'; ...; } # skip all remaining tests if git is not available test_requires_git; # force which git binary to use test_requires_git git => '/usr/local/bin/git', version_ge => '1.6.5'; Takes a list of version requirements (see L below), and if one of them does not pass, I all remaining tests. All conditions must be satisfied for the check to pass. When the C parameter is given, only the specified number of tests will be skipped. The "current git" is obtained by running C. I.e. the first C binary found in the current environment will be tested. This is of course sensitive to local changes to C, so this will behave as expected: # skip 4 tests if there's no git available in the alternative PATH SKIP: { local $ENV{PATH} = $alternative_PATH; test_requires_git skip => 4; ...; } When the C parameter is given, C will run that program instead of C. If no condition is given, C will simply check if C is available. The first time it's called, C will print a test diagnostic with the output of C (if C is available, of course). To prevent this behaviour, load the module with: use Test::Requires::Git -quiet; =head1 GIT VERSION CHECKING The actual comparison is handled by L, so the strings can be version numbers, tags from C or the output of C or C. The following version checks are currently supported: =head2 version_eq Aliases: C, C, C<==>, C. test_requires_git version_eq => $version; Passes if the current B version is I to C<$version>. =head2 version_ne Aliases: C, C, C. test_requires_git version_eq => $version; Passes if the current B version is I to C<$version>. =head2 version_lt Aliases: C, C, C>. test_requires_git version_lt => $version; Passes if the current B version is I C<$version>. =head2 version_gt Aliases: C, C, C>. test_requires_git version_gt => $version; Passes if the current B version is I C<$version>. =head2 version_le Aliases: C, C, C=>. test_requires_git version_le => $version; Passes if the current B version is I C<$version>. =head2 version_ge Aliases: C, C, C=>. test_requires_git version_ge => $version; Passes if the current B version is I C<$version>. As a special shortcut for the most common case, a lone version number is turned into a C check, so the following two lines are exactly equivalent: test_requires_git version_ge => '1.6.5'; # version_ge implied test_requires_git '1.6.5'; =head1 SEE ALSO L, L. =head1 ACKNOWLEDGEMENTS Thanks to Oliver Mengué (DOLMEN), who gave me the idea for this module at the Perl QA Hackathon 2015 in Berlin, and suggested to give a look at L for inspiration. =head1 AUTHOR Philippe Bruhat (BooK), . =head1 COPYRIGHT Copyright 2015-2016 Philippe Bruhat (BooK), all rights reserved. =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Test-Requires-Git-1.008/README0000644000175000017500000000137313057610703014313 0ustar bookbookNAME Test::Requires::Git - Check your test requirements against the available version of Git SYNOPSIS use Test::Requires::Git; # needs some git that supports `git init $dir` test_requires_git version_ge => '1.6.5'; DESCRIPTION Test::Requires::Git checks if the version of Git available for testing meets the given requirements. The "current git" is obtained by running "git --version" (so the first "git" binary found in the "PATH" will be tested). If the checks fail, then all tests will be skipped. AUTHOR Philippe Bruhat (BooK), . COPYRIGHT Copyright 2015 Philippe Bruhat (BooK), all rights reserved. LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.