File: bogus.t

package info (click to toggle)
libipc-run-perl 0.80-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 452 kB
  • ctags: 186
  • sloc: perl: 5,317; makefile: 44
file content (67 lines) | stat: -rwxr-xr-x 1,409 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
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl -w

=head1 NAME

bogus.t - test bogus file cases.

=cut

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


use strict ;

use Test ;

use IPC::Run qw( start ) ;
use UNIVERSAL qw( isa ) ;

my $r ;

sub Win32_MODE() ;
*Win32_MODE = \&IPC::Run::Win32_MODE ;

## Win32 does not support a lot of things that Unix does.  These
## skip_unless subs help that.
##
## TODO: There are also a few things that Win32 supports (passing Win32 OS
## handles) that we should test for, conversely.
sub skip_unless_exec(&) {
   if ( Win32_MODE ) {
      return sub {
         skip "Can't really exec() $^O", 0 ;
      } ;
   }
   shift ;
}

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

skip_unless_exec {
   ## 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 : $@ || "" ;
   ok $got, $expected, "starting $^X with simulated_exec_failure => 1" ;
},

) ;

plan tests => scalar @tests ;

$_->() for ( @tests ) ;