File: Test.pm

package info (click to toggle)
libvcflib 1.0.0~rc1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 46,836 kB
  • ctags: 1,488
  • sloc: cpp: 27,298; makefile: 177; ansic: 139; python: 46; perl: 26; sh: 19
file content (32 lines) | stat: -rw-r--r-- 858 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
use strict;
use warnings;

package Local::vcflib::Test;
use base 'Exporter';

use File::Basename qw< dirname >;
use IPC::Run3 qw< run3 >;
use Test::More;

our @EXPORT = qw( run run_ok );
our $BIN    = dirname(__FILE__) . "/../../../../bin";

sub run {
    my ($run, $stdin)    = @_;
    my ($command, @opts) = @$run;
    run3(["$BIN/$command", @opts], \$stdin, \(my $stdout), \(my $stderr));
    return ($stdout, $stderr, $?);
}

sub run_ok {
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    my ($stdout, $stderr, $exit) = run(@_);
    ok $exit >> 8 == 0, "exit code"
        or diag "error running command: " . join(" ", @{$_[0]}) . "\n"
               ."with input:\n$_[1]\n--\n"
               ."exit code = " . ($exit >> 8) . " (system() return value = $exit)\n"
               ."stderr = \n$stderr";
    return ($stdout, $stderr);
}

1;