File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -486,6 +486,47 @@ sub time_command {
486
486
return \@times ;
487
487
}
488
488
489
+ sub diagnose_capture {
490
+ my ($out , $err , $status , $expected ) = @_ ;
491
+
492
+ my $failed = 0;
493
+ my $reason = ' ' ;
494
+
495
+ if ($out =~ / Segmentation/i || $err =~ / Segmentation/i ) {
496
+ $failed = 1;
497
+ $reason = ' segfaulted' ;
498
+ }
499
+ elsif ($status ) {
500
+ $failed = 1;
501
+ if ($status < 0) {
502
+ $reason = ' failed to spawn' ;
503
+ }
504
+ elsif (my $signal = $status & 127) {
505
+ $reason = " received signal $signal " ;
506
+
507
+ # Handle SIGINT specially as it indicates user intervention
508
+ if ($signal == 2) {
509
+ $failed = -1;
510
+ $reason = ' terminated by SIGINT' ;
511
+ }
512
+ }
513
+ else {
514
+ my $exit = $status >> 8;
515
+ $reason = " exited with exit status $exit " ;
516
+ }
517
+ }
518
+ elsif (length $err ) {
519
+ $failed = 1;
520
+ $reason = ' wrote to STDERR' ;
521
+ }
522
+ elsif (defined $expected && $expected ne $out ) {
523
+ $failed = 1;
524
+ $reason = ' did not produce expected output' ;
525
+ }
526
+
527
+ return ($failed , $reason );
528
+ }
529
+
489
530
sub min_by (&@) {
490
531
my $code = shift ;
491
532
You can’t perform that action at this time.
0 commit comments