| 1 | package Selenium::CanStartBinary::FindBinary; | ||||||||||||||||||||||||||||
| 2 | 10 | $Selenium::CanStartBinary::FindBinary::VERSION = '1.49'; | |||||||||||||||||||||||||||
| 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 | sub coerce_simple_binary { | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my ($executable) = @_; | ||||||||||||||||||||||||||
|
Subroutine
coerce_simple_binary: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 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 | sub coerce_firefox_binary { | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($executable) = @_; | ||||||||||||||||||||||||||
|
Subroutine
coerce_firefox_binary: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 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 | sub _validate_manual_binary { | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my ($executable) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_manual_binary: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 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 | sub _naive_find_binary { | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my ($executable) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_naive_find_binary: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =pod | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head1 NAME | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Selenium::CanStartBinary::FindBinary - Coercions for finding webdriver binaries on your system | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head1 VERSION | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | version 1.49 | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =for Pod::Coverage *EVERYTHING* | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Current Maintainers: | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =over 4 | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =item * | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | George S. Baugh <george@troglodyne.net> | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =back | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Previous maintainers: | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =over 4 | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =item * | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | Daniel Gempesaw <gempesaw@gmail.com> | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =item * | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Emmanuel Peroumalnaïk <peroumalnaik.emmanuel@gmail.com> | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =item * | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | Luke Closs <cpan@5thplane.com> | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =item * | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | Mark Stosberg <mark@stosberg.com> | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =back | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | Original authors: | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =over 4 | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =item * | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | Aditya Ivaturi <ivaturi@gmail.com> | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =back | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Copyright (c) 2014-2017 Daniel Gempesaw | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | Copyright (c) 2018-2021 George S. Baugh | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||
| 146 | you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||
| 147 | You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 152 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 153 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| 154 | See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| 155 | limitations under the License. | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||