-
Notifications
You must be signed in to change notification settings - Fork 8
/
10test-options.t
executable file
·57 lines (45 loc) · 1.31 KB
/
10test-options.t
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
#!/usr/bin/env perl
use strict; use warnings;
use English qw( -no_match_vars );
use rlib '../lib';
use Test::More;
note( "Testing Devel::Trepan::Options" );
if( $Test::More::VERSION >= 1.0 ) {
plan skip_all => "Test::More::VERSION >= 1.0 causes weird problems";
}
BEGIN {
use_ok( 'Devel::Trepan::Options' );
}
import Devel::Trepan::Options;
note 'Test whence_file';
for my $not_found_program
(qw(./bogus/program ../bogus/program /bogus/program)) {
is(whence_file($not_found_program), $not_found_program,
"when program ${not_found_program} is not found, it is unchanged");
}
my $perl = ($OSNAME eq 'MSWin32') ? 'perl.exe' : 'perl';
isnt(whence_file($perl), $perl,
"We should be able to find perl in your path");
is(whence_file($EXECUTABLE_NAME), $EXECUTABLE_NAME,
"Perl binary ${EXECUTABLE_NAME} is generally absolute and should be unchanged");
note 'Test get_options';
my $pid = fork();
if ($pid == 0) {
my @argv = qw(--version);
my $opts = process_options(\@argv);
exit 0;
} else {
waitpid($pid, 0);
isnt($?>>8, 0);
}
note 'Test --batch option';
$pid = fork();
if ($pid == 0) {
my @argv = ('--batch', __FILE__);
my $opts = process_options(\@argv);
($opts->{batchfile} eq __FILE__) ? exit 0 : exit 10;
} else {
waitpid($pid, 0);
is($?>>8, 0);
}
done_testing();