File: update-copied-tests

package info (click to toggle)
liblist-someutils-xs-perl 0.58-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 588 kB
  • sloc: perl: 1,954; ansic: 130; makefile: 3
file content (58 lines) | stat: -rwxr-xr-x 1,097 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl

use strict;
use warnings;
use autodie qw( :all );

use 5.01000;

use File::Find::Rule;
use File::pushd;
use File::Temp qw( tempdir );
use Path::Class qw( file );

my $branch = shift || 'master';

my $tempdir = tempdir( CLEANUP => 1 );

{
    my $dir = pushd($tempdir);

    system(
        'git',      'clone',
        '--branch', $branch,
        'https://github.com/houseabsolute/List-SomeUtils.git',
        'pp'
    );
}

my $t_root = "$tempdir/pp/t";

for my $file ( map { file($_) }
    File::Find::Rule->name(qr/\.(?:t|pm)$/)->in($t_root) ) {

    my $to_file = file( 't', $file =~ s{^\Q$t_root\E/}{}r );

    $to_file->dir->mkpath( 0, 0755 );

    my $content = $file->slurp;
    next if $content =~ /^\# PP only/;
    $content =~ s/PP/XS/;

    if ( $file =~ /\.t/ ) {
        my $guard = <<'EOF';
use Test::More 0.96;

BEGIN {
    eval 'require List::SomeUtils';
    if ($@) {
        plan skip_all => 'These tests require that List::SomeUtils already be installed';
    }
}
EOF

        $content =~ s/(BEGIN .+?\n)/$guard$1/;
    }

    $to_file->spew($content);
}