File: test-all-git.t

package info (click to toggle)
libgit-repository-perl 1.325-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 376 kB
  • sloc: perl: 661; makefile: 7
file content (72 lines) | stat: -rw-r--r-- 1,951 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use strict;
use warnings;
use Test::More;
use Git::Repository;
use Git::Version::Compare qw( cmp_git );
use File::Spec;

plan skip_all => 'these tests are for extended testing'
  if !$ENV{EXTENDED_TESTING};

# look for the git-collection dir, including under ../.. (under `dzil test`)
my $collection = 'git-collection';
my ($git_home) = grep -d, $collection,
  File::Spec->catdir( File::Spec->updir, File::Spec->updir, $collection );

plan skip_all => "set the $collection directory/link to point at your local collection of Git builds"
  if !defined $git_home;

my @versions;
{
    opendir my $DH, $git_home or die "Can't opendir $git_home";
    @versions = grep { /^\d/ } readdir $DH;
    closedir $DH
}

# the test script accepts version specifications to limit the number
# of versions tested
my @spec = map {
    /-/
      ? do {    # range
        my ( $min, $max ) = split /-/;
        sub {
            !( $min      && Git::Repository::_version_gt( $min,  $_[0] ) )
              && !( $max && Git::Repository::_version_gt( $_[0], $max ) );
          }
      }
      : do {    # single item
        my $v = $_;
        sub { $_[0] eq $v }
      };
} @ARGV;

# the default it to test against all available versions
if (@spec) {
    @versions = grep {
        my $version = $_;
        my $ok;
        $ok += $_->($version) for @spec;
        $ok;
    } @versions;
}

# sort the versions to test
@versions = sort cmp_git @versions;

plan tests => scalar @versions;

# remove it to avoid infinite loops
delete $ENV{EXTENDED_TESTING};

my @fail;
for my $version (@versions) {
    local $ENV{PATH} = join $Config::Config{path_sep},
      File::Spec->catdir( $git_home, $version, 'bin' ), $ENV{PATH};
    close STDERR;    # don't let the inner prove spoil the output
    `prove -l t`;
    ok( $? == 0, $version );
    push @fail, $version if $?;
}

diag "Test suite failed with Git version:" if @fail;
diag join ' ', splice @fail, 0, 5 while @fail;