From ef9630da8289edab1f20ae6f9034c55e005eb832 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 20 Mar 2026 07:40:41 -0400 Subject: [PATCH 1/5] gate tests behind BUILD_TESTING Intended to work around error untarring paths with two dots. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d44c1122e..d19276fb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,6 +499,8 @@ set (TEST_MONGOCRYPT_SOURCES test/test-unicode-fold.c ) +if (BUILD_TESTING) + # Define test-mongocrypt add_executable (test-mongocrypt ${TEST_MONGOCRYPT_SOURCES}) # Use the static version since it allows the test binary to use private symbols @@ -549,6 +551,8 @@ if ("cxx_relaxed_constexpr" IN_LIST CMAKE_CXX_COMPILE_FEATURES) endforeach () endif () +endif () # BUILD_TESTING + if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) add_executable (csfle-markup src/csfle-markup.cpp) target_link_libraries (csfle-markup PRIVATE mongocrypt_static _mongocrypt::libbson_for_static mongo::mc-mlib) From 652aa267e463367dfff620751b7a915ffb0a9776 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 20 Mar 2026 08:04:43 -0400 Subject: [PATCH 2/5] do not build tests if BUILD_TESTING is is not true --- .evergreen/build_all.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.evergreen/build_all.sh b/.evergreen/build_all.sh index 945ce95d0..1ebe583f7 100755 --- a/.evergreen/build_all.sh +++ b/.evergreen/build_all.sh @@ -27,6 +27,8 @@ export CMAKE_INSTALL_PREFIX="${MONGOCRYPT_INSTALL_PREFIX-}" export CTEST_OUTPUT_ON_FAILURE=1 # Generate a compilation database for use by other tools export CMAKE_EXPORT_COMPILE_COMMANDS=1 +# Permit skipping build of tests. +BUILD_TESTING="${BUILD_TESTING-TRUE}" # Accumulate arguments that are passed to CMake cmake_args=( @@ -38,7 +40,7 @@ cmake_args=( # Toggle compiling with shared BSON -D USE_SHARED_LIBBSON="${USE_SHARED_LIBBSON-FALSE}" # Toggle building of tests - -D BUILD_TESTING="${BUILD_TESTING-TRUE}" + -D BUILD_TESTING="${BUILD_TESTING:?}" # Enable additional warnings-as-errors -D ENABLE_MORE_WARNINGS_AS_ERRORS=TRUE ) @@ -85,8 +87,7 @@ if [ "$CONFIGURE_ONLY" ]; then exit 0; fi echo "Installing libmongocrypt" -_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt test_kms_request -run_chdir "$BINARY_DIR" run_ctest +_cmake_with_env --build "$BINARY_DIR" --target install # MONGOCRYPT-372, ensure macOS universal builds contain both x86_64 and arm64 architectures. if test "${CMAKE_OSX_ARCHITECTURES-}" != ''; then @@ -100,6 +101,14 @@ if test "${CMAKE_OSX_ARCHITECTURES-}" != ''; then fi fi +if [[ "${BUILD_TESTING:?}" =~ ^(0|OFF|NO|FALSE|n|off|no|false)$ ]]; then + echo "Skipping tests since BUILD_TESTING is false" + exit 0; +fi + +_cmake_with_env --build "$BINARY_DIR" --target test-mongocrypt test_kms_request +run_chdir "$BINARY_DIR" run_ctest + if [ "$PPA_BUILD_ONLY" ]; then echo "Only building/installing for PPA"; exit 0; From a6449742f71b0f2bd1a46a8465dcafa9ea3ff445 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 23 Mar 2026 10:54:59 -0400 Subject: [PATCH 3/5] remove unnecessary branch No need to skip ctest if BUILD_TESTING is false. The ctest command exits with "No test configuration file found!" if `BUILD_TESTING=FALSE`. --- .evergreen/build_all.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.evergreen/build_all.sh b/.evergreen/build_all.sh index 1ebe583f7..9e5db6db2 100755 --- a/.evergreen/build_all.sh +++ b/.evergreen/build_all.sh @@ -88,6 +88,7 @@ if [ "$CONFIGURE_ONLY" ]; then fi echo "Installing libmongocrypt" _cmake_with_env --build "$BINARY_DIR" --target install +run_chdir "$BINARY_DIR" run_ctest # MONGOCRYPT-372, ensure macOS universal builds contain both x86_64 and arm64 architectures. if test "${CMAKE_OSX_ARCHITECTURES-}" != ''; then @@ -101,14 +102,6 @@ if test "${CMAKE_OSX_ARCHITECTURES-}" != ''; then fi fi -if [[ "${BUILD_TESTING:?}" =~ ^(0|OFF|NO|FALSE|n|off|no|false)$ ]]; then - echo "Skipping tests since BUILD_TESTING is false" - exit 0; -fi - -_cmake_with_env --build "$BINARY_DIR" --target test-mongocrypt test_kms_request -run_chdir "$BINARY_DIR" run_ctest - if [ "$PPA_BUILD_ONLY" ]; then echo "Only building/installing for PPA"; exit 0; @@ -119,7 +112,7 @@ _cmake_with_env "${cmake_args[@]}" \ -DDISABLE_NATIVE_CRYPTO=ON \ -DCMAKE_INSTALL_PREFIX="$MONGOCRYPT_INSTALL_PREFIX/nocrypto" \ -B "$BINARY_DIR" -S "$LIBMONGOCRYPT_DIR" -_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt +_cmake_with_env --build "$BINARY_DIR" --target install run_chdir "$BINARY_DIR" run_ctest # Build and install libmongocrypt without statically linking libbson @@ -127,5 +120,5 @@ _cmake_with_env "${cmake_args[@]}" \ -DUSE_SHARED_LIBBSON=ON \ -DCMAKE_INSTALL_PREFIX="$MONGOCRYPT_INSTALL_PREFIX/sharedbson" \ -B "$BINARY_DIR" -S "$LIBMONGOCRYPT_DIR" -_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt +_cmake_with_env --build "$BINARY_DIR" --target install run_chdir "$BINARY_DIR" run_ctest From 0fae2342340f3e56a982153331afa456a8d0e578 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 23 Mar 2026 11:00:45 -0400 Subject: [PATCH 4/5] add `BUILD_MONGOCRYPT_VARIANTS` to skip build time for the C driver (only needs first build) --- .evergreen/build_all.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.evergreen/build_all.sh b/.evergreen/build_all.sh index 9e5db6db2..2b12abb48 100755 --- a/.evergreen/build_all.sh +++ b/.evergreen/build_all.sh @@ -29,6 +29,8 @@ export CTEST_OUTPUT_ON_FAILURE=1 export CMAKE_EXPORT_COMPILE_COMMANDS=1 # Permit skipping build of tests. BUILD_TESTING="${BUILD_TESTING-TRUE}" +# Build nocrypto and sharedbson variants (true by defualt). +BUILD_MONGOCRYPT_VARIANTS="${BUILD_MONGOCRYPT_VARIANTS:-TRUE}" # Accumulate arguments that are passed to CMake cmake_args=( @@ -107,6 +109,11 @@ if [ "$PPA_BUILD_ONLY" ]; then exit 0; fi +if [ "${BUILD_MONGOCRYPT_VARIANTS:?}" != "TRUE" ]; then + echo "Skipping build of libmongocrypt variants"; + exit 0; +fi + # Build and install libmongocrypt with no native crypto. _cmake_with_env "${cmake_args[@]}" \ -DDISABLE_NATIVE_CRYPTO=ON \ From 21a0f88bdd4ece7ff2c93f0d6ee7f97312fd2860 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 23 Mar 2026 11:11:52 -0400 Subject: [PATCH 5/5] use more consistent naming --- .evergreen/build_all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.evergreen/build_all.sh b/.evergreen/build_all.sh index 2b12abb48..be0fce306 100755 --- a/.evergreen/build_all.sh +++ b/.evergreen/build_all.sh @@ -30,7 +30,7 @@ export CMAKE_EXPORT_COMPILE_COMMANDS=1 # Permit skipping build of tests. BUILD_TESTING="${BUILD_TESTING-TRUE}" # Build nocrypto and sharedbson variants (true by defualt). -BUILD_MONGOCRYPT_VARIANTS="${BUILD_MONGOCRYPT_VARIANTS:-TRUE}" +LIBMONGOCRYPT_BUILD_VARIANTS="${LIBMONGOCRYPT_BUILD_VARIANTS:-TRUE}" # Accumulate arguments that are passed to CMake cmake_args=( @@ -109,7 +109,7 @@ if [ "$PPA_BUILD_ONLY" ]; then exit 0; fi -if [ "${BUILD_MONGOCRYPT_VARIANTS:?}" != "TRUE" ]; then +if [ "${LIBMONGOCRYPT_BUILD_VARIANTS:?}" != "TRUE" ]; then echo "Skipping build of libmongocrypt variants"; exit 0; fi