From 92f30decb277289ee68a877744da54a0350f1460 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 28 Aug 2025 16:41:05 -0400 Subject: [PATCH 1/5] GH-47434: [C++] Fix issue preventing running of tests on Windows --- cpp/CMakeLists.txt | 2 +- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 ++ cpp/src/arrow/CMakeLists.txt | 2 +- cpp/src/arrow/compute/CMakeLists.txt | 12 +++--------- cpp/src/arrow/compute/test_env.cc | 9 --------- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 18841ac874b..03aacf4e9ba 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -679,7 +679,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 6e7544a707d..b815d9da56e 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2428,6 +2428,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") @@ -2435,6 +2436,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 0cc4765a79c..9acd7083437 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/compute/CMakeLists.txt b/cpp/src/arrow/compute/CMakeLists.txt index 28e30a564b7..6c530a76e18 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 $ - PUBLIC ${ARROW_GTEST_GTEST_MAIN}) - else() - target_link_libraries(arrow_compute_testing - PUBLIC $ - PUBLIC ${ARROW_GTEST_GTEST}) - endif() + target_link_libraries(arrow_compute_testing + PUBLIC $ + 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 b035b8ca035..57e92763c6d 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 From 4bc252d5b7e8aee73b3a00ff3bdd5c0a954a1043 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 28 Aug 2025 17:08:27 -0400 Subject: [PATCH 2/5] Don't run Ulp assertion on Windows --- cpp/src/arrow/testing/gtest_util_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/arrow/testing/gtest_util_test.cc b/cpp/src/arrow/testing/gtest_util_test.cc index 4ad5159a6b1..9205be09fcc 100644 --- a/cpp/src/arrow/testing/gtest_util_test.cc +++ b/cpp/src/arrow/testing/gtest_util_test.cc @@ -287,9 +287,11 @@ TEST(TestWithinUlp, Float) { TEST(AssertTestWithinUlp, Basics) { AssertWithinUlp(123.4567, 123.45670000000015, 11); AssertWithinUlp(123.456f, 123.456085f, 11); +#ifndef _WIN32 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 From 697c0557a7dfeeaefe244e3e0f95225ba15989e4 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 3 Sep 2025 18:05:06 -0400 Subject: [PATCH 3/5] Skip broken tests --- cpp/src/arrow/adapters/orc/adapter_test.cc | 3 +++ cpp/src/arrow/engine/substrait/serde_test.cc | 3 +++ cpp/src/arrow/testing/gtest_util_test.cc | 1 + 3 files changed, 7 insertions(+) diff --git a/cpp/src/arrow/adapters/orc/adapter_test.cc b/cpp/src/arrow/adapters/orc/adapter_test.cc index b3c314fccc0..498433a8fc9 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/engine/substrait/serde_test.cc b/cpp/src/arrow/engine/substrait/serde_test.cc index 6762d1e0454..d48d07c0e96 100644 --- a/cpp/src/arrow/engine/substrait/serde_test.cc +++ b/cpp/src/arrow/engine/substrait/serde_test.cc @@ -1065,6 +1065,9 @@ NamedTableProvider AlwaysProvideSameTable(std::shared_ptr 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 9205be09fcc..663d1549be1 100644 --- a/cpp/src/arrow/testing/gtest_util_test.cc +++ b/cpp/src/arrow/testing/gtest_util_test.cc @@ -288,6 +288,7 @@ 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"); From d86c958de4e3d8aa540f45fac86d97854e553297 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 4 Sep 2025 11:34:16 -0400 Subject: [PATCH 4/5] Update gandiva config --- cpp/src/gandiva/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index 687e75f4b73..e5760243b39 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) From b7aa8923d6127ce78e91fc99032da839ddf8604f Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 4 Sep 2025 16:30:27 -0400 Subject: [PATCH 5/5] link fix --- cpp/src/arrow/adapters/orc/adapter_test.cc | 2 +- cpp/src/arrow/engine/substrait/serde_test.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/adapters/orc/adapter_test.cc b/cpp/src/arrow/adapters/orc/adapter_test.cc index 498433a8fc9..714e61b22b1 100644 --- a/cpp/src/arrow/adapters/orc/adapter_test.cc +++ b/cpp/src/arrow/adapters/orc/adapter_test.cc @@ -644,7 +644,7 @@ TEST(TestAdapterReadWrite, ThrowWhenTZDBUnavaiable) { } #ifdef _WIN32 GTEST_SKIP() << "GH-47489: Expected error is not thrown on Windows"; -#endif +#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/engine/substrait/serde_test.cc b/cpp/src/arrow/engine/substrait/serde_test.cc index d48d07c0e96..f92aee8eaad 100644 --- a/cpp/src/arrow/engine/substrait/serde_test.cc +++ b/cpp/src/arrow/engine/substrait/serde_test.cc @@ -1066,7 +1066,8 @@ NamedTableProvider AlwaysProvideSameTable(std::shared_ptr
table) { TEST(Substrait, ExecReadRelWithLocalFiles) { #ifdef _WIN32 - GTEST_SKIP() << "GH-47490: Substrait does not properly parse PARQUET_TEST_DATA path on Windows"; + 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"));