From 40b03b42eb2d3ac65b58e95e6c7fce7e8c902117 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 7 Dec 2021 00:50:55 +0100 Subject: [PATCH] Adapt tests to new cc_binary file extension on macOS (#834) As of https://github.com/bazelbuild/bazel/pull/14369, shared libraries produced with cc_binary on macOS with the auto-configured toolchain use the correct file extension for dynamic libraries (.dylib rather than .so). This requires adapting a test. --- .../cmake_with_data/tests/test_cmake_with_shared_lib.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/cmake_with_data/tests/test_cmake_with_shared_lib.cpp b/examples/cmake_with_data/tests/test_cmake_with_shared_lib.cpp index 14792ece..0c218b31 100644 --- a/examples/cmake_with_data/tests/test_cmake_with_shared_lib.cpp +++ b/examples/cmake_with_data/tests/test_cmake_with_shared_lib.cpp @@ -20,7 +20,13 @@ int main(int argc, char* argv[]) #ifdef _WIN32 test_opening_file(".\\cmake_with_data\\lib_b\\lib_b.dll"); #else - test_opening_file("./cmake_with_data/lib_b/liblib_b.so"); + // Shared libraries used to have the .so file extension on macOS. + // See https://github.com/bazelbuild/bazel/pull/14369. + try { + test_opening_file("./cmake_with_data/lib_b/liblib_b.so"); + } catch (std::runtime_error& e) { + test_opening_file("./cmake_with_data/lib_b/liblib_b.dylib"); + } #endif std::cout << "Everything's fine!"; }