GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Requires::Git(3) User Contributed Perl Documentation Test::Requires::Git(3)

Test::Requires::Git - Check your test requirements against the available version of Git

    # 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';

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 skipped.

"use Test::Requires::Git" always calls "test_requires_git" with the given arguments. If you don't want "test_requires_git" to be called at import time, write this instead:

    use Test::Requires::Git -nocheck;

Passing the "git" parameter (see "test_requires_git" below) to "use Test::Requires::Git" will override it for the rest of the program run.

    # 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 "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.

The "current git" is obtained by running "git --version". I.e. the first "git" binary found in the current environment will be tested. This is of course sensitive to local changes to "PATH", 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 "git" parameter is given, "test_requires_git" will run that program instead of "git".

If no condition is given, "test_requires_git" will simply check if "git" is available.

The first time it's called, "test_require_git" will print a test diagnostic with the output of "git --version" (if "git" is available, of course). To prevent this behaviour, load the module with:

    use Test::Requires::Git -quiet;

The actual comparison is handled by Git::Version::Compare, so the strings can be version numbers, tags from "git.git" or the output of "git version" or "git describe".

The following version checks are currently supported:

Aliases: "version_eq", "eq", "==", "version".

    test_requires_git version_eq => $version;

Passes if the current git version is equal to $version.

Aliases: "version_ne", "ne", "!=".

    test_requires_git version_eq => $version;

Passes if the current git version is not equal to $version.

Aliases: "version_lt", "lt", "<".

    test_requires_git version_lt => $version;

Passes if the current git version is less than $version.

Aliases: "version_gt", "gt", ">".

    test_requires_git version_gt => $version;

Passes if the current git version is greater than $version.

Aliases: "version_le", "le", "<=".

    test_requires_git version_le => $version;

Passes if the current git version is less than or equal $version.

Aliases: "version_ge", "ge", ">=".

    test_requires_git version_ge => $version;

Passes if the current git version is greater than or equal $version.

As a special shortcut for the most common case, a lone version number is turned into a "version_ge" 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';

Test::Requires, Git::Version::Compare.

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.

Philippe Bruhat (BooK), <book@cpan.org>.

Copyright 2015-2016 Philippe Bruhat (BooK), all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2017-03-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.