commit cd1657df2c8ed88873200cf90b5b334cad865e40 Author: Eirik A. Nygaard 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/lib/Parrot/Test.pm +++ b/lib/Parrot/Test.pm @@ -582,6 +582,9 @@ sub _run_test_file { if ( $func =~ m/^pir_.*?output/ ) { $code_f = per_test( '.pir', $test_no ); } + elsif ( $func =~ m/^pir_exit_code_/ ) { + $code_f = per_test( '.pir', $test_no ); + } elsif ( $func =~ m/^pasm_.*?output_/ ) { $code_f = per_test( '.pasm', $test_no ); } @@ -684,6 +687,7 @@ sub _generate_test_functions { my %parrot_test_map = map { $_ . '_output_is' => 'is_eq', $_ . '_error_output_is' => 'is_eq', + $_ . '_exit_code_is' => 'is_eq', $_ . '_output_isnt' => 'isnt_eq', $_ . '_error_output_isnt' => 'isnt_eq', $_ . '_output_like' => 'like', @@ -723,6 +727,18 @@ sub _generate_test_functions { \$extra{todo} if defined $extra{todo}; + if ( $func =~ /_exit_code_is$/ ) { + $expected = int($expected); + if ($exit_code == $expected) { + my $pass = $builder->$meth( $exit_code, $expected, $desc ); + return $pass; + } + else { + $builder->diag("\nExited with error code: $exit_code, expected: $expected.\n"); + return 0; + } + } + if ( $func =~ /_error_/ ) { return _handle_error_output( $builder, $real_output, $expected, $desc ) unless $exit_code;