summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2011-12-15 23:11:51 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2011-12-22 13:36:57 +0000
commitcfc6c78d0071efb47b7551183968bd55254af6e5 (patch)
tree157a97263db128da6164e4c086734e88e09b19f0 /t
parent911bfca9fca9e4fddb455137dd35806cfa8adf5a (diff)
downloadperl-cfc6c78d0071efb47b7551183968bd55254af6e5.tar.gz
Added porting tests for CUSTOMIZED files
In Porting/Maintainers.pl CUSTOMIZED is a list of files that have been customized within the Perl core. These tests make SHA digests of the customized files and do a comparison previously stored digests to ensure that customization is not lost when updating from upstream. Update MANIFEST with the customized files Add --regen ability to porting/customized.t and some documentation
Diffstat (limited to 't')
-rw-r--r--t/porting/customized.dat14
-rw-r--r--t/porting/customized.t144
2 files changed, 158 insertions, 0 deletions
diff --git a/t/porting/customized.dat b/t/porting/customized.dat
new file mode 100644
index 0000000000..e2ef05d3d2
--- /dev/null
+++ b/t/porting/customized.dat
@@ -0,0 +1,14 @@
+Module::Build cpan/Module-Build/lib/Module/Build/ConfigData.pm 2f3f07fd889077ebd51791ad6e195d9164b4baf3
+Test::Harness cpan/Test-Harness/t/source.t 61738913dac9ba6c4504756d355c23c25c47d31e
+Test::Harness cpan/Test-Harness/t/testargs.t 79c91b2ea73f7cbfb9bae45dec4a62db74cb8dbf
+Module::Pluggable cpan/Module-Pluggable/Makefile.PL 72062c1a01ed7c62d16c55122c163b2d89f0d739
+autodie cpan/autodie/t/open.t cb493da4305f591ca0344d09e8a840a3147c5579
+libnet cpan/libnet/Makefile.PL 5554b71464b45f5cc002e55f2464f7ff4abd05b6
+podlators cpan/podlators/scripts/pod2man.PL 8fb484dc560adb00889f504760ca0a4defa9dc40
+podlators cpan/podlators/scripts/pod2text.PL 53ccba9264368c3f9acd2a36d1d354797d2a88f6
+podlators pod/perlpodstyle.pod 4f1ba65eddc5576267954b948556e16a9686c411
+CPANPLUS cpan/CPANPLUS/Makefile.PL 5d533f6722af6aae73204755beb8d6c008fc0d4a
+Text-Tabs+Wrap cpan/Text-Tabs/t/fill.t a960d2c4f66b7e30557b5479e0da2da1bf7a7f45
+Text-Tabs+Wrap cpan/Text-Tabs/t/tabs.t 63a67b3a319c858d7e66306b8a653de1951153dc
+Sys::Syslog cpan/Sys-Syslog/t/syslog.t 647571fc90918883b871ff7e005ed7ab8a223784
+CGI cpan/CGI/t/tmpdir.t 83c913c36712f00412ce42475ae8a2bd1eba52ea
diff --git a/t/porting/customized.t b/t/porting/customized.t
new file mode 100644
index 0000000000..76053bcc07
--- /dev/null
+++ b/t/porting/customized.t
@@ -0,0 +1,144 @@
+#!./perl -w
+
+# Test that CUSTOMIZED files in Maintainers.pl have not been overwritten.
+
+BEGIN {
+ # This test script uses a slightly atypical invocation of the 'standard'
+ # core testing setup stanza.
+ # The existing porting tools which manage the Maintainers file all
+ # expect to be run from the root
+ # XXX that should be fixed
+
+ chdir '..' unless -d 't';
+ @INC = qw(lib Porting);
+}
+
+use strict;
+use warnings;
+use Digest;
+use File::Spec;
+use Maintainers qw[%Modules get_module_files get_module_pat];
+
+sub filter_customized {
+ my ($m, @files) = @_;
+
+ return @files
+ unless my $customized = $Modules{$m}{CUSTOMIZED};
+
+ my ($pat) = map { qr/$_/ } join '|' => map {
+ ref $_ ? $_ : qr/\b\Q$_\E$/
+ } @{ $customized };
+
+ return grep { $_ =~ $pat } @files;
+}
+
+sub my_get_module_files {
+ my $m = shift;
+ return filter_customized $m => map { Maintainers::expand_glob($_) } get_module_pat($m);
+}
+
+my $TestCounter = 0;
+
+my $digest_type = 'SHA-1';
+
+my $original_dir = File::Spec->rel2abs(File::Spec->curdir);
+my $data_dir = File::Spec->catdir('t', 'porting');
+my $customised = File::Spec->catfile($data_dir, 'customized.dat');
+
+my %customised;
+
+my $regen = 0;
+
+while (@ARGV && substr($ARGV[0], 0, 1) eq '-') {
+ my $arg = shift @ARGV;
+
+ $arg =~ s/^--/-/; # Treat '--' the same as a single '-'
+ if ($arg eq '-regen') {
+ $regen = 1;
+ }
+ else {
+ die <<EOF;
+Unknown option '$arg'
+
+Usage: $0 [ --regen ]\n"
+ --regen -> Regenerate the data file for $0
+
+EOF
+ }
+}
+
+my $data_fh;
+
+if ( $regen ) {
+ open $data_fh, '>:bytes', $customised or die "Can't open $customised";
+}
+else {
+ open $data_fh, '<:bytes', $customised or die "Can't open $customised";
+ while (<$data_fh>) {
+ chomp;
+ my ($module,$file,$sha) = split ' ';
+ $customised{ $module }->{ $file } = $sha;
+ }
+ close $data_fh;
+}
+
+foreach my $module ( keys %Modules ) {
+ next unless my $files = $Modules{ $module }{CUSTOMIZED};
+ my @perl_files = my_get_module_files( $module );
+ foreach my $file ( @perl_files ) {
+ my $digest = Digest->new( $digest_type );
+ {
+ open my $fh, '<', $file or die "Can't open $file";
+ binmode $fh;
+ $digest->addfile( $fh );
+ close $fh;
+ }
+ my $id = $digest->hexdigest;
+ if ( $regen ) {
+ print $data_fh join(' ', $module, $file, $id), "\n";
+ next;
+ }
+ my $should_be = $customised{ $module }->{ $file };
+ if ( $id ne $should_be ) {
+ print "not ok ".++$TestCounter." - SHA for $file does not match stashed SHA\n";
+ }
+ else {
+ print "ok ".++$TestCounter." - SHA for $file matched\n";
+ }
+ }
+}
+
+if ( $regen ) {
+ print "ok ".++$TestCounter." - regenerated data file\n";
+ close $data_fh;
+}
+
+print "1..".$TestCounter."\n";
+
+=pod
+
+=head1 NAME
+
+customized.t - Test that CUSTOMIZED files in Maintainers.pl have not been overwritten
+
+=head1 SYNOPSIS
+
+ cd t
+ ./perl -I../lib porting/customized.t --regen
+
+=head1 DESCRIPTION
+
+customized.t checks that files listed in C<Maintainers.pl> that have been C<CUSTOMIZED>
+are not accidently overwritten by CPAN module updates.
+
+=head1 OPTIONS
+
+=over
+
+=item C<--regen>
+
+Use this command line option to regenerate the C<customized.dat> file.
+
+=back
+
+=cut