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
1616
1717use Carp;
1818use Data::Dump ' pp' ;
19+ use Feature::Compat::Try;
1920use IPC::Run qw( start) ;
2021use Mojo::IOLoop::Server;
2122use Mojo::Server::Daemon;
@@ -24,6 +25,7 @@ use OpenQA::WebAPI;
2425use OpenQA::Log ' log_info' ;
2526use OpenQA::Utils;
2627use OpenQA::Test::Utils qw( wait_for) ;
28+
2729use POSIX ' _exit' ;
2830
2931our $_driver;
@@ -49,7 +51,7 @@ sub disable_timeout () {
4951
5052sub start_driver ($mojoport ) {
5153 # Connect to it
52- eval {
54+ try {
5355 # enforce the JSON Wire protocol (instead of using W3C WebDriver protocol)
5456 # note: This is required with Selenium::Remote::Driver 1.36 which would now use W3C mode leading
5557 # to errors like "unknown command: unknown command: Cannot call non W3C standard command while
@@ -97,8 +99,8 @@ sub start_driver ($mojoport) {
9799 $_driver-> set_window_size(600, 800);
98100 $_driver-> get(" http://localhost:$mojoport /" );
99101
100- };
101- die $@ if ( $@ );
102+ }
103+ catch ( $e ) { die $e }
102104
103105 return $_driver;
104106}
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ use Mojo::IOLoop::ReadWriteProcess 'process';
3232use Mojo::Server::Daemon;
3333use Mojo::IOLoop::Server;
3434use Test::MockModule;
35+ use Feature::Compat::Try;
3536use Time::HiRes ' sleep' ;
3637
3738BEGIN {
@@ -595,8 +596,10 @@ sub mock_io_loop (%args) {
595596 my $io_loop_mock = Test::MockModule-> new(' Mojo::IOLoop' );
596597 $io_loop_mock -> redefine( # avoid forking to prevent coverage analysis from slowing down the test significantly
597598 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 }
600603 $io_loop -> next_tick(sub { $callback -> (undef , $error , @result ) });
601604 }) if $args {subprocess };
602605 return $io_loop_mock ;
You can’t perform that action at this time.
0 commit comments