Skip to content

Commit 7df6220

Browse files
committed
add test
1 parent 6d84ad8 commit 7df6220

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

lib/Test2/Require/ProgramInPath.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ the reason why the test was skipped. Currently `This test only runs if $program
3030
3131
=cut
3232

33-
use File::Which qw( which );
33+
use File::Which ();
3434
use Carp qw( confess );
3535
use parent qw( Test2::Require );
3636

3737
sub skip ( $, $program = undef ) {
3838
confess "no program specified" unless defined $program;
39-
return undef if which $program;
39+
return undef if File::Which::which $program;
4040
return "This test only runs if $program is in the PATH";
4141
}
4242
}

t/test2_require_programinpath.t

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
use Test2::V0 -no_srand => 1;
22
use Test2::Require::ProgramInPath ();
33

4-
ok 1, 'todo';
4+
subtest 'skip' => sub {
5+
6+
plan 2;
7+
8+
local *File::Which::which = sub {
9+
is(\@_, ['foo']);
10+
return undef;
11+
};
12+
13+
is(
14+
Test2::Require::ProgramInPath->skip('foo'),
15+
'This test only runs if foo is in the PATH',
16+
);
17+
18+
};
19+
20+
subtest 'no skip' => sub {
21+
22+
plan 2;
23+
24+
local *File::Which::which = sub {
25+
is(\@_, ['foo']);
26+
return '/bin/foo';
27+
};
28+
29+
is(
30+
Test2::Require::ProgramInPath->skip('foo'),
31+
U(),
32+
);
33+
34+
};
535

636
done_testing;

0 commit comments

Comments
 (0)