Re: [PATCH v9 3/8] t2400: refactor "worktree add" opt exclusion tests
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 17, 2023, 21:30 UTC
- Message-ID
- <xmqqmt36jixr.fsf@gitster.g>
- In-Reply-To
- <20230417093255.31079-4-jacobabel@nullpo.dev>
Jacob Abel <jacobabel@nullpo.dev> writes:
> +# Helper function to test mutually exclusive options. > +# > +# Note: Quoted arguments containing spaces are not supported.
Good to have this note here.
> +test_wt_add_excl () {
> + local opts="$*" &&
> + test_expect_success "'worktree add' with '$opts' has mutually exclusive options" '
> + test_when_finished cat actual >&2 &&Again, I do not think this sends output to the standard output at the end of this test piece.
> + test_must_fail git worktree add $opts 2>actual && > + grep -E "fatal:( options)? .* cannot be used together" actual > + ' > +}
I do not think this patch is needed (I'd rather see people learn the trick of running with "-i" and rely on the fact that the trash directory is left intact to be inspected), but if you must, it may make more sense to add test_must_contain to make a failed 'grep "$@"' easier to see, similar to the way that test_must_be_empty helps a failing 'test ! -s "$1"', something along the lines of ...
test_must_contain () {
if ! grep "$@"
then
echo "'grep $*' fails; the file contains"
while test $# != 1
do
shift
done
cat "$1"
return 1
fi
}Thanks.