File: tester-exit.t

package info (click to toggle)
libapp-cmd-perl 0.338-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 516 kB
  • sloc: perl: 1,727; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 707 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
#!perl
use strict;
use warnings;

use Test::More tests => 3;

use Capture::Tiny 'capture';
use File::Spec;

require App::Cmd::Tester; # not used, but check which!

my $helper_fn = $0;
$helper_fn =~ s{\.t$}{.helper.pl} or die "Can't make helper from $0";

for my $exit_with (0, 5) {
  my ($stdout, $stderr, $got_exit) = capture {
    system(
      $^X,
      (-d 'blib' ? '-Mblib' : ('-I', File::Spec->rel2abs('lib'))),
      $helper_fn, $exit_with);
  };

  chomp $stdout;
  is($stdout, $INC{'App/Cmd/Tester.pm'}, "App::Cmd::Tester source path")
    unless $exit_with; # just once

  is($exit_with,
     $got_exit / 256, # yes it could be fractional, and that would be fail
     "exit code as expected");
}