Re: [PATCH 2/2] t/Makefile: get UNIT_TESTS list from C sources
- From
Adam Dinwoodie <adam@dinwoodie.org>
- Date
- Jan 29, 2024, 21:31 UTC
- Message-ID
- <CA+kUOanDydgCEax9RFu_xVXkx_LeiSPOoWiUpwAg=EVQxSDJRw@mail.gmail.com>
- In-Reply-To
- <20240129174918.GA3765717@coredump.intra.peff.net>
On Mon, 29 Jan 2024 at 17:49, Jeff King wrote:
Show 15 quoted lines
> > On Mon, Jan 29, 2024 at 12:26:42PM +0100, Patrick Steinhardt wrote: > > > > -UNIT_TESTS = $(sort $(filter-out %.pdb unit-tests/bin/t-basic%,$(wildcard unit-tests/bin/t-*))) > > > +UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c) > > > +UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%,$(UNIT_TEST_SOURCES)) > > > +UNIT_TESTS = $(sort $(filter-out unit-tests/bin/t-basic%,$(UNIT_TEST_PROGRAMS))) > > > > Wouldn't we have to honor `$X` on Windows systems so that the unit tests > > have the expected ".exe" suffix here? > > Hmm, good point. It seems like the answer should obviously be "yes", but > Windows CI seemed to pass all the same (and I checked that it indeed ran > the unit tests). Do we only get the $X suffix for MSVC builds or > something? Looks like maybe cygwin, as well.
Cygwin will automatically append ".exe" when doing directory listings; a check if the file "a" exists will return true on Cygwin if "a" or "a.exe" exists; a glob for "a*" in a directory containing files "a1" and "a2.exe" will return "a1" and "a2". This causes problems in some edge cases, but it means *nix scripts and applications are much more likely to work without any Cygwin-specific handling. I *think* this logic is carried downstream to MSYS2 and thence to Git for Windows.
As a result, I'm not surprised this worked without handling $X, but I don't think there's any harm in adding it either.