This is an automated email from the ASF dual-hosted git repository.

willayd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 3105d9c026 GH-47434: [C++] Fix issue preventing running of tests on 
Windows (#47455)
3105d9c026 is described below

commit 3105d9c0266e8ba146af5faada3f43ae53171ddc
Author: William Ayd <[email protected]>
AuthorDate: Mon Sep 8 15:18:09 2025 -0400

    GH-47434: [C++] Fix issue preventing running of tests on Windows (#47455)
    
    ### Rationale for this change
    
    It was recently discovered that the majority of tests in the CMake 
configuration on Windows are not actually running. This solves that issue so 
the tests are discovered and run.
    
    ### What changes are included in this PR?
    
    Usage of the gtest_main dependency has been replaced with gmock_main.
    
    ### Are these changes tested?
    
    Yes
    
    ### Are there any user-facing changes?
    
    No
    * GitHub Issue: #47434
    
    Authored-by: Will Ayd <[email protected]>
    Signed-off-by: Will Ayd <[email protected]>
---
 cpp/CMakeLists.txt                           |  2 +-
 cpp/cmake_modules/ThirdpartyToolchain.cmake  |  2 ++
 cpp/src/arrow/CMakeLists.txt                 |  2 +-
 cpp/src/arrow/adapters/orc/adapter_test.cc   |  3 +++
 cpp/src/arrow/compute/CMakeLists.txt         | 12 +++---------
 cpp/src/arrow/compute/test_env.cc            |  9 ---------
 cpp/src/arrow/engine/substrait/serde_test.cc |  4 ++++
 cpp/src/arrow/testing/gtest_util_test.cc     |  3 +++
 cpp/src/gandiva/CMakeLists.txt               |  4 ++--
 9 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 4d466de521..e805694f52 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -686,7 +686,7 @@ endif()
 # the first link library. It's for prioritizing bundled FlatBuffers
 # than system FlatBuffers.
 list(PREPEND ARROW_TEST_LINK_LIBS arrow::flatbuffers)
-list(APPEND ARROW_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK} 
${ARROW_GTEST_GTEST_MAIN})
+list(APPEND ARROW_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK_MAIN})
 
 if(ARROW_BUILD_BENCHMARKS)
   set(ARROW_BENCHMARK_LINK_LIBS benchmark::benchmark_main 
${ARROW_TEST_LINK_LIBS})
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 79700aea04..5b8b039357 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2430,6 +2430,7 @@ if(ARROW_TESTING)
     set(ARROW_GTEST_GMOCK GTest::gmock)
     set(ARROW_GTEST_GTEST GTest::gtest)
     set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
+    set(ARROW_GTEST_GMOCK_MAIN GTest::gmock_main)
   else()
     string(APPEND ARROW_TESTING_PC_CFLAGS " -I\${includedir}/arrow-gtest")
     string(APPEND ARROW_TESTING_PC_LIBS " -larrow_gtest")
@@ -2437,6 +2438,7 @@ if(ARROW_TESTING)
     set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
     set(ARROW_GTEST_GTEST arrow::GTest::gtest)
     set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
+    set(ARROW_GTEST_GMOCK_MAIN arrow::GTest::gmock_main)
   endif()
 endif()
 
diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt
index 0cc4765a79..9acd708343 100644
--- a/cpp/src/arrow/CMakeLists.txt
+++ b/cpp/src/arrow/CMakeLists.txt
@@ -137,7 +137,7 @@ if(ARROW_ENABLE_THREADING)
   list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS Threads::Threads)
 endif()
 
-set(ARROW_TEST_LINK_TOOLCHAIN ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN})
+set(ARROW_TEST_LINK_TOOLCHAIN ${ARROW_GTEST_GMOCK_MAIN})
 set(ARROW_TEST_STATIC_LINK_LIBS arrow::flatbuffers arrow_testing_static 
arrow_static
                                 ${ARROW_TEST_LINK_TOOLCHAIN})
 set(ARROW_TEST_SHARED_LINK_LIBS arrow::flatbuffers arrow_testing_shared 
arrow_shared
diff --git a/cpp/src/arrow/adapters/orc/adapter_test.cc 
b/cpp/src/arrow/adapters/orc/adapter_test.cc
index b3c314fccc..714e61b22b 100644
--- a/cpp/src/arrow/adapters/orc/adapter_test.cc
+++ b/cpp/src/arrow/adapters/orc/adapter_test.cc
@@ -642,6 +642,9 @@ TEST(TestAdapterReadWrite, ThrowWhenTZDBUnavaiable) {
   if (adapters::orc::GetOrcMajorVersion() >= 2) {
     GTEST_SKIP() << "Only ORC pre-2.0.0 versions have the time zone database 
check";
   }
+#ifdef _WIN32
+  GTEST_SKIP() << "GH-47489: Expected error is not thrown on Windows";
+#endif
 
   EnvVarGuard tzdir_guard("TZDIR", "/wrong/path");
   const char* expect_str = "IANA time zone database is unavailable but 
required by ORC";
diff --git a/cpp/src/arrow/compute/CMakeLists.txt 
b/cpp/src/arrow/compute/CMakeLists.txt
index 28e30a564b..6c530a76e1 100644
--- a/cpp/src/arrow/compute/CMakeLists.txt
+++ b/cpp/src/arrow/compute/CMakeLists.txt
@@ -43,15 +43,9 @@ if(ARROW_TESTING AND ARROW_COMPUTE)
   add_library(arrow_compute_testing OBJECT ${ARROW_COMPUTE_TESTING_SRCS})
   # Even though this is still just an object library we still need to "link"
   # arrow_compute_core_testing so that is also included correctly
-  if(MSVC)
-    target_link_libraries(arrow_compute_testing
-                          PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
-                          PUBLIC ${ARROW_GTEST_GTEST_MAIN})
-  else()
-    target_link_libraries(arrow_compute_testing
-                          PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
-                          PUBLIC ${ARROW_GTEST_GTEST})
-  endif()
+  target_link_libraries(arrow_compute_testing
+                        PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
+                        PUBLIC ${ARROW_GTEST_GTEST})
 endif()
 
 set(ARROW_COMPUTE_TEST_PREFIX "arrow-compute")
diff --git a/cpp/src/arrow/compute/test_env.cc 
b/cpp/src/arrow/compute/test_env.cc
index b035b8ca03..57e92763c6 100644
--- a/cpp/src/arrow/compute/test_env.cc
+++ b/cpp/src/arrow/compute/test_env.cc
@@ -34,19 +34,10 @@ class ComputeKernelEnvironment : public 
::testing::Environment {
 };
 
 }  // namespace
-
-#ifdef _MSC_VER
-// Initialize the compute module
-::testing::Environment* compute_kernels_env =
-    ::testing::AddGlobalTestEnvironment(new ComputeKernelEnvironment);
-#endif
-
 }  // namespace arrow::compute
 
-#ifndef _MSC_VER
 int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
   ::testing::AddGlobalTestEnvironment(new 
arrow::compute::ComputeKernelEnvironment);
   return RUN_ALL_TESTS();
 }
-#endif
diff --git a/cpp/src/arrow/engine/substrait/serde_test.cc 
b/cpp/src/arrow/engine/substrait/serde_test.cc
index 6762d1e045..f92aee8eaa 100644
--- a/cpp/src/arrow/engine/substrait/serde_test.cc
+++ b/cpp/src/arrow/engine/substrait/serde_test.cc
@@ -1065,6 +1065,10 @@ NamedTableProvider 
AlwaysProvideSameTable(std::shared_ptr<Table> table) {
 }
 
 TEST(Substrait, ExecReadRelWithLocalFiles) {
+#ifdef _WIN32
+  GTEST_SKIP()
+      << "GH-47490: Substrait does not properly parse PARQUET_TEST_DATA path 
on Windows";
+#endif
   ASSERT_OK_AND_ASSIGN(std::string dir_string,
                        arrow::internal::GetEnvVar("PARQUET_TEST_DATA"));
 
diff --git a/cpp/src/arrow/testing/gtest_util_test.cc 
b/cpp/src/arrow/testing/gtest_util_test.cc
index 4ad5159a6b..663d1549be 100644
--- a/cpp/src/arrow/testing/gtest_util_test.cc
+++ b/cpp/src/arrow/testing/gtest_util_test.cc
@@ -287,9 +287,12 @@ TEST(TestWithinUlp, Float) {
 TEST(AssertTestWithinUlp, Basics) {
   AssertWithinUlp(123.4567, 123.45670000000015, 11);
   AssertWithinUlp(123.456f, 123.456085f, 11);
+#ifndef _WIN32
+  // GH-47442
   EXPECT_FATAL_FAILURE(AssertWithinUlp(123.4567, 123.45670000000015, 10),
                        "not within 10 ulps");
   EXPECT_FATAL_FAILURE(AssertWithinUlp(123.456f, 123.456085f, 10), "not within 
10 ulps");
+#endif
 }
 
 }  // namespace arrow
diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt
index 687e75f4b7..e5760243b3 100644
--- a/cpp/src/gandiva/CMakeLists.txt
+++ b/cpp/src/gandiva/CMakeLists.txt
@@ -195,8 +195,8 @@ if(WIN32)
   list(APPEND GANDIVA_STATIC_TEST_LINK_LIBS ${GANDIVA_OPENSSL_LIBS})
   list(APPEND GANDIVA_SHARED_TEST_LINK_LIBS ${GANDIVA_OPENSSL_LIBS})
 endif()
-list(APPEND GANDIVA_STATIC_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK} 
${ARROW_GTEST_GTEST_MAIN})
-list(APPEND GANDIVA_SHARED_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK} 
${ARROW_GTEST_GTEST_MAIN})
+list(APPEND GANDIVA_STATIC_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK_MAIN})
+list(APPEND GANDIVA_SHARED_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK_MAIN})
 
 function(ADD_GANDIVA_TEST REL_TEST_NAME)
   set(options USE_STATIC_LINKING)

Reply via email to