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

Re: [PATCH] Make test script annotate-tests.sh handle missing authors

From
Kevin Ballard <kevin@sb.org>
Date
Oct 16, 2010, 10:43 UTC
Message-ID
<09193539-B5AD-4574-9FE4-983566A34355@sb.org>
In-Reply-To
<m3sk06617a.fsf@localhost.localdomain>
On Oct 16, 2010, at 12:34 AM, Jakub Narebski wrote:
Show 23 quoted lines
> Kevin Ballard <kevin@sb.org> writes:
> 
>> Also, I'm not a Perl programmer, so it's possible there's a better idiom
>> for this sort of thing.
>> 
>> t/annotate-tests.sh |    3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>> 
>> diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
>> index 396b965..4e37a66 100644
>> --- a/t/annotate-tests.sh
>> +++ b/t/annotate-tests.sh
>> @@ -9,6 +9,9 @@ check_count () {
>> 	cat .result | perl -e '
>> 		my %expect = (@ARGV);
>> 		my %count = ();
>> +		while (my ($author, $count) = each %expect) {
>> +			$count{$author} = 0;
>> +		}
> 
> 
> First, it is a very bad practice to have variables of different type
> named the same way, here %count (hash) and $count (scalar, unused).
Thanks for the pointer, but $count is already used in the while loop below:
		while (my ($author, $count) = each %count) {
			my $ok;
			if ($expect{$author} != $count) {
				$bad = 1;
				$ok = "bad";
			}
			else {
				$ok = "good";
			}
			print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
		}
I'll go and change the one in my new while loop though, to use the Perl idiom way you listed below.
> Perl idiom way would be
> 
>  -		my %count = ();
>  +		my %count = map { $_ => 0 } keys %expect;
-Kevin Ballard
Previous: Jakub NarebskiNext: Kevin Ballard
Message 3 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.