summaryrefslogtreecommitdiff
path: root/test/errchk
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-08-16 11:14:26 -0400
committerRuss Cox <rsc@golang.org>2011-08-16 11:14:26 -0400
commit7a251687c029ee915573f767f57ab17372b3c134 (patch)
tree9c51f39075a2500498a8e73a399c95b141a6205d /test/errchk
parent8a6ab1ccb1aaf1d5d69fbe6bce24139458da6122 (diff)
downloadgo-7a251687c029ee915573f767f57ab17372b3c134.tar.gz
errchk: allow multiple patterns
// ERROR "pattern1" "pattern2" means that there has to be one or more lines matching pattern1 and then excluding those, there have to be one or more lines matching pattern2. So if you expect two different error messages from a particular line, writing two separate patterns checks that both errors are produced. Also, errchk now flags lines that produce more errors than expected. Before, as long as at least one error matched the pattern, all the others were ignored. Revise tests to expect or silence these additional errors. R=lvd, r, iant CC=golang-dev http://codereview.appspot.com/4869044
Diffstat (limited to 'test/errchk')
-rwxr-xr-xtest/errchk49
1 files changed, 27 insertions, 22 deletions
diff --git a/test/errchk b/test/errchk
index 8fdf77a30..6b00570bd 100755
--- a/test/errchk
+++ b/test/errchk
@@ -88,41 +88,46 @@ sub chk {
$line++;
next if $src =~ m|////|; # double comment disables ERROR
next unless $src =~ m|// (GC_)?ERROR (.*)|;
- $regexp = $2;
- if($regexp !~ /^"([^"]*)"/) {
+ my $all = $2;
+ if($all !~ /^"([^"]*)"/) {
print STDERR "$file:$line: malformed regexp\n";
next;
}
- $regexp = $1;
-
- # Turn relative line number in message into absolute line number.
- if($regexp =~ /LINE(([+-])([0-9]+))?/) {
- my $n = $line;
- if(defined($1)) {
- if($2 eq "+") {
- $n += int($3);
- } else {
- $n -= int($3);
- }
- }
- $regexp = "$`$file:$n$'";
- }
-
@errmsg = grep { /$file:$line[:[]/ } @out;
@out = grep { !/$file:$line[:[]/ } @out;
if(@errmsg == 0) {
bug();
- print STDERR "errchk: $file:$line: missing expected error: '$regexp'\n";
+ print STDERR "errchk: $file:$line: missing expected error: '$all'\n";
next;
}
- @match = grep { /$regexp/ } @errmsg;
- if(@match == 0) {
+ foreach my $regexp ($all =~ /"([^"]*)"/g) {
+ # Turn relative line number in message into absolute line number.
+ if($regexp =~ /LINE(([+-])([0-9]+))?/) {
+ my $n = $line;
+ if(defined($1)) {
+ if($2 eq "+") {
+ $n += int($3);
+ } else {
+ $n -= int($3);
+ }
+ }
+ $regexp = "$`$file:$n$'";
+ }
+
+ @match = grep { /$regexp/ } @errmsg;
+ if(@match == 0) {
+ bug();
+ print STDERR "errchk: $file:$line: error messages do not match '$regexp'\n";
+ next;
+ }
+ @errmsg = grep { !/$regexp/ } @errmsg;
+ }
+ if(@errmsg != 0) {
bug();
- print STDERR "errchk: $file:$line: error message does not match '$regexp'\n";
+ print STDERR "errchk: $file:$line: unmatched error messages:\n";
foreach my $l (@errmsg) {
print STDERR "> $l";
}
- next;
}
}
}