Re: [PATCH v3 1/9] t5520: fixup file contents comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Tan <pyokagan@xxxxxxxxx> writes:

> Hi Junio,
>
> On Fri, May 15, 2015 at 1:44 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> Change that 'verbose test' line to
>>
>>         verbose test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
>>
>> i.e. losing the double-quotes around $().
>
> Noted and fixed. Interesting quirk though :-).
>
>> By the way, thanks for a fine demonstration that the 'verbose test'
>> is not very useful.
>>
>> This output
>>
>>> command failed:  'test' '1' '=' '       1'
>
> Personally, I find that the quoting provided by "verbose" helps make
> it clear that it's a whitespace issue, which might be a bit harder to
> spot with the output of set -x I think.

To be fair, yes, because of the leading SP in the RHS, I immediately
knew that this was a "wc -l" from that without running the test one
more time with "-i -v -x".  The "rev-parse --sq-quote" did help.
Without the --sq-quote trick, i.e. "command failed: test 1 = 1",
would actually make the debugger suspect that there would be a
quoting issue anyway, so it is not a very big deal, though.

In any case, that "test 1 = 1" (with or without quoting) helped only
because I had to deal with "wc -l" issues in the past.  Without
telling how that ' 1' ended up compared with '1' by showing "wc -l"
on that 'command failed:' line, it wouldn't have helped much if the
debugger were not me.

> Other than that, I'm also convinced that "verbose" doesn't really
> offer much. Will remove in the re-roll.

Just to avoid misunderstanding, please do not remove 'verbose '
blindly without thinking while doing so, as you already did 1/3 of
the necessary job to make things better.

You might have noticed, while adding them, there were something
common that we currently do with a bare 'test' only because we
haven't identified common needs.  As I already said, it may be that
we often try to see a file has a known single line content (I didn't
check if that were the case; I am just giving you an example) and
only because there is no ready-made test_file_contents helper to be
used, the current tests say

	test expected_string = "$(cat file)"

And if that were the case, it is a good thing to have a new helper
like this

	test_file_contents () {
		if test "$(cat "$1")" != "$2"
		then
			echo "Contents of file '$1' is not '$2'"
                        false
		fi
	}

in t/test-lib-functions.sh and convert them to say

	test_file_contents file expected_string

That would be an improvement (and that is the remaining 2/3 ;-).

Thanks.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]