Re: [PATCH] t0004: replace test -e with test_path_exists
- From
Jeff King <peff@peff.net>
- Date
- Mar 9, 2026, 22:47 UTC
- Message-ID
- <20260309224739.GA5682@coredump.intra.peff.net>
- In-Reply-To
- <xmqq4imo4sf1.fsf@gitster.g>
On Mon, Mar 09, 2026 at 02:14:10PM -0700, Junio C Hamano wrote:
Show 17 quoted lines
> PRASHANT S BISHT <prashantjee2025@gmail.com> writes: > > > -test_lazy_prereq WRITE_TREE_OUT 'test -e "$TRASH_DIRECTORY"/out.write-tree' > > +test_lazy_prereq WRITE_TREE_OUT 'test_path_exists "$TRASH_DIRECTORY/out.write-tree"' > > I suspect this is utterly wrong. As you wrote in the proposed log > message, test_path_exists is *NOT* about checking if the path > exists. It rather is about *expecting* for the path to exist, and > fail *LOUDLY* if it does not. > > You need to _think_ if we want a LOUD failure when somebody checks > if a path exists and conditionally skip setting a test prerequisite > when the path does not exist. The original code is trying to be > quiet, as the check is done not because existence of the checked > path is good and lack of it is a test failure. Lack of the path is > expected on places where the prerequisite is not set, and that by > itself is not a test failure that you want a LOUD report about.
I'm not sure I agree. Verbose prereq blocks can help with debugging. Normally you would not see them at all, but if you are investigating why a prereq did not trigger, you may want more output.
Without "-v" you would not see the output either way, like:
ok 1 # skip some test (missing FOO)
But with it, it is the difference between:
checking prerequisite: FOO mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-FOO" && ( cd "$TRASH_DIRECTORY/prereq-test-dir-FOO" && test -e foo ) prerequisite FOO not satisfied ok 1 # skip some test (missing FOO)
and:
checking prerequisite: FOO mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-FOO" && ( cd "$TRASH_DIRECTORY/prereq-test-dir-FOO" && test_path_exists foo ) Path foo doesn't exist prerequisite FOO not satisfied ok 1 # skip some test (missing FOO)
Probably it's pretty obvious for a one-liner like this, but I think it would help for a longer block.
-Peff