X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/cd9a17141adacfdd66e379334b50b7516d4f2cec..3d6de2cd13dfe0ce6162563bc69ff8f6329e8664:/Porting/sync-with-cpan diff --git a/Porting/sync-with-cpan b/Porting/sync-with-cpan index fc65150..d0cc1d6 100755 --- a/Porting/sync-with-cpan +++ b/Porting/sync-with-cpan @@ -130,6 +130,7 @@ use Getopt::Long; use Archive::Tar; use File::Path qw( remove_tree ); use File::Find; +use Config qw( %Config ); $| = 1; @@ -156,12 +157,20 @@ my @problematic = ( ); +sub usage +{ + my $err = shift and select STDERR; + print "Usage: $0 module [args] [cpan package]\n"; + exit $err; +} + GetOptions ('tarball=s' => \my $tarball, 'version=s' => \my $version, - force => \my $force,) - or die "Failed to parse arguments"; + force => \my $force, + help => sub { usage 0; }, + ) or die "Failed to parse arguments"; -die "Usage: $0 module [args] [cpan package]" unless @ARGV == 1 || @ARGV == 2; +usage 1 unless @ARGV == 1 || @ARGV == 2; sub find_type_f { my @res; @@ -184,6 +193,16 @@ sub de_exec { } sub make { + my @args= @_; + if( $^O eq 'MSWin32') { + chdir "Win32"; + system "$Config{make} @args> ..\\make.log 2>&1" and die "Running make failed, see make.log"; + chdir '..'; + } else { + system "$Config{make} @args> make.log 2>&1" and die "Running make failed, see make.log"; + }; +}; + my ($module) = shift; my $cpan_mod = @ARGV ? shift : $module; @@ -207,7 +226,7 @@ chdir "cpan"; my $pkg_dir = $files[0]; $pkg_dir =~ s!.*/!!; -my ($old_version) = $distribution =~ /-([0-9.]+)\.tar\.gz/; +my ($old_version) = $distribution =~ /-([0-9.]+(?:-TRIAL[0-9]*)?)\.tar\.gz/; my $o_module = $module; if ($cpan_mod =~ /-/ && $cpan_mod !~ /::/) { @@ -232,9 +251,9 @@ unless ($tarball) { } or system wget => $package_url, '-qO', $package_file; } - my $new_line = `grep '^$cpan_mod ' $package_file` + open my $fh, '<', $package_file; + (my $new_line) = grep {/^$cpan_mod/} <$fh> # Yes, this needs a lot of memory or die "Cannot find $cpan_mod on CPAN\n"; - chomp $new_line; (undef, $new_version, my $new_path) = split ' ', $new_line; if (defined $version) { $new_path =~ s/-$new_version\./-$version\./; @@ -256,7 +275,7 @@ unless ($tarball) { } else { $new_file = $tarball; - $new_version = $version // ($new_file =~ /-([0-9._]+)\.tar\.gz/) [0]; + $new_version = $version // ($new_file =~ /-([0-9._]+(?:-TRIAL[0-9]*)?)\.tar\.gz/) [0]; } my $old_dir = "$pkg_dir-$old_version"; @@ -433,7 +452,8 @@ if (@commit) { print "Running a make ... "; -system "$Config{make} > make.log 2>&1" and die "Running make failed, see make.log"; +# Prepare for running (selected) tests +make 'test-prep'; print "done\n"; # @@ -445,7 +465,6 @@ print "About to clean up; hit return or abort (^C) "; ; remove_tree( "cpan/$old_dir" ); unlink "cpan/$new_file" unless $tarball; - # # Run the tests. First the test belonging to the module, followed by the # the tests in t/porting @@ -465,7 +484,9 @@ my @tests = glob 'porting/*.t'; chomp @tests; my @failed; foreach my $t (@tests) { - my @not = `./perl -I../lib -I.. $t | grep ^not | grep -v "# TODO"`; + my @not = grep {!/# TODO/ } + grep { /^not/ } + `${exe_dir}perl -I../lib -I.. $t`; print @not ? '!' : '.'; push @failed => $t if @not; }