@matheusbsbs / matheus-bagliano / commits / 27eea66b28
Fork 0

Update test script annotate-tests.sh to handle missing/extra authors

The current script used by annotate-tests.sh (used by t8001 and t8002) fails to emit a warning if any of the expected authors never show up in the output or if authors that show up in the output were never specified as expected. Update the script to fail in both of these scenarios. Helped-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Kevin Ballard <kevin@sb.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kevin Ballard committed Oct 16, 2010 at 04:09 UTC 27eea66b28e15890ae587303c1c316388845169e
1 file changed +6 -6
t/annotate-tests.sh
+6 -6
@@ -8,27 +8,27 @@ check_count () {
8 $PROG file $head >.result || return 1
9 cat .result | perl -e '
10 my %expect = (@ARGV);
11 - my %count = ();
11 + my %count = map { $_ => 0 } keys %expect;
12 while (<STDIN>) {
13 if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
14 my $author = $1;
15 for ($author) { s/^\s*//; s/\s*$//; }
16 - if (exists $expect{$author}) {
17 - $count{$author}++;
18 - }
16 + $count{$author}++;
17 }
18 }
19 my $bad = 0;
20 while (my ($author, $count) = each %count) {
21 my $ok;
24 - if ($expect{$author} != $count) {
22 + my $value = 0;
23 + $value = $expect{$author} if defined $expect{$author};
24 + if ($value != $count) {
25 $bad = 1;
26 $ok = "bad";
27 }
28 else {
29 $ok = "good";
30 }
31 - print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
31 + print STDERR "Author $author (expected $value, attributed $count) $ok\n";
32 }
33 exit($bad);
34 ' "$@"