@@ -35,7 +35,7 @@ subtest 'process basic functions' => sub {
3535 $p -> start();
3636 $p -> stop();
3737 };
38- ok $@ , " Error expected" ;
38+ ok $@ , " Error expected" ;
3939 like $@ , qr / Nothing to do/ ,
4040 " Process with no code nor execute command, will fail" ;
4141
@@ -88,8 +88,8 @@ subtest 'process is_running()' => sub {
8888
8989 close (PARENT);
9090 chomp @output ;
91- is $output [0], " FOOBARFTW" , ' right output from process' ;
92- is $p -> is_running, 0, " Process now is stopped" ;
91+ is $output [0], " FOOBARFTW" , ' right output from process' ;
92+ is $p -> is_running, 0, " Process now is stopped" ;
9393
9494 # Redefine new code and restart it.
9595 pipe (PARENT, CHILD);
@@ -106,8 +106,8 @@ subtest 'process is_running()' => sub {
106106 @output = scalar <PARENT>;
107107 $p -> stop();
108108 chomp @output ;
109- is $output [0], " FOOBAZFTW" , ' right output from process' ;
110- is $p -> is_running, 0, " Process now is not running" ;
109+ is $output [0], " FOOBAZFTW" , ' right output from process' ;
110+ is $p -> is_running, 0, " Process now is not running" ;
111111 @output = (' ' );
112112
113113 pipe (PARENT, CHILD);
@@ -146,7 +146,7 @@ subtest 'process execute()' => sub {
146146 )-> start();
147147 is $p -> getline, " TEST normal print\n " , ' Get right output from stdout' ;
148148 is $p -> err_getline, " TEST error print\n " , ' Get right output from stderr' ;
149- is $p -> is_running, 1, ' process is still waiting for our input' ;
149+ is $p -> is_running, 1, ' process is still waiting for our input' ;
150150 $p -> write (" FOOBAR" );
151151 is $p -> read , " you entered FOOBAR\n " ,
152152 ' process received input and printed it back' ;
@@ -163,7 +163,7 @@ subtest 'process execute()' => sub {
163163 ])-> start();
164164 is $p -> stdout, " TEST normal print\n " , ' Get right output from stdout' ;
165165 is $p -> err_getline, " TEST error print\n " , ' Get right output from stderr' ;
166- is $p -> is_running, 1, ' process is still waiting for our input' ;
166+ is $p -> is_running, 1, ' process is still waiting for our input' ;
167167 $p -> write (" FOOBAR" );
168168 is $p -> getline, " you entered FOOBAR\n " ,
169169 ' process received input and printed it back' ;
@@ -178,7 +178,7 @@ subtest 'process execute()' => sub {
178178 )-> args([qw( FOO BAZ) ])-> start();
179179 is $p -> stdout, " TEST normal print\n " , ' Get right output from stdout' ;
180180 is $p -> err_getline, " TEST error print\n " , ' Get right output from stderr' ;
181- is $p -> is_running, 1, ' process is still waiting for our input' ;
181+ is $p -> is_running, 1, ' process is still waiting for our input' ;
182182 $p -> write (" FOOBAR" );
183183 is $p -> getline, " you entered FOOBAR\n " ,
184184 ' process received input and printed it back' ;
@@ -224,8 +224,8 @@ subtest 'process execute()' => sub {
224224 ); # ;)
225225 $p -> start();
226226 $p -> stop();
227- is $p -> is_running, 1, ' process is still running' ;
228- is $p -> _status, undef , ' no status yet' ;
227+ is $p -> is_running, 1, ' process is still running' ;
228+ is $p -> _status, undef , ' no status yet' ;
229229 my $err = ${(@{$p -> error})[0]};
230230 my $exp = qr / Could not kill process/ ;
231231 like $err , $exp , ' Error is not empty if process could not be killed' ;
@@ -266,8 +266,8 @@ subtest 'process execute()' => sub {
266266 pidfile => $pidfile
267267 )-> start();
268268 my $pid = path($pidfile )-> slurp();
269- is -e $pidfile , 1, ' Pidfile is there!' ;
270- is $pid , $p -> pid, " Pidfile was correctly written" ;
269+ is -e $pidfile , 1, ' Pidfile is there!' ;
270+ is $pid , $p -> pid, " Pidfile was correctly written" ;
271271 $p -> stop();
272272 is -e $pidfile , undef , ' Pidfile got removed after stop()' ;
273273
@@ -283,8 +283,8 @@ subtest 'process execute()' => sub {
283283 )-> start();
284284 $p -> write_pidfile($pidfile );
285285 $pid = path($pidfile )-> slurp();
286- is -e $pidfile , 1, ' Pidfile is there!' ;
287- is $pid , $p -> pid, " Pidfile was correctly written" ;
286+ is -e $pidfile , 1, ' Pidfile is there!' ;
287+ is $pid , $p -> pid, " Pidfile was correctly written" ;
288288 $p -> stop();
289289 is -e $pidfile , undef , ' Pidfile got removed after stop()' ;
290290
@@ -304,7 +304,12 @@ subtest 'process execute()' => sub {
304304subtest ' process(execute =>"/usr/bin/true")' => sub {
305305 plan skip_all => " Missing '/usr/bin/true'" unless -e ' /usr/bin/true' ;
306306
307- is(process(execute => ' /usr/bin/true' )-> quirkiness(1)-> start()-> wait_stop()-> exit_status(), 0, ' Simple exec of "/usr/bin/true" return 0' );
307+ is(
308+ process(execute => ' /usr/bin/true' )-> quirkiness(1)-> start()-> wait_stop()
309+ -> exit_status(),
310+ 0,
311+ ' Simple exec of "/usr/bin/true" return 0'
312+ );
308313};
309314
310315subtest ' process code()' => sub {
@@ -464,7 +469,7 @@ subtest 'process code()' => sub {
464469 $p -> write (" a" );
465470 $p -> wait_stop();
466471 like $p -> stderr_all, qr / TEST error print/ , ' read all from stderr works' ;
467- is $p -> read_all, ' ' , ' stdout is empty' ;
472+ is $p -> read_all, ' ' , ' stdout is empty' ;
468473};
469474
470475subtest stop_whole_process_group_gracefully => sub {
@@ -546,46 +551,65 @@ process';
546551
547552subtest ' process_args' => sub {
548553 my $code = sub {
549- shift ;
550- print $_ . $/ for ( @_ ) ;
554+ shift ;
555+ print " $_$/ " for @_ ;
551556 };
552557
553- my $p = Mojo::IOLoop::ReadWriteProcess-> new($code , args => ' 0' )-> start-> wait_stop();
558+ my $p = Mojo::IOLoop::ReadWriteProcess-> new($code , args => ' 0' )
559+ -> start-> wait_stop();
554560 is($p -> read_all_stdout(), " 0$/ " , ' 1) False scalar value was given as args.' );
555561
556- $p = Mojo::IOLoop::ReadWriteProcess-> new($code )-> args(' 0' )-> start-> wait_stop();
562+ $p
563+ = Mojo::IOLoop::ReadWriteProcess-> new($code )-> args(' 0' )-> start-> wait_stop();
557564 is($p -> read_all_stdout(), " 0$/ " , ' 2) False scalar value was given as args.' );
558565
559- $p = Mojo::IOLoop::ReadWriteProcess-> new($code , args => [(0..3)] )-> start-> wait_stop();
566+ $p = Mojo::IOLoop::ReadWriteProcess-> new($code , args => [(0 .. 3)])
567+ -> start-> wait_stop();
560568 is($p -> read_all_stdout(), " 0$/1$/2$/3$/ " , ' 1) Args given as arrayref.' );
561569
562- $p = Mojo::IOLoop::ReadWriteProcess-> new($code )-> args([(0..3)])-> start-> wait_stop();
570+ $p = Mojo::IOLoop::ReadWriteProcess-> new($code )-> args([(0 .. 3)])
571+ -> start-> wait_stop();
563572 is($p -> read_all_stdout(), " 0$/1$/2$/3$/ " , ' 2) Args given as arrayref.' );
564573};
565574
566575subtest ' process in process' => sub {
567- my $p = process(sub {
568- is( process(execute => ' /usr/bin/true' )-> quirkiness(1)-> start()-> wait_stop()-> exit_status(), 0, ' process(execute) from process(code) -- retval check true' );
569- is( process(execute => ' /usr/bin/false' )-> quirkiness(1)-> start()-> wait_stop()-> exit_status(), 1, ' process(execute) from process(code) -- retval check false' );
570- is( process(sub { print ' sub-sub-process' })-> start()-> wait_stop()-> read_all_stdout, ' sub-sub-process' , ' process(code) works from process(code)' );
571- print ' DONE' ;
576+ my $p = process(
577+ sub {
578+ is(
579+ process(execute => ' /usr/bin/true' )-> quirkiness(1)-> start()
580+ -> wait_stop()-> exit_status(),
581+ 0,
582+ ' process(execute) from process(code) -- retval check true'
583+ );
584+ is(
585+ process(execute => ' /usr/bin/false' )-> quirkiness(1)-> start()
586+ -> wait_stop()-> exit_status(),
587+ 1,
588+ ' process(execute) from process(code) -- retval check false'
589+ );
590+ is(
591+ process(sub { print ' sub-sub-process' })-> start()-> wait_stop()
592+ -> read_all_stdout,
593+ ' sub-sub-process' ,
594+ ' process(code) works from process(code)'
595+ );
596+ print ' DONE' ;
572597 })-> start()-> wait_stop();
573598
574- is ($p -> read_all_stdout(), ' DONE' , " Use ReadWriteProcess inside of ReadWriteProcess(code=>'')" );
599+ is($p -> read_all_stdout(), ' DONE' ,
600+ " Use ReadWriteProcess inside of ReadWriteProcess(code=>'')" );
575601};
576602
577603subtest ' execute exeption handling' => sub {
578- throws_ok {
579- process(execute => ' /I/do/not/exist' )-> start()-> wait_stop()-> exit_status();
580- } qr % /I/do/not/exist% , ' Execute throw exception, if executable does not exists' ;
581-
582- my $p = process(execute => ' sleep 0.2' )-> start();
583- attempt {
584- attempts => 20,
585- condition => sub { defined ($p -> exit_status)},
586- };
587- is ($p -> is_running(), 0, ' Process not running' );
588- is ($p -> exit_status(), 0, ' Exit status is 0' );
604+ throws_ok {
605+ process(execute => ' /I/do/not/exist' )-> start()-> wait_stop()-> exit_status();
606+ }
607+ qr % /I/do/not/exist% , ' Execute throw exception, if executable does not exists' ;
608+
609+ my $p = process(execute => ' sleep 0.2' )-> start();
610+ attempt {attempts => 20, condition => sub { defined ($p -> exit_status) },};
611+ is($p -> is_running(), 0, ' Process not running' );
612+ is($p -> exit_status(), 0, ' Exit status is 0' );
589613};
590614
591615done_testing;
0 commit comments