Re: [PATCH] t7500: fix tests with absolute path following ":(optional)" on Windows
From: Junio C Hamano <hidden>
Date: 2025-10-20 18:06:22
Johannes Sixt [off-list ref] writes:
Am 20.10.25 um 15:43 schrieb Ben Knoble:quoted
Going forward I will probably stick with using pwd, given the difference in platform behavior.$(pwd) is usually safe, but not always. If we have to look at every instance anyway, we can use $PWD for efficiency if it does not matter, and $(pwd) only when it is necessary.quoted
Is there a doc or test lint for that? If not, might be useful.If this were documented somewhere, would you have found it and obeyed the recommendations?
I myself forget about it every time, even after getting bitten at least 3 times in the past, maybe more. t/README has this. - When a test checks for an absolute path that a git command generated, construct the expected value using $(pwd) rather than $PWD, $TEST_DIRECTORY, or $TRASH_DIRECTORY. It makes a difference on Windows, where the shell (MSYS bash) mangles absolute path names. For details, see the commit message of 4114156ae9. It is mentioned in t/README, I know it is mentioned in t/README, and I did re-read the part of t/README, every time I needed to decide between $PWD and $(pwd), but I still got it wrong 50% of the time X-<.