NAME
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.
EXPORTED FUNCTIONS
test_requires_git
# skip all
test_requires_git version_ge => '1.6.5';
# skip 2
SKIP: {
test_requires_git
skip => 2,
version_ge => '1.7.12';
...;
}
# skip all if git is not available
test_requires_git;
# skip 2 if git is not available
SKIP: {
test_requires_git skip => 2;
...;
}
Takes a list of version requirements (see "GIT VERSION CHECKING" below), and if one of them does not pass, skips all remaining tests. All conditions must be satisfied for the check to pass.
When the skip
parameter is given, only the specified number of tests will be skipped.
If no condition is given, test_requires_git
will simply check if git
is available.
GIT VERSION CHECKING
The following version checks are currently supported.
Note that versions 1.0.0a
and 1.0.0b
are respectively turned into 1.0.1
and 1.0.2
internally.
version_eq
Aliases: version_eq
, eq
, ==
, version
.
test_requires_git version_eq => $version;
Passes if the current git version is equal to $version
.
version_ne
Aliases: version_ne
, ne
, !=
.
test_requires_git version_eq => $version;
Passes if the current git version is not equal to $version
.
version_lt
Aliases: version_lt
, lt
, <
.
test_requires_git version_lt => $version;
Passes if the current git version is less than $version
.
version_gt
Aliases: version_gt
, gt
, >
.
test_requires_git version_gt => $version;
Passes if the current git version is greater than $version
.
version_le
Aliases: version_le
, le
, <=
.
test_requires_git version_le => $version;
Passes if the current git version is less than or equal $version
.
version_ge
Aliases: version_ge
, ge
, >=
.
test_requires_git version_ge => $version;
Passes if the current git version is greater than or equal $version
.
SEE ALSO
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 Test::Requires for inspiration.
AUTHOR
Philippe Bruhat (BooK), <book@cpan.org>.
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.