git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] Update test script annotate-tests.sh to handle missing/extra authors

From
Kevin Ballard <kevin@sb.org>
Date
Oct 16, 2010, 11:09 UTC
Message-ID
<1287227360-2610-1-git-send-email-kevin@sb.org>
In-Reply-To
<09193539-B5AD-4574-9FE4-983566A34355@sb.org>

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>
---
 t/annotate-tests.sh |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 396b965..141b60c 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -8,27 +8,27 @@ check_count () {
 	$PROG file $head >.result || return 1
 	cat .result | perl -e '
 		my %expect = (@ARGV);
-		my %count = ();
+		my %count = map { $_ => 0 } keys %expect;
 		while (<STDIN>) {
 			if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
 				my $author = $1;
 				for ($author) { s/^\s*//; s/\s*$//; }
-				if (exists $expect{$author}) {
-					$count{$author}++;
-				}
+				$count{$author}++;
 			}
 		}
 		my $bad = 0;
 		while (my ($author, $count) = each %count) {
 			my $ok;
-			if ($expect{$author} != $count) {
+			my $value = 0;
+			$value = $expect{$author} if defined $expect{$author};
+			if ($value != $count) {
 				$bad = 1;
 				$ok = "bad";
 			}
 			else {
 				$ok = "good";
 			}
-			print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
+			print STDERR "Author $author (expected $value, attributed $count) $ok\n";
 		}
 		exit($bad);
 	' "$@"
-- 
1.7.3.1.208.g53ea2
Previous: Kevin BallardNext: Jakub Narebski
Message 4 of 5 in “Make test script annotate-tests.sh handle missing authors”
  1. Make test script annotate-tests.sh handle missing authorsKevin Ballard, Oct 16, 2010
  2. Jakub NarebskiOct 16, 2010
  3. Kevin BallardOct 16, 2010
  4. Update test script annotate-tests.sh to handle missing/extra authorsKevin Ballard, Oct 16, 2010
  5. Jakub NarebskiOct 16, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.