Skip to content

Commit 6d6bc38

Browse files
authored
MONGOCRYPT-889 skip building tests when BUILD_TESTING=OFF (#1139)
* gate tests behind BUILD_TESTING Intended to work around error untarring paths with two dots. * add `LIBMONGOCRYPT_BUILD_VARIANTS` to skip build time for the C driver (only needs first build)
1 parent c6ef79f commit 6d6bc38

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

.evergreen/build_all.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export CMAKE_INSTALL_PREFIX="${MONGOCRYPT_INSTALL_PREFIX-}"
2727
export CTEST_OUTPUT_ON_FAILURE=1
2828
# Generate a compilation database for use by other tools
2929
export CMAKE_EXPORT_COMPILE_COMMANDS=1
30+
# Permit skipping build of tests.
31+
BUILD_TESTING="${BUILD_TESTING-TRUE}"
32+
# Build nocrypto and sharedbson variants (true by defualt).
33+
LIBMONGOCRYPT_BUILD_VARIANTS="${LIBMONGOCRYPT_BUILD_VARIANTS:-TRUE}"
3034

3135
# Accumulate arguments that are passed to CMake
3236
cmake_args=(
@@ -38,7 +42,7 @@ cmake_args=(
3842
# Toggle compiling with shared BSON
3943
-D USE_SHARED_LIBBSON="${USE_SHARED_LIBBSON-FALSE}"
4044
# Toggle building of tests
41-
-D BUILD_TESTING="${BUILD_TESTING-TRUE}"
45+
-D BUILD_TESTING="${BUILD_TESTING:?}"
4246
# Enable additional warnings-as-errors
4347
-D ENABLE_MORE_WARNINGS_AS_ERRORS=TRUE
4448
)
@@ -85,7 +89,7 @@ if [ "$CONFIGURE_ONLY" ]; then
8589
exit 0;
8690
fi
8791
echo "Installing libmongocrypt"
88-
_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt test_kms_request
92+
_cmake_with_env --build "$BINARY_DIR" --target install
8993
run_chdir "$BINARY_DIR" run_ctest
9094

9195
# MONGOCRYPT-372, ensure macOS universal builds contain both x86_64 and arm64 architectures.
@@ -105,18 +109,23 @@ if [ "$PPA_BUILD_ONLY" ]; then
105109
exit 0;
106110
fi
107111

112+
if [ "${LIBMONGOCRYPT_BUILD_VARIANTS:?}" != "TRUE" ]; then
113+
echo "Skipping build of libmongocrypt variants";
114+
exit 0;
115+
fi
116+
108117
# Build and install libmongocrypt with no native crypto.
109118
_cmake_with_env "${cmake_args[@]}" \
110119
-DDISABLE_NATIVE_CRYPTO=ON \
111120
-DCMAKE_INSTALL_PREFIX="$MONGOCRYPT_INSTALL_PREFIX/nocrypto" \
112121
-B "$BINARY_DIR" -S "$LIBMONGOCRYPT_DIR"
113-
_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt
122+
_cmake_with_env --build "$BINARY_DIR" --target install
114123
run_chdir "$BINARY_DIR" run_ctest
115124

116125
# Build and install libmongocrypt without statically linking libbson
117126
_cmake_with_env "${cmake_args[@]}" \
118127
-DUSE_SHARED_LIBBSON=ON \
119128
-DCMAKE_INSTALL_PREFIX="$MONGOCRYPT_INSTALL_PREFIX/sharedbson" \
120129
-B "$BINARY_DIR" -S "$LIBMONGOCRYPT_DIR"
121-
_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt
130+
_cmake_with_env --build "$BINARY_DIR" --target install
122131
run_chdir "$BINARY_DIR" run_ctest

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ set (TEST_MONGOCRYPT_SOURCES
499499
test/test-unicode-fold.c
500500
)
501501

502+
if (BUILD_TESTING)
503+
502504
# Define test-mongocrypt
503505
add_executable (test-mongocrypt ${TEST_MONGOCRYPT_SOURCES})
504506
# 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)
549551
endforeach ()
550552
endif ()
551553

554+
endif () # BUILD_TESTING
555+
552556
if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
553557
add_executable (csfle-markup src/csfle-markup.cpp)
554558
target_link_libraries (csfle-markup PRIVATE mongocrypt_static _mongocrypt::libbson_for_static mongo::mc-mlib)

0 commit comments

Comments
 (0)