summaryrefslogtreecommitdiff
path: root/Porting/cmpVERSION.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-05-19 20:24:14 +0100
committerNicholas Clark <nick@ccl4.org>2011-05-23 15:07:27 +0100
commit76733a60f0c586b040ff148deb9350d0e6a2b742 (patch)
tree83ceeb7b07fa1036976e6cc8149047a1403d439f /Porting/cmpVERSION.pl
parent844d38432e40db17e5b3b260f7fa76192371dfc6 (diff)
downloadperl-76733a60f0c586b040ff148deb9350d0e6a2b742.tar.gz
Fold Abigail's TAP generation logic back into cmpVERSION.pl
Reduce t/porting/cmp_version.t down to an invocation of cmpVERSION.pl with --tap.
Diffstat (limited to 'Porting/cmpVERSION.pl')
-rwxr-xr-xPorting/cmpVERSION.pl79
1 files changed, 59 insertions, 20 deletions
diff --git a/Porting/cmpVERSION.pl b/Porting/cmpVERSION.pl
index d5e47003bf..d95eb76a15 100755
--- a/Porting/cmpVERSION.pl
+++ b/Porting/cmpVERSION.pl
@@ -10,7 +10,7 @@
# them)
#
# Original by slaven@rezic.de, modified by jhi and matt.w.johnson@gmail.com.
-#
+# Adaptation to produce TAP by Abigail, folded back into this file by Nicholas
use strict;
@@ -19,12 +19,13 @@ use File::Compare;
use File::Spec::Functions qw(devnull);
use Getopt::Long;
-my ($diffs, $exclude_upstream, $tag_to_compare);
+my ($diffs, $exclude_upstream, $tag_to_compare, $tap);
unless (GetOptions('diffs' => \$diffs,
'exclude|x' => \$exclude_upstream,
'tag=s' => \$tag_to_compare,
+ 'tap' => \$tap,
) && @ARGV == 0) {
- die "usage: $0 [ -d -x --tag TAG]";
+ die "usage: $0 [ -d -x --tag TAG --tap]";
}
die "$0: This does not look like a Perl directory\n"
@@ -44,8 +45,11 @@ unless (defined $tag_to_compare) {
my $tag_exists = `git --no-pager tag -l $tag_to_compare 2>$null`;
chomp $tag_exists;
-die "$0: '$tag_to_compare' is not a known Git tag\n"
- unless $tag_exists eq $tag_to_compare;
+unless ($tag_exists eq $tag_to_compare) {
+ die "$0: '$tag_to_compare' is not a known Git tag\n" unless $tap;
+ print "1..0 # SKIP: '$tag_to_compare' is not a known Git tag\n";
+ exit 0;
+}
my %upstream_files;
if ($exclude_upstream) {
@@ -68,6 +72,19 @@ my %skip;
'lib/Exporter/Heavy.pm',
'win32/FindExt.pm',
} = ();
+
+# Files to skip just for particular version(s),
+# usually due to some # mix-up
+
+my %skip_versions;
+if ($tap) {
+ %skip_versions
+ = (
+ # 'some/sample/file.pm' => [ '1.23', '1.24' ],
+ 'dist/threads/lib/threads.pm' => [ '1.83' ],
+ );
+}
+
my $skip_dirs = qr|^t/lib|;
my @all_diffs = `git --no-pager diff --name-only $tag_to_compare`;
@@ -82,9 +99,20 @@ my @module_diffs = grep {
!exists $upstream_files{$_}
} @all_diffs;
-my (@output_files, @output_diffs);
+unless (@module_diffs) {
+ print "1..1\nok 1 - No difference found\n" if $tap;
+ exit;
+}
+
+printf "1..%d\n" => scalar @module_diffs if $tap;
+
+my $count;
+my $diff_cmd = "git --no-pager diff $tag_to_compare ";
+my (@diff);
-foreach my $pm_file (@module_diffs) {
+foreach my $pm_file (sort @module_diffs) {
+ # --tap does diff inline, --diff does it at the end.
+ @diff = () if $tap;
(my $xs_file = $pm_file) =~ s/\.pm$/.xs/;
my $pm_eq = compare_git_file($pm_file, $tag_to_compare);
next unless defined $pm_eq;
@@ -100,9 +128,25 @@ foreach my $pm_file (@module_diffs) {
next if ( ! defined $pm_version || ! defined $orig_pm_version );
next if ( $pm_version eq 'undef' || $orig_pm_version eq 'undef' ); # sigh
next if $pm_version ne $orig_pm_version;
- push @output_files, $pm_file;
- push @output_diffs, $pm_file unless $pm_eq;
- push @output_diffs, $xs_file unless $xs_eq;
+ next if exists $skip_versions{$pm_file}
+ and grep $pm_version eq $_, @{$skip_versions{$pm_file}};
+ push @diff, $pm_file unless $pm_eq;
+ push @diff, $xs_file unless $xs_eq;
+}
+continue {
+ if (@diff) {
+ if ($tap) {
+ foreach (@diff) {
+ print "# $_" for `$diff_cmd '$_'`;
+ }
+ printf "not ok %d - %s\n", ++$count, $pm_file;
+ } else {
+ print "$pm_file\n";
+ }
+ }
+ elsif ($tap) {
+ printf "ok %d - %s\n", ++$count, $pm_file;
+ }
}
sub compare_git_file {
@@ -121,14 +165,9 @@ sub get_file_from_git {
return $file_content;
}
-for (sort @output_files) {
- print "$_\n";
-}
-
-exit unless $diffs;
-
-for (sort @output_diffs) {
- print "\n";
- system "git --no-pager diff $tag_to_compare '$_'";
+if ($diffs) {
+ for (sort @diff) {
+ print "\n";
+ system "$diff_cmd '$_'";
+ }
}
-