Debian Codegraph @

dev-bin/update-copied-tests

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use autodie qw( :all );
6
7 use 5.01000;
8
9 use File::Find::Rule;
10 use File::pushd;
11 use File::Temp qw( tempdir );
12 use Path::Class qw( file );
13
14 my $branch = shift || 'master';
15
16 my $tempdir = tempdir( CLEANUP => 1 );
17
18 {
19 my $dir = pushd($tempdir);
20
21 system(
22 'git', 'clone',
23 '--branch', $branch,
24 'https://github.com/houseabsolute/List-SomeUtils.git',
25 'pp'
26 );
27 }
28
29 my $t_root = "$tempdir/pp/t";
30
31 for my $file ( map { file($_) }
32 File::Find::Rule->name(qr/\.(?:t|pm)$/)->in($t_root) ) {
33
34 my $to_file = file( 't', $file =~ s{^\Q$t_root\E/}{}r );
35
36 $to_file->dir->mkpath( 0, 0755 );
37
38 my $content = $file->slurp;
39 next if $content =~ /^\# PP only/;
40 $content =~ s/PP/XS/;
41
42 if ( $file =~ /\.t/ ) {
43 my $guard = <<'EOF';
44 use Test::More 0.96;
45
46 BEGIN {
47 eval 'require List::SomeUtils';
48 if ($@) {
49 plan skip_all => 'These tests require that List::SomeUtils already be installed';
50 }
51 }
52 EOF
53
54 $content =~ s/(BEGIN .+?\n)/$guard$1/;
55 }
56
57 $to_file->spew($content);
58 }