6 # Setting $strict to 1 enables line number checks, setting it to 2 makes
7 # line number mismatches fatal.
10 my $mcs = (defined $ENV{MCS}) ? $ENV{MCS} : 'mcs';
12 unless ($#ARGV == 0) {
13 print STDERR "Usage: $0 testcase.cs\n";
21 my $filename = $ARGV [0];
26 open (INPUT, "<$filename") or die
27 "Can't open testcase: $!";
28 while (defined ($input = <INPUT>)) {
31 next unless $input =~ m,^\s*//\s*(error|warning)?\s*(CS\d+),;
33 if ((defined $1) and ($1 eq 'warning')) {
43 open (MCS, "$mcs $filename|") or die
44 "Can't open mcs pipe: $!";
46 while (defined ($input = <MCS>)) {
48 next unless $input =~ m,\((\d+)\)\s+(warning|error)\s+(CS\d+):,;
50 if ($2 eq 'warning') {
58 if (!defined $lines{$1}) {
59 print "Didn't expect any warnings or errors in line $1, but got $2 $3.\n";
60 $failures++ if $strict == 2;
61 } elsif ($lines{$1} ne $3) {
62 print "Expected to find ".$lines{$1}." on line $1, but got $3.\n";
63 $failures++ if $strict == 2;
69 foreach my $error (keys %errors) {
70 my $times = $errors{$error};
73 print "Unexpected error $error.\n";
74 } elsif ($times < 0) {
75 print "Unexpected error $error (reported ".(-$times)." times).\n";
76 } elsif ($times == 1) {
77 print "Failed to report error $error.\n";
78 } elsif ($times > 0) {
79 print "Failed to report error $error $times times.\n";
82 $failures++ unless $times == 0;
85 foreach my $warning (keys %warnings) {
86 my $times = $warnings{$warning};
89 print "Unexpected warning $warning.\n";
90 } elsif ($times < 0) {
91 print "Unexpected warning $warning (reported ".(-$times)." times).\n";
92 } elsif ($times == 1) {
93 print "Failed to report warning $warning.\n";
94 } elsif ($times > 0) {
95 print "Failed to report warning $warning $times times.\n";
98 $failures++ unless $times == 0;
101 if ($failures == 0) {