Skip to content

Commit ef17ad4

Browse files
impl(bq_driver): Enabling unit test cases on macos
1 parent f6e5d43 commit ef17ad4

4 files changed

Lines changed: 96 additions & 2 deletions

File tree

.github/workflows/macos-cmake.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ jobs:
8686
export ODBC_PREFIX="$(brew --prefix libiodbc)"
8787
export ODBC_INCLUDE_PATH="$ODBC_PREFIX/include"
8888
export VCPKG_ROOT="${{ runner.temp }}/vcpkg"
89-
89+
export CPP_BIGQUERY_ODBC_DRIVER_TEST_DATA_PATH="$PWD/google/cloud/odbc/bq_driver/internal/test_data"
9090
export PATH="$(brew --prefix)/bin:/opt/homebrew/bin:$VCPKG_ROOT:$PATH"
9191
export LDFLAGS="-L$(brew --prefix libiodbc)/lib -liconv"
92+
bash ci/gha/builds/macos-cmake-unit.sh
9293
bash ci/gha/builds/macos-cmake.sh
9394
env:
9495
USE_BAZEL_VERSION: 7.0.0

ci/gha/builds/macos-cmake-unit.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
19+
source "$(dirname "$0")/../../lib/init.sh"
20+
source module ci/gha/builds/lib/macos.sh
21+
source module ci/gha/builds/lib/cmake.sh
22+
23+
if [[ -z "${CMAKE_OUT:-}" ]]; then
24+
CMAKE_OUT=cmake-out
25+
fi
26+
27+
mapfile -t args < <(cmake::common_args "${CMAKE_OUT}")
28+
mapfile -t vcpkg_args < <(cmake::vcpkg_args)
29+
mapfile -t ctest_args < <(ctest::common_args)
30+
31+
args+=("-DODBC_EXAMPLES=OFF")
32+
args+=("-DGTEST_HAS_ABSL=0")
33+
args+=("-DODBC_UNIT_TESTING=ON")
34+
args+=("-DODBC_INTEGRATION_TESTING=OFF")
35+
args+=("-DCLIENT_LIBRARY_INTEGRATION_TESTING=OFF")
36+
args+=("-DBQ_DRIVER_INTEGRATION_TESTS=OFF")
37+
args+=("-DCMAKE_CXX_STANDARD=20")
38+
39+
if command -v sccache >/dev/null 2>&1; then
40+
args+=(
41+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
42+
)
43+
fi
44+
45+
io::log_h1 "Starting macOS Unit Test Build"
46+
47+
TIMEFORMAT="==> 🕑 CMake configuration done in %R seconds"
48+
time {
49+
io::run cmake "${args[@]}" "${vcpkg_args[@]}"
50+
}
51+
52+
TIMEFORMAT="==> 🕑 CMake build done in %R seconds"
53+
time {
54+
io::run cmake --build "${CMAKE_OUT}" --parallel
55+
}
56+
57+
export CTEST_OUTPUT_ON_FAILURE=1
58+
export GTEST_COLOR=1
59+
60+
TIMEFORMAT="==> 🕑 Unit tests done in %R seconds"
61+
time {
62+
io::run ctest \
63+
"${ctest_args[@]}" \
64+
--test-dir "${CMAKE_OUT}" \
65+
-LE integration-test \
66+
--output-on-failure \
67+
--parallel 2 \
68+
--timeout 300 \
69+
--schedule-random
70+
}

ci/gha/builds/macos-cmake.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,30 @@ export GOOGLEBIGQUERYODBCINI=/Users/runner/work/connection/google.googlebigquery
3131
export ODBC_TESTS_DSN="SampleDSNGoogleDriver"
3232
export CPP_BIGQUERY_ODBC_TEST_SERVICE_ACCOUNT_AUTH_KEY=/Users/runner/work/connection/key.json
3333

34+
mapfile -t args < <(cmake::common_args)
35+
args+=(
36+
-DODBC_UNIT_TESTING=OFF
37+
-DODBC_INTEGRATION_TESTING=ON
38+
-DBQ_DRIVER_INTEGRATION_TESTS=ON
39+
-DCLIENT_LIBRARY_INTEGRATION_TESTING=OFF
40+
-DCMAKE_CXX_FLAGS="-I$(brew --prefix libiodbc)/include"
41+
-DCMAKE_CXX_STANDARD=17
42+
)
43+
44+
mapfile -t vcpkg_args < <(cmake::vcpkg_args)
3445
mapfile -t ctest_args < <(ctest::common_args)
3546

47+
io::log_h1 "Starting Build"
48+
TIMEFORMAT="==> 🕑 CMake configuration done in %R seconds"
49+
time {
50+
io::run cmake "${args[@]}" "${vcpkg_args[@]}"
51+
}
52+
53+
TIMEFORMAT="==> 🕑 CMake build done in %R seconds"
54+
time {
55+
io::run cmake --build cmake-out
56+
}
57+
3658
if [[ "$MATRIX_OS" == "macos-14" ]]; then
3759
TIMEFORMAT="==> 🕑 CMake test done in %R seconds"
3860
time {

google/cloud/odbc/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ endif ()
6060

6161
find_package(absl CONFIG REQUIRED)
6262

63-
if (ODBC_UNIT_TESTING)
63+
if (ODBC_UNIT_TESTING
64+
AND NOT APPLE)
6465
FetchContent_Declare(
6566
fuzztest
6667
URL "https://github.com/google/fuzztest/archive/refs/tags/2024-10-28.tar.gz"

0 commit comments

Comments
 (0)