summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-09-22 08:57:33 +0000
committerNicholas Clark <nick@ccl4.org>2021-10-12 08:11:47 +0000
commita36da35bfcd30972d735b109216c89367a655e9b (patch)
tree65d97e547b1ef2eaa67d96ded6ad92af3be4a8c5 /Porting
parentf73a32e0fd37de0a9c1965edfc1bda20d38e12d7 (diff)
downloadperl-a36da35bfcd30972d735b109216c89367a655e9b.tar.gz
manicheck now optionally exits non-zero if it finds problems
This will enable it to be used in a CI test. Refactor the code to avoid the temporary array @files by iterating over the lines of MANIFEST as they are read in.
Diffstat (limited to 'Porting')
-rw-r--r--Porting/manicheck38
1 files changed, 32 insertions, 6 deletions
diff --git a/Porting/manicheck b/Porting/manicheck
index c0d7548e6d..6db1fd2120 100644
--- a/Porting/manicheck
+++ b/Porting/manicheck
@@ -7,14 +7,27 @@
use v5.14;
use warnings;
use File::Find;
+use Getopt::Long;
+use constant SKIP => 125;
+
+my $exitstatus;
+GetOptions('exitstatus!', \$exitstatus)
+ or die "$0 [--exitstatus]";
+
+my %files;
+my $missing = 0;
+my $bonus = 0;
open my $fh, '<', 'MANIFEST' or die "Can't read MANIFEST: $!\n";
-my @files = map { (split)[0] } <$fh>;
-close $fh;
-for (@files) {
- print "$_ from MANIFEST doesn't exist\n" if ! -f;
+for my $line (<$fh>) {
+ my ($file) = $line =~ /^(\S+)/;
+ ++$files{$file};
+ next if -f $file;
+ ++$missing;
+ print "$file from MANIFEST doesn't exist\n";
}
-my %files = map { $_ => 1 } @files;
+close $fh;
+
find {
wanted => sub {
return if -d;
@@ -26,7 +39,20 @@ find {
my $x = $File::Find::name =~ s!^\./!!r;
return if $x =~ /^\.git\b/;
return if $x =~ m{^\.github/};
- print "$x\t\tnot in MANIFEST\n" if !$files{$x};
+ return if $files{$x};
+ ++$bonus;
+ print "$x\t\tnot in MANIFEST\n";
},
}, ".";
+my $exitcode = $exitstatus ? $missing + $bonus : 0;
+
+# We can't (meaningfully) exit with codes above 255, so we're going to have to
+# clamp them to some range whatever we do. So as we need the code anyway, use
+# 124 as our maximum instead, and then we can run as a useful git bisect run
+# script if needed...
+
+$exitcode = SKIP - 1
+ if $exitcode > SKIP;
+
+exit $exitcode;