Selenium/CanStartBinary/FindBinary.pm

filter: Statementstmt 50.0% 25 / 50 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 2 totaltotal 38.5% 32 / 83 CC 9 SCAR 27.4
CC
9
Cov
37%
_validate_manual_binary
42.0
coerce_simple_binary
6.0
coerce_firefox_binary
6.0
CRAP 15.5
« Test/Selenium/Remote/Driver.pm ↑ Summary Selenium/Remote/Spec.pm »
1 package Selenium::CanStartBinary::FindBinary;
2 10 $Selenium::CanStartBinary::FindBinary::VERSION = '1.50';
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Coercions for finding webdriver binaries on your system
7 10 ▶use Cwd qw/abs_path/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use File::Which qw/which/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Selenium::Firefox::Binary qw/firefox_path/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 10 require Exporter;
13 10 our @ISA = qw/Exporter/;
14 10 our @EXPORT_OK = qw/coerce_simple_binary coerce_firefox_binary/;
15  
16 10 ▶use constant IS_WIN => $^O eq 'MSWin32';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 0 ▶sub coerce_simple_binary {
Subroutine coerce_simple_binary: not called CC=2 SCAR=17.9
Pod undocumented
20 0 my ($executable) = @_;
21  
22 0 my $manual_binary = _validate_manual_binary($executable);
23 0 ▶ if ($manual_binary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($manual_binary) { } 0 0 0
24 0 return $manual_binary;
25 }
26 else {
27 0 return _naive_find_binary($executable);
28 }
29 }
30  
31 0 ▶sub coerce_firefox_binary {
Subroutine coerce_firefox_binary: not called CC=2 SCAR=17.9
Pod undocumented
32 0 my ($executable) = @_;
33  
34 0 my $manual_binary = _validate_manual_binary($executable);
35 0 ▶ if ($manual_binary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($manual_binary) { } 0 0 0
36 0 return $manual_binary;
37 }
38 else {
39 0 return firefox_path();
40 }
41 }
42  
43 0 ▶sub _validate_manual_binary {
Subroutine _validate_manual_binary: not called CC=6 SCAR=37.4
44 0 my ($executable) = @_;
45  
46 0 my $abs_executable = eval {
47 0 my $path = abs_path($executable);
48 0 ▶ die if $path && !-f $path;
Branch: 1 branch
BranchTrueFalseTotal
if $path and not -f $path 0 0 0
Condition0%0/3
$path and not -f $path
!ll&&!rl&&r
000
MC/DC0%0/2
$path and not -f $path
$path not -f $path
Truth table0%0/3
A and not(B)
A= $pathB= not -f $path
ABresult
0X0
100
111
49 0 $path;
50 };
51  
52 0 ▶ if ($abs_executable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($abs_executable) 0 0 0
53 0 ▶ if ( -x $abs_executable || IS_WIN ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-x $abs_executable or 0) { } 0 0 0
Condition0%0/2
-x $abs_executable or !!0
l!l
00
MC/DC0%0/1
-x $abs_executable or !!0
-x $abs_executable
Truth table0%0/2
A
A= -x $abs_executable
Aresult
11
00
54 0 return $abs_executable;
55 }
56 else {
57 0 die 'The binary at '
58 . $executable
59 . ' is not executable. Choose the correct file or chmod +x it as needed.';
60 }
61 }
62 }
63  
64 0 ▶sub _naive_find_binary {
Subroutine _naive_find_binary: not called CC=2 SCAR=17.9
65 0 my ($executable) = @_;
66  
67 0 my $naive_binary = which($executable);
68 0 ▶ if ( defined $naive_binary ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $naive_binary) { } 0 0 0
69 0 return $naive_binary;
70 }
71 else {
72 0 warn qq(Unable to find the $executable binary in your \$PATH.);
73 0 return;
74 }
75 }
76  
77 __END__
« Test/Selenium/Remote/Driver.pm ↑ Summary Selenium/Remote/Spec.pm »