File: utils.pl

package info (click to toggle)
libpar-packer-perl 1.063-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,380 kB
  • sloc: perl: 12,859; ansic: 1,486; makefile: 30; sh: 5
file content (55 lines) | stat: -rw-r--r-- 1,145 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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Config;
use File::Spec::Functions;
use File::Temp qw( tempdir );
use Cwd;
use IPC::Run3;

# use an absolute pathname in case a test chdir()s
my $pp = catfile(getcwd(), qw( blib script pp ));
$pp = '/usr/bin/pp' if $ENV{AUTOPKGTEST_TMP};

my $xid = 0;

# runs 1 test
sub pp_ok
{
    $ENV{PAR_TMPDIR} ||= tempdir(TMPDIR => 1, CLEANUP => 1);
    my $exe = catfile($ENV{PAR_TMPDIR}, sprintf("pp%03d%s", $xid++, $Config{_exe}));
    unlink($exe);

    die "system(LIST) with double quotes in LIST doesn't work on Windows: @_"
        if grep { /"/ } @_;

    # Note: The test harness runs tests 
    # with PERL5LIB prepended as if "-Mblib" was in effect
    system($^X, $pp, -o => $exe, @_);

    # Note: -x is unreliable on Windows
    ok( $? == 0 && -f $exe, qq[successfully packed "$exe"] );

    return $exe;
}

# runs 1 test
sub run_ok
{
    my @cmd = @_;

    my ($out, $err);
    run3(\@cmd, \undef, \$out, \$err);
    if (is( $?, 0, qq[successfully ran "@cmd"] )) {
        return ($out, $err);
    } else {
        diag("OUT:\n$out\nERR:\n$err");
        return;
    }
}


1;