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
34 34 move_if_diff 35 35 ); 36 36 37 # report the makefile and lineno 38 sub 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 37 44 our %file_types_info = ( 38 45 makefile => { 39 46 comment_type => '#', … … 396 403 # this loop can not be implemented as a foreach loop as the body 397 404 # is dependent on <IN> being evaluated lazily 398 405 406 $conf->{_compiler_file} = $source; 399 407 my $former_truth = -1; 400 408 LINE: 401 409 while ( my $line = <$in> ) { 410 $conf->{_compiler_line} = $.; 402 411 403 412 # everything after the line starting with #perl is eval'ed 404 413 if ( $line =~ /^#perl/ && $options{feature_file} ) { … … 413 422 # interpolate @foo@ values 414 423 $text =~ s{ \@ (\w+) \@ }{\$conf->data->get("$1")}gx; 415 424 eval $text; 416 die$@ if $@;425 croak $@ if $@; 417 426 last LINE; 418 427 } 419 428 if ( $options{conditioned_lines} ) { … … 531 540 532 541 if ( $options{replace_slashes} ) { 533 542 if ( $line =~ m{/$} ) { 534 die"$source:$.: line ends in a slash\n";543 croak "$source:$.: line ends in a slash\n"; 535 544 } 536 545 537 546 $line =~ s{(/+)}{ … … 651 660 $op = 'NOT'; 652 661 } 653 662 else { 654 die "invalid op \"$op\" in \"$_[1]\" at \"$prevexpr\".\n";663 makecroak($conf, "invalid op \"$op\" in \"$_[1]\" at \"$prevexpr\""); 655 664 } 656 665 $key = next_expr($expr); 657 666 } 658 667 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\""); 660 669 } 661 670 else { 662 671 last LOOP; # end of expr, nothing left 663 672 } 664 673 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\""); 666 675 } 667 676 } 668 677 return $truth; -
t/steps/gen_makefiles-01.t
76 76 ["INVERSE_CONDITIONED_LINE(false)", 1], 77 77 ); 78 78 } 79 use Test::More tests => ( 7+ scalar(@cond_tests));79 use Test::More tests => (8 + scalar(@cond_tests)); 80 80 use Carp; 81 81 use lib qw( . lib ); 82 82 use_ok('config::gen::makefiles'); … … 140 140 local $/; 141 141 $f = <OUT>; 142 142 } 143 END {144 unlink "Makefile_$$.in", "Makefile_$$.out";145 }146 143 $index = undef; 147 144 for my $c (@cond_tests) { 148 145 my $result = result($c); … … 155 152 } 156 153 } 157 154 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 158 open IN, ">", "Makefile_$$.in"; 159 print IN "# Test reporting sourcefile line numbers. TT #279\n"; 160 print IN "#IF(IF(bla)):test\n"; 161 close IN; 162 eval { 163 $conf->genfile("Makefile_$$.in", "Makefile_$$.out", 164 (makefile => 1, conditioned_lines => 1)); 165 }; 166 my $error = $@; 167 ok($error eq "invalid op \"bla\" in \"IF(bla)\" at \"(bla)\" at Makefile_$$.in line 2\n", 168 "report correct error line"); 169 158 170 pass("Completed all tests in $0"); 171 END { 172 unlink "Makefile_$$.in", "Makefile_$$.out"; 173 } 159 174 160 175 ################### DOCUMENTATION ################### 161 176 … … 176 191 =head1 AUTHOR 177 192 178 193 James E Keenan 194 Reini Urban 179 195 180 196 =head1 SEE ALSO 181 197