File: bogus.t

package info (click to toggle)
libipc-run-perl 20231003.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 844 kB
  • sloc: perl: 6,255; makefile: 5
file content (45 lines) | stat: -rw-r--r-- 1,021 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
#!/usr/bin/perl

=pod

=head1 NAME

bogus.t - test bogus file cases.

=cut

use strict;
use warnings;

BEGIN {
    $|  = 1;
    $^W = 1;
    if ( $ENV{PERL_CORE} ) {
        chdir '../lib/IPC/Run' if -d '../lib/IPC/Run';
        unshift @INC, 'lib', '../..';
        $^X = '../../../t/' . $^X;
    }
}

use Test::More tests => 2;
use IPC::Run qw( start );

SCOPE: {
    ## Older Test.pm's don't grok qr// in $expected.
    my $expected = 'file not found';
    eval { start ["./bogus_really_bogus"] };
    my $got = $@ =~ $expected ? $expected : $@ || "";
    is( $got, $expected, "starting ./bogus_really_bogus" );
}

SKIP: {
    if ( IPC::Run::Win32_MODE() ) {
        skip "Can't really exec() $^O", 1;
    }

    ## Older Test.pm's don't grok qr// in $expected.
    my $expected = 'exec failed';
    my $h        = eval { start( [ $^X, "-e", 1 ], _simulate_exec_failure => 1 ); };
    my $got      = $@ =~ $expected ? $expected : $@ || "";
    is( $got, $expected, "starting $^X with simulated_exec_failure => 1" );
}