Ticket #834: testing-of-exit-code.patch

File testing-of-exit-code.patch, 1.8 KB (added by eirik, 12 years ago)
  • lib/Parrot/Test.pm

    commit cd1657df2c8ed88873200cf90b5b334cad865e40
    Author: Eirik A. Nygaard <eirikald@pvv.ntnu.no>
    Date:   Mon Aug 17 08:33:49 2009 +0200
    
        Add testing of exit codes. Enable it for pir tests.
    
    diff --git a/lib/Parrot/Test.pm b/lib/Parrot/Test.pm
    index f04d29a..5624fa9 100644
    a b  
    582582    if ( $func =~ m/^pir_.*?output/ ) { 
    583583        $code_f = per_test( '.pir', $test_no ); 
    584584    } 
     585    elsif ( $func =~ m/^pir_exit_code_/ ) { 
     586        $code_f = per_test( '.pir', $test_no ); 
     587    } 
    585588    elsif ( $func =~ m/^pasm_.*?output_/ ) { 
    586589        $code_f = per_test( '.pasm', $test_no ); 
    587590    } 
     
    684687    my %parrot_test_map = map { 
    685688        $_ . '_output_is'           => 'is_eq', 
    686689        $_ . '_error_output_is'     => 'is_eq', 
     690        $_ . '_exit_code_is'        => 'is_eq', 
    687691        $_ . '_output_isnt'         => 'isnt_eq', 
    688692        $_ . '_error_output_isnt'   => 'isnt_eq', 
    689693        $_ . '_output_like'         => 'like', 
     
    723727                \$extra{todo} 
    724728                if defined $extra{todo}; 
    725729 
     730            if ( $func =~ /_exit_code_is$/ ) { 
     731                $expected = int($expected); 
     732                if ($exit_code == $expected) { 
     733                    my $pass = $builder->$meth( $exit_code, $expected, $desc ); 
     734                    return $pass; 
     735                } 
     736                else { 
     737                    $builder->diag("\nExited with error code: $exit_code, expected: $expected.\n"); 
     738                    return 0; 
     739                } 
     740            } 
     741 
    726742            if ( $func =~ /_error_/ ) { 
    727743                return _handle_error_output( $builder, $real_output, $expected, $desc ) 
    728744                    unless $exit_code;