Re: [PATCH 6/9] cmake: use GIT_TEST_BUILD_DIR instead of editing hack
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Oct 25, 2022, 13:29 UTC
- Message-ID
- <c3d27586-f5b5-4e3f-9cbb-8cd31ac8887e@dunelm.org.uk>
- In-Reply-To
- <221021.868rl9faf2.gmgdl@evledraar.gmail.com>
On 21/10/2022 15:43, Ævar Arnfjörð Bjarmason wrote:
Show 12 quoted lines
> > On Fri, Oct 21 2022, Phillip Wood wrote: >> Lets squash that commit into this one, so we can see how it is used >> when it is added. > > Heh, I did that to begin with, but found that the commit message & > change was too long & trying to explain two different things. > > Since GIT_TEST_BUILD_DIR (like GIT_TEST_INSTALLED) is something you can > use stand-alone I prefer to keep it this way. The commit message shows > how you can use it without anything to do with cmake, and then later > (here) we can use it for cmake...
We're only adding it because we want to use it with cmake though and the only way to see if the previous patch is correct is to start using it.
Show 15 quoted lines
>>> file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
>>> #test
>>> foreach(tsh ${test_scipts})
>>> add_test(NAME ${tsh}
>>> - COMMAND ${SH_EXE} ${tsh}
>>> + COMMAND env GIT_TEST_BUILD_DIR=${CMAKE_BINARY_DIR} ${SH_EXE} ${tsh}
>>
>> I'm not sure about using env on windows,
>
> In general, if it didn't work a lot of our test suite would fail, so
> it's definitely supported, and since this is only used to run tests it
> should be OK with portability.
>
> But I don't have a Windows dev environment other than the CI, are you
> able to test this & check if it works?I keep meaning to set up a git build on windows but I haven't got round to it. Using "sh -c" also gives us more flexibility in later patches.
Show 8 quoted lines
>> can we use ${SH_EXE} -c
>> instead to avoid creating an extra process?
>>
>> COMMAND ${SH_EXE} -c [[GIT_TEST_BUILD_DIR="$1"; . "$2"]]
>> "${tsh}" "${CMAKE_BINARY_DIR}" "${tsh}"
>
> Neat, so that "[[...]]" syntax makes sure we don't have any quoting
> issues?Yes, it works like lua. https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#bracket-argument
Best Wishes
Phillip