File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ our @EXPORT = qw(driver_missing check_driver_modules enable_timeout
16
16
17
17
use Carp;
18
18
use Data::Dump ' pp' ;
19
+ use Feature::Compat::Try;
19
20
use IPC::Run qw( start) ;
20
21
use Mojo::IOLoop::Server;
21
22
use Mojo::Server::Daemon;
@@ -24,6 +25,7 @@ use OpenQA::WebAPI;
24
25
use OpenQA::Log ' log_info' ;
25
26
use OpenQA::Utils;
26
27
use OpenQA::Test::Utils qw( wait_for) ;
28
+
27
29
use POSIX ' _exit' ;
28
30
29
31
our $_driver;
@@ -49,7 +51,7 @@ sub disable_timeout () {
49
51
50
52
sub start_driver ($mojoport ) {
51
53
# Connect to it
52
- eval {
54
+ try {
53
55
# enforce the JSON Wire protocol (instead of using W3C WebDriver protocol)
54
56
# note: This is required with Selenium::Remote::Driver 1.36 which would now use W3C mode leading
55
57
# to errors like "unknown command: unknown command: Cannot call non W3C standard command while
@@ -97,8 +99,8 @@ sub start_driver ($mojoport) {
97
99
$_driver-> set_window_size(600, 800);
98
100
$_driver-> get(" http://localhost:$mojoport /" );
99
101
100
- };
101
- die $@ if ( $@ );
102
+ }
103
+ catch ( $e ) { die $e }
102
104
103
105
return $_driver;
104
106
}
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ use Mojo::IOLoop::ReadWriteProcess 'process';
32
32
use Mojo::Server::Daemon;
33
33
use Mojo::IOLoop::Server;
34
34
use Test::MockModule;
35
+ use Feature::Compat::Try;
35
36
use Time::HiRes ' sleep' ;
36
37
37
38
BEGIN {
@@ -595,8 +596,10 @@ sub mock_io_loop (%args) {
595
596
my $io_loop_mock = Test::MockModule-> new(' Mojo::IOLoop' );
596
597
$io_loop_mock -> redefine( # avoid forking to prevent coverage analysis from slowing down the test significantly
597
598
subprocess => sub ($io_loop , $function , $callback ) {
598
- my @result = eval { $function -> () };
599
- my $error = $@ ;
599
+ my @result ;
600
+ my $error ;
601
+ try { @result = $function -> () }
602
+ catch ($e ) { $error = $e }
600
603
$io_loop -> next_tick(sub { $callback -> (undef , $error , @result ) });
601
604
}) if $args {subprocess };
602
605
return $io_loop_mock ;
You can’t perform that action at this time.
0 commit comments