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

Re: [PATCH 1/1] tests: Allow customization of how say_color() prints

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Dec 17, 2012, 22:31 UTC
Message-ID
<50CF9D4C.9080706@ramsay1.demon.co.uk>
In-Reply-To
<7vobhuqzdc.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 43 quoted lines
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> 
>> diff --git a/t/test-lib.sh b/t/test-lib.sh
>> index f50f834..9dcf3c1 100644
>> --- a/t/test-lib.sh
>> +++ b/t/test-lib.sh
>> @@ -202,6 +202,15 @@ do
>>  	esac
>>  done
>>  
>> +if test -z "$GIT_TEST_PRINT"
>> +then
>> +	GIT_TEST_PRINT="printf %s"
>> +fi
>> +if test -z "$GIT_TEST_PRINT_LN"
>> +then
>> +	GIT_TEST_PRINT_LN="printf %s\n"
>> +fi
>> +
>>  if test -n "$color"
>>  then
>>  	say_color () {
>> @@ -221,7 +230,7 @@ then
>>  			test -n "$quiet" && return;;
>>  		esac
>>  		shift
>> -		printf "%s" "$*"
>> +		$GIT_TEST_PRINT "$*"
>>  		tput sgr0
>>  		echo
>>  		)
>> @@ -230,7 +239,7 @@ else
>>  	say_color() {
>>  		test -z "$1" && test -n "$quiet" && return
>>  		shift
>> -		printf "%s\n" "$*"
>> +		$GIT_TEST_PRINT_LN "$*"
>>  	}
>>  fi
> 
> As you said, this is ugly and also unwieldy in that I do not see an
> easy way for a platform/builder to define something that needs to
> pass a parameter with $IFS in it in these two variables.

Yes, I spent 10 minutes trying to decide if I should send this patch at all ... (ie how much public humiliation could I take :-D )

> Why does your printf die in the first place???

I really don't know. I'm not sure I will ever know. A couple of years ago, when I was trying to debug the (harmless) "--color" spew, I found (via google, etc) numerous accounts of similar problems, with various workarounds for specific problems. One such account claimed that the cause of the problem was an official "fix" from Microsoft (as part of a service pack) which worked just fine on Windows Vista (and later) but had this known side-effect on XP. Since it fixed the problem it was intended to fix, even on XP, and the unfortunate "side-effect" on XP should be quite rare, they decided to apply it on XP anyway. :(

Hmm, on reflection, it would probably be best if you just drop this patch. I can keep it locally and apply it on top of any branch I want to test. (Actually, it would be easier to simply revert commit 7bc0911d.)

Sorry for wasting your time.

ATB, Ramsay Jones

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “tests: Allow customization of how say_color() prints”
  1. 1/1 tests: Allow customization of how say_color() printsRamsay Jones, Dec 15, 2012
  2. Junio C HamanoDec 16, 2012
  3. Ramsay JonesDec 17, 2012
  4. Junio C HamanoDec 18, 2012

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.