Re: [PATCH 2/3] test: improve rebase -q test
From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:57:40
On Mon, Jun 10, 2013 at 09:07:06PM +0200, Johannes Sixt wrote:
Am 10.06.2013 19:27, schrieb SZEDER Gábor:quoted
My main motivation is that, like in your example, in the bash prompt tests I only have to check a single line of output, but because of debuggability I always did: echo "(master)" >expected __git_ps1 >actual test_cmp expected actualChained by &&, I presume.
Sure.
quoted
With such a helper function this could be reduced to a single line: test_string_equal "(master)" "$(__git_ps1)" without loss of functionalityNot quite: A non-zero exit code of the $(__git_ps1) is lost. (It probably doesn't matter here, but it certainly does if the command is $(git rev-parse foo) or similar.)
Ouch, indeed. Yeah, the exit code doesn't matter for the prompt tests (I mean for __git_ps1() tests, but maybe it does matter for some __gitdir() tests), but I suppose it does matter everywhere else where the same construct is used. We could still do actual="$(git foo)" && test_string_equal "good" "$actual" to preserve and check the exit code, and this is still one line shorter, but overall not that appealing anymore. However. The git command's exit code is lost the same way in 'test good = $(git foo)' constructs, too, and plenty of such constructs are all over the test suite. Shouldn't we avoid using such constucts then? Gábor