]> git.imager.perl.org - imager.git/blob - t/x90cmpversion.t
202da2a969643da16c58747b3a192ff93179d22f
[imager.git] / t / 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
8 my $last_tag = `git describe --abbrev=0`;
9 chomp $last_tag;
10
11 $last_tag
12   or plan skip_all => "Only usable in a git checkout";
13
14 my $mani = maniread();
15
16 my @subdirs = qw(PNG TIFF GIF JPEG W32 T1 FT2 ICO SGI Mandelbrot CountColor DynTest);
17
18 my $subdir_re = "^(?:" . join("|", @subdirs) . ")/";
19
20 my @pm_files = sort
21   grep /\.pm$/ && !/$subdir_re/ && !/^t\// && $_ ne 'Imager.pm', keys %$mani;
22
23 plan tests => scalar(@subdirs) + scalar(@pm_files);
24
25 for my $dir (@subdirs) {
26   my @changes = `git log --abbrev --oneline $last_tag..HEAD $dir`;
27   my @more_changes = `git status --porcelain $dir`;
28  SKIP:
29   {
30     @changes || @more_changes
31       or skip "No changes for $dir", 1;
32     my $vfile = "$dir/$dir.pm";
33     my $current = eval { MM->parse_version($vfile) };
34     my $last_rel_content = get_file_from_git($vfile, $last_tag);
35     my $last = eval { MM->parse_version(\$last_rel_content) };
36     unless (isnt($current, $last, "$dir updated, $vfile version bump")) {
37       diag(@changes, @more_changes);
38     }
39   }
40 }
41
42 for my $file (@pm_files) {
43   my @changes = `git log --abbrev --oneline $last_tag..HEAD $file`;
44   my @more_changes = `git status --porcelain $file`;
45  SKIP:
46   {
47     @changes || @more_changes
48       or skip "No changes for $file", 1;
49     my $current = eval { MM->parse_version($file) };
50     my $last_rel_content = get_file_from_git($file, $last_tag);
51     my $last = eval { MM->parse_version(\$last_rel_content) };
52     unless (isnt($current, $last, "$file updated, version bump")) {
53       diag(@changes, @more_changes);
54     }
55   }
56 }
57
58 sub get_file_from_git {
59     my ($file, $tag) = @_;
60     my $null = devnull();
61     local $/;
62     return scalar `git --no-pager show $tag:$file 2>$null`;
63 }