Re: [PATCH 7/9] cmake: support using GIT_TEST_OPTS from the environment
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Oct 21, 2022, 14:18 UTC
- Message-ID
- <830905ef-fb90-9b2a-c40a-67cf24f7a24b@dunelm.org.uk>
- In-Reply-To
- <patch-7.9-fc9f036695f-20221021T091013Z-avarab@gmail.com>
Hi Ævar
On 21/10/2022 10:44, Ævar Arnfjörð Bjarmason wrote:
Show 9 quoted lines
> Get "GIT_TEST_OPTS" from the environment, and use it to pass arguments > to tests. This allows for passing arguments to tests with e.g.: > > GIT_TEST_OPTS="--verbose --debug" cmake .; ctest -R t0001 --verbose > > There's some overlap with this and what was suggested in [1], but as > noted there we're not passing "--verbose" and friends unconditionally, > so a plain "ctest" invocation without a "cmake" re-build won't pick up > the options.
The aim of dscho's patch was to make debugging information available in the test logs without the user having to do anything, now to get that information every user has to set GIT_TEST_OPTS="--no-bin-wrappers --no-chain-lint -vx" when running cmake.
I think it would be helpful to have some default options set if the user does not pass GIT_TEST_OPTS. Ideally one would be able to do
GIT_TEST_OPTS=... ctest
and have the tests pick up the options at runtime. Following on from my previous comment, if we used "sh -c" to launch the tests we could have something like
COMMAND ${SH_EXE} -c [[GIT_TEST_BUILD_DIR="$1"; . "$2"
${GIT_TEST_OPTS:---no-bin-wrappers --no-chain-lint -vx}]] "${tsh}"
"${CMAKE_BINARY_DIR}" "${tsh}"Best Wishes
Phillip
Show 24 quoted lines
> 1. https://lore.kernel.org/git/356b2e9a1007bcd1382f26f333926ff0d5b9abe2.1666090745.git.gitgitgadget@gmail.com/
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> contrib/buildsystems/CMakeLists.txt | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 91b7009f4fd..8e29e3f514b 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -1083,9 +1083,11 @@ endif()
> file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
>
> #test
> +set(GIT_TEST_OPTS "$ENV{GIT_TEST_OPTS}")
> +separate_arguments(GIT_TEST_OPTS)
> foreach(tsh ${test_scipts})
> add_test(NAME ${tsh}
> - COMMAND env GIT_TEST_BUILD_DIR=${CMAKE_BINARY_DIR} ${SH_EXE} ${tsh}
> + COMMAND env GIT_TEST_BUILD_DIR=${CMAKE_BINARY_DIR} ${SH_EXE} ${tsh} ${GIT_TEST_OPTS}
> WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
> endforeach()
>