Ticket #279: tt279-makefiles-error.patch

File tt279-makefiles-error.patch, 3.9 KB (added by rurban, 13 years ago)
  • lib/Parrot/Configure/Compiler.pm

     
    3434    move_if_diff 
    3535); 
    3636 
     37# report the makefile and lineno 
     38sub makecroak { 
     39    my ($conf, $error) = @_; 
     40    my ($file, $line) = ($conf->{_compiler_file}, $conf->{_compiler_line}); 
     41    die "$error at $file line $line\n"; 
     42} 
     43 
    3744our %file_types_info = ( 
    3845    makefile => { 
    3946        comment_type    => '#', 
     
    396403    # this loop can not be implemented as a foreach loop as the body 
    397404    # is dependent on <IN> being evaluated lazily 
    398405 
     406    $conf->{_compiler_file} = $source; 
    399407    my $former_truth = -1; 
    400408  LINE: 
    401409    while ( my $line = <$in> ) { 
     410        $conf->{_compiler_line} = $.; 
    402411 
    403412        # everything after the line starting with #perl is eval'ed 
    404413        if ( $line =~ /^#perl/ && $options{feature_file} ) { 
     
    413422            # interpolate @foo@ values 
    414423            $text =~ s{ \@ (\w+) \@ }{\$conf->data->get("$1")}gx; 
    415424            eval $text; 
    416             die $@ if $@; 
     425            croak $@ if $@; 
    417426            last LINE; 
    418427        } 
    419428        if ( $options{conditioned_lines} ) { 
     
    531540 
    532541        if ( $options{replace_slashes} ) { 
    533542            if ( $line =~ m{/$} ) { 
    534                 die "$source:$.: line ends in a slash\n"; 
     543                croak "$source:$.: line ends in a slash\n"; 
    535544            } 
    536545 
    537546            $line =~ s{(/+)}{ 
     
    651660                    $op = 'NOT'; 
    652661                } 
    653662                else { 
    654                     die "invalid op \"$op\" in \"$_[1]\" at \"$prevexpr\".\n"; 
     663                    makecroak($conf, "invalid op \"$op\" in \"$_[1]\" at \"$prevexpr\""); 
    655664                } 
    656665                $key = next_expr($expr); 
    657666            } 
    658667            elsif ($prevexpr) { 
    659                 die "Makefile conditional syntax error: missing op in \"$_[1]\" at \"$prevexpr\".\n"; 
     668                makecroak($conf, "Makefile conditional syntax error: missing op in \"$_[1]\" at \"$prevexpr\""); 
    660669            } 
    661670            else { 
    662671                last LOOP; # end of expr, nothing left 
    663672            } 
    664673            if ($prevexpr eq $expr) { 
    665                 die "Makefile conditional parser error in \"$_[1]\" at \"$prevexpr\".\n"; 
     674                makecroak($conf, "Makefile conditional parser error in \"$_[1]\" at \"$prevexpr\""); 
    666675            } 
    667676        } 
    668677        return $truth; 
  • t/steps/gen_makefiles-01.t

     
    7676       ["INVERSE_CONDITIONED_LINE(false)",  1], 
    7777      ); 
    7878} 
    79 use Test::More tests => (7 + scalar(@cond_tests)); 
     79use Test::More tests => (8 + scalar(@cond_tests)); 
    8080use Carp; 
    8181use lib qw( . lib ); 
    8282use_ok('config::gen::makefiles'); 
     
    140140    local $/; 
    141141    $f = <OUT>; 
    142142} 
    143 END { 
    144     unlink "Makefile_$$.in", "Makefile_$$.out"; 
    145 } 
    146143$index = undef; 
    147144for my $c (@cond_tests) { 
    148145    my $result = result($c); 
     
    155152    } 
    156153} 
    157154 
     155# TT #279: reporting the makefile line number 
     156# step gen::makefiles died during execution: 
     157#  invalid op "IF" in "#IF(bla)" at "(bla)" at Configure.pl line 72 
     158open IN, ">", "Makefile_$$.in"; 
     159print IN "# Test reporting sourcefile line numbers. TT #279\n"; 
     160print IN "#IF(IF(bla)):test\n"; 
     161close IN; 
     162eval { 
     163    $conf->genfile("Makefile_$$.in", "Makefile_$$.out", 
     164                   (makefile => 1, conditioned_lines => 1)); 
     165}; 
     166my $error = $@; 
     167ok($error eq "invalid op \"bla\" in \"IF(bla)\" at \"(bla)\" at Makefile_$$.in line 2\n", 
     168   "report correct error line"); 
     169 
    158170pass("Completed all tests in $0"); 
     171END { 
     172    unlink "Makefile_$$.in", "Makefile_$$.out"; 
     173} 
    159174 
    160175################### DOCUMENTATION ################### 
    161176 
     
    176191=head1 AUTHOR 
    177192 
    178193James E Keenan 
     194Reini Urban 
    179195 
    180196=head1 SEE ALSO 
    181197