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::Copy qw( copy );
10 use File::Find::Rule;
11 use File::pushd;
12 use File::Temp qw( tempdir );
13 use Path::Class qw( file );
14
15 my $branch = shift || 'main';
16
17 my $tempdir = tempdir( CLEANUP => 1 );
18
19 {
20 my $dir = pushd($tempdir);
21
22 system(
23 'git', 'clone',
24 '--branch', $branch,
25 'git://github.com/maxmind/MaxMind-DB-Reader-perl.git',
26 'pp'
27 );
28 }
29
30 my $t_root = "$tempdir/pp/t";
31
32 for my $file ( File::Find::Rule->name(qr/\.t$/)->in($t_root) ) {
33 open my $fh, '<', $file;
34 my $first_line = <$fh>;
35
36 next if $first_line =~ /^\# PP only/;
37
38 my $to_file = file( 't', $file =~ s{^\Q$t_root\E/}{}r );
39
40 $to_file->dir()->mkpath( 0, 0755 );
41 copy( $file => $to_file );
42 }