| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$path and not -f $path
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
| |||||||||||||||||||||||||||||
| 49 | 0 | $path; | |||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($abs_executable) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( -x $abs_executable || IS_WIN ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
-x $abs_executable or !!0
MC/DC0%0/1
-x $abs_executable or !!0
-x $abs_executable
Truth table0%0/2
A
A= -x $abs_executable
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||