test-lib.sh: support a "GIT_TEST_BUILD_DIR"
cmake: optionally be able to run tests before "ctest"
cmake: support GIT_TEST_OPTS, abstract away WIN32 defaults
cmake: increase test timeout on Windows only
cmake: only look for "sh" in "C:/Program Files" on Windows
cmake: copy over git-p4.py for t983[56] perforce test
CI: add a "linux-cmake-test" to run cmake & ctest on linux
.github/workflows/main.yml | 3 +
Makefile | 1 -
ci/run-build-and-tests.sh | 11 +-
contrib/buildsystems/CMakeLists.txt | 213 ++++++++++++++++++++++------
t/README | 3 +
t/lib-gettext.sh | 2 +-
t/lib-gitweb.sh | 2 +-
t/t7609-mergetool--lib.sh | 2 +-
t/t9902-completion.sh | 14 +-
t/t9903-bash-prompt.sh | 2 +-
t/test-lib.sh | 19 ++-
11 files changed, 211 insertions(+), 61 deletions(-)
Range-diff against v5:
1: 7d83ff44c61 ! 1: fc190b379cd cmake: don't invoke msgfmt with --statistics
@@ Metadata
## Commit message ##
cmake: don't invoke msgfmt with --statistics
- In 2f12b31b746 (Makefile: don't invoke msgfmt with --statistics,
- 2021-12-17) I made the same change to our Makefile, let's follow-up
- and do the same here.
+ In [1] I made the same change to our Makefile, let's follow-up and do
+ the same here.
For "cmake" this is particularly nice with "-G Ninja", as before we'd
emit ~40 lines of overflowed progress bar output, but now it's only
the one line of "ninja"'s progress bar.
+ 1. 2f12b31b746 (Makefile: don't invoke msgfmt with --statistics,
+ 2021-12-17)
+
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
## contrib/buildsystems/CMakeLists.txt ##
2: 314c5e40cff ! 2: 1a11aa233a3 cmake: use "-S" and "-B" to specify source and build directories
@@ Commit message
The "-S" and "-B" options were added in cmake v3.13.0, which is older
than the version we have a hard dependency on[1].
- As an aside The "-p" flag to "mkdir" in the pre-image wasn't needed,
+ As an aside, the "-p" flag to "mkdir" in the pre-image wasn't needed,
as "contrib/buildsystems" is tracked
1. 061c2240b1b (Introduce CMake support for configuring Git, 2020-06-12)
3: 5c4ba2425b6 = 3: b9ddb5db1d3 cmake: update instructions for portable CMakeLists.txt
4: e86245ffbab = 4: 7b7850c00ee cmake: don't copy chainlint.pl to build directory
5: 435452314fa ! 5: 82ecb797915 cmake: chmod +x the bin-wrappers/* & SCRIPT_{SH,PERL} & git-p4
@@ Commit message
The remaining failures will be addressed in subsequent commits.
+ As this isn't needed on Windows let's skip this there. There's also an
+ unconfirmed (it works in CI) report[5] that invoking the "chmod"
+ command fails in some scenarios.
+
1. f31b6244950 (Merge branch 'yw/cmake-updates', 2022-06-07)
2. e4597aae659 (run test suite without dashed git-commands in PATH, 2009-12-02)
3. 2ea1d8b5563 (cmake: make it easier to diagnose regressions in CTest
runs, 2022-10-18)
4. https://cmake.org/cmake/help/latest/command/file.html#chmod
+ 5. https://lore.kernel.org/git/87f22a55-ee84-2f76-7b9b-924a97f44f89@xxxxxxxxxxxxx/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
@@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi
+function(write_script path content)
+ file(WRITE ${path} ${content})
+
-+ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER_EQUAL "3.19")
++ if(WIN32)
++ message(TRACE "skipping chmod +x '${path}' on Windows")
++ elseif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER_EQUAL "3.19")
+ file(CHMOD ${path} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
+ else()
+ execute_process(COMMAND chmod +x ${path}
6: 7ee341245a8 = 6: 1f326944a07 cmake & test-lib.sh: add a $GIT_SOURCE_DIR variable
7: 49645cb1643 = 7: 973c8038f54 cmake: set "USE_LIBPCRE2" in "GIT-BUILD-OPTIONS" for test-lib.sh
8: 9e10cd5bd8a = 8: b8448c7a8a6 Makefile + test-lib.sh: don't prefer cmake-built to make-built git
9: df5aea35bbd ! 9: 5135e40969e test-lib.sh: support a "GIT_TEST_BUILD_DIR"
@@ Metadata
## Commit message ##
test-lib.sh: support a "GIT_TEST_BUILD_DIR"
- Compliment the existing GIT_TEST_INSTALLED variable added in [1] with
+ Complement the existing GIT_TEST_INSTALLED variable added in [1] with
one that allows for testing a git built in a directory that's not
"../".
10: 529e18f7f72 ! 10: 65204463730 cmake: optionally be able to run tests before "ctest"
@@ contrib/buildsystems/CMakeLists.txt: if(USE_VCPKG)
+ set(GIT_CTEST_SETS_BUILD_DIR "OFF" CACHE BOOL GIT_CTEST_SETS_BUILD_DIR_DOC)
+endif()
+if(GIT_CTEST_SETS_BUILD_DIR)
-+ message(STATUS "Enabling manual runs of t/* tests once ctest writes CMAKE-BUILD-DIR")
++ message(STATUS "Have GIT_CTEST_SETS_BUILD_DIR=ON. Need a 'ctest' run to write GIT-BUILD-DIR")
+else()
-+ message(STATUS "Enabling manual runs of t/* tests via cmake build dir discovery")
++ message(STATUS "Have GIT_CTEST_SETS_BUILD_DIR=OFF. Wrote out a GIT-BUILD-DIR, no 'ctest' required")
+endif()
+
+# When using GIT_CTEST_SETS_BUILD_DIR, running the tests from the "t/"
11: a5dd4fa1d00 ! 11: e25992b16f1 cmake: support GIT_TEST_OPTS, abstract away WIN32 defaults
@@ contrib/buildsystems/CMakeLists.txt: endif()
+elseif(WIN32)
+ set(GIT_TEST_OPTS "--no-bin-wrappers --no-chain-lint -vx"
+ CACHE STRING "test options, see t/README")
-+ message(STATUS "Using Windowns-specific default test options: ${GIT_TEST_OPTS}")
++ message(STATUS "Using Windows-specific default test options: ${GIT_TEST_OPTS}")
+else()
+ set(GIT_TEST_OPTS ""
+ CACHE STRING "test options, see t/README")
12: c9d550b8558 = 12: 4905ce5321d cmake: increase test timeout on Windows only
13: 7a5dd684d40 = 13: 6c6b530965d cmake: only look for "sh" in "C:/Program Files" on Windows
14: c9c895bb794 = 14: 563f1b9b045 cmake: copy over git-p4.py for t983[56] perforce test
15: a6f343b6221 ! 15: 917a884eb65 CI: add a "linux-cmake-test" to run cmake & ctest on linux
@@ Commit message
To ensure that it doesn't break again let's add a "linux-cmake-ctest"
target to build and test "cmake" on Linux, in addition to that we'll
also run the tests with "ctest" instead of "make" or "prove", so we
- can assert that testing with that method works..
+ can assert that testing with that method works.
This also stress tests running "cmake" (and "ctest") out of a build
directory that isn't the top-level. The "vs-build" job uses "cmake"
@@ Commit message
"$GIT_SOURCE_DIR" in a preceding commit.
Since the "ci/lib.sh" already creates and exports a
- GIT_TEST_OPTS="..." we'll pick that up in our CI, see the preceding
+ GIT_TEST_OPTS="..." we'll pick that up in our CI; see the preceding
commit. Because we pass the "--verbose-log -x
--github-workflow-markup" in the GitHub CI as a result the interaction
with "handle_failed_tests" here works correctly. I.e. on failure we'll
@@ .github/workflows/main.yml: jobs:
pool: macos-latest
## ci/run-build-and-tests.sh ##
-@@ ci/run-build-and-tests.sh: pedantic)
- ;;
- esac
+@@ ci/run-build-and-tests.sh: esac
+
+ run_tests=t
--group Build make
+mc=
-+if test "$jobname" = "linux-cmake-ctest"
-+then
+ case "$jobname" in
+ linux-gcc)
+ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+@@ ci/run-build-and-tests.sh: pedantic)
+ export DEVOPTS=pedantic
+ run_tests=
+ ;;
++linux-cmake-ctest)
+ cb=contrib/buildsystems
+ group CMake cmake -S "$cb" -B "$cb/out"
+ mc="-C $cb/out"
-+fi
-+
++ ;;
+ esac
+
+-group Build make
+group Build make $mc
+
if test -n "$run_tests"