]> git.imager.perl.org - imager.git/blob - xt/x90cmpversion.t
avoid a possible sign-extension for offsets/sizes in SGI
[imager.git] / xt / x90cmpversion.t
1 #!perl -w
2 use strict;
3 use Test::More;
4 use ExtUtils::MakeMaker;
5 use ExtUtils::Manifest 'maniread';
6 use File::Spec::Functions qw(devnull);
7 use Getopt::Long;
8
9 my $report;
10 GetOptions("r" => \$report);
11
12 my $last_tag = shift;
13
14 unless ($last_tag) {
15   $last_tag = `git describe --abbrev=0`;
16   chomp $last_tag;
17 }
18
19 -d ".git"
20   or plan skip_all => "Only usable in a git checkout";
21
22 my $mani = maniread();
23
24 my @subdirs = qw(PNG TIFF GIF JPEG W32 T1 FT2 ICO SGI Mandelbrot CountColor DynTest);
25
26 my $subdir_re = "^(?:" . join("|", @subdirs) . ")/";
27
28 my @pm_files = sort
29   grep /\.pm$/ && !/$subdir_re/ && !/^t\// && $_ ne 'Imager.pm', keys %$mani;
30
31 plan tests => scalar(@subdirs) + scalar(@pm_files)
32   unless $report;
33
34 for my $dir (@subdirs) {
35   my @changes = `git log --abbrev --oneline $last_tag..HEAD -- $dir`;
36   my @more_changes = `git status --porcelain -- $dir`;
37   if ($report) {
38     print "$dir updated\n" if @changes || @more_changes;
39   }
40   else {
41   SKIP:
42     {
43       @changes || @more_changes
44         or skip "No changes for $dir", 1;
45       my $vfile = "$dir/$dir.pm";
46       my $current = eval { MM->parse_version($vfile) };
47       my $last_rel_content = get_file_from_git($vfile, $last_tag);
48       my $last = eval { MM->parse_version(\$last_rel_content) };
49       unless (isnt($current, $last, "$dir updated, $vfile version bump")) {
50         diag(@changes, @more_changes);
51       }
52     }
53   }
54 }
55
56 unless ($report) {
57   for my $file (@pm_files) {
58     my @changes = `git log --abbrev --oneline $last_tag..HEAD $file`;
59     my @more_changes = `git status --porcelain $file`;
60   SKIP:
61     {
62       @changes || @more_changes
63         or skip "No changes for $file", 1;
64       my $current = eval { MM->parse_version($file) };
65       my $last_rel_content = get_file_from_git($file, $last_tag);
66       my $last = eval { MM->parse_version(\$last_rel_content) };
67       unless (isnt($current, $last, "$file updated, version bump")) {
68         diag(@changes, @more_changes);
69       }
70     }
71   }
72 }
73
74 sub get_file_from_git {
75     my ($file, $tag) = @_;
76     my $null = devnull();
77     local $/;
78     return scalar `git --no-pager show $tag:$file 2>$null`;
79 }