Skip to content

Commit 3105d9c

Browse files
authored
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]>
1 parent 64cfa7c commit 3105d9c

File tree

9 files changed

+19
-22
lines changed

9 files changed

+19
-22
lines changed

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ endif()
686686
# the first link library. It's for prioritizing bundled FlatBuffers
687687
# than system FlatBuffers.
688688
list(PREPEND ARROW_TEST_LINK_LIBS arrow::flatbuffers)
689-
list(APPEND ARROW_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN})
689+
list(APPEND ARROW_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK_MAIN})
690690

691691
if(ARROW_BUILD_BENCHMARKS)
692692
set(ARROW_BENCHMARK_LINK_LIBS benchmark::benchmark_main ${ARROW_TEST_LINK_LIBS})

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,13 +2430,15 @@ if(ARROW_TESTING)
24302430
set(ARROW_GTEST_GMOCK GTest::gmock)
24312431
set(ARROW_GTEST_GTEST GTest::gtest)
24322432
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
2433+
set(ARROW_GTEST_GMOCK_MAIN GTest::gmock_main)
24332434
else()
24342435
string(APPEND ARROW_TESTING_PC_CFLAGS " -I\${includedir}/arrow-gtest")
24352436
string(APPEND ARROW_TESTING_PC_LIBS " -larrow_gtest")
24362437
set(ARROW_GTEST_GTEST_HEADERS arrow::GTest::gtest_headers)
24372438
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
24382439
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
24392440
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
2441+
set(ARROW_GTEST_GMOCK_MAIN arrow::GTest::gmock_main)
24402442
endif()
24412443
endif()
24422444

cpp/src/arrow/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ if(ARROW_ENABLE_THREADING)
137137
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS Threads::Threads)
138138
endif()
139139

140-
set(ARROW_TEST_LINK_TOOLCHAIN ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN})
140+
set(ARROW_TEST_LINK_TOOLCHAIN ${ARROW_GTEST_GMOCK_MAIN})
141141
set(ARROW_TEST_STATIC_LINK_LIBS arrow::flatbuffers arrow_testing_static arrow_static
142142
${ARROW_TEST_LINK_TOOLCHAIN})
143143
set(ARROW_TEST_SHARED_LINK_LIBS arrow::flatbuffers arrow_testing_shared arrow_shared

cpp/src/arrow/adapters/orc/adapter_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,9 @@ TEST(TestAdapterReadWrite, ThrowWhenTZDBUnavaiable) {
642642
if (adapters::orc::GetOrcMajorVersion() >= 2) {
643643
GTEST_SKIP() << "Only ORC pre-2.0.0 versions have the time zone database check";
644644
}
645+
#ifdef _WIN32
646+
GTEST_SKIP() << "GH-47489: Expected error is not thrown on Windows";
647+
#endif
645648

646649
EnvVarGuard tzdir_guard("TZDIR", "/wrong/path");
647650
const char* expect_str = "IANA time zone database is unavailable but required by ORC";

cpp/src/arrow/compute/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,9 @@ if(ARROW_TESTING AND ARROW_COMPUTE)
4343
add_library(arrow_compute_testing OBJECT ${ARROW_COMPUTE_TESTING_SRCS})
4444
# Even though this is still just an object library we still need to "link"
4545
# arrow_compute_core_testing so that is also included correctly
46-
if(MSVC)
47-
target_link_libraries(arrow_compute_testing
48-
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
49-
PUBLIC ${ARROW_GTEST_GTEST_MAIN})
50-
else()
51-
target_link_libraries(arrow_compute_testing
52-
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
53-
PUBLIC ${ARROW_GTEST_GTEST})
54-
endif()
46+
target_link_libraries(arrow_compute_testing
47+
PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
48+
PUBLIC ${ARROW_GTEST_GTEST})
5549
endif()
5650

5751
set(ARROW_COMPUTE_TEST_PREFIX "arrow-compute")

cpp/src/arrow/compute/test_env.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,10 @@ class ComputeKernelEnvironment : public ::testing::Environment {
3434
};
3535

3636
} // namespace
37-
38-
#ifdef _MSC_VER
39-
// Initialize the compute module
40-
::testing::Environment* compute_kernels_env =
41-
::testing::AddGlobalTestEnvironment(new ComputeKernelEnvironment);
42-
#endif
43-
4437
} // namespace arrow::compute
4538

46-
#ifndef _MSC_VER
4739
int main(int argc, char** argv) {
4840
::testing::InitGoogleTest(&argc, argv);
4941
::testing::AddGlobalTestEnvironment(new arrow::compute::ComputeKernelEnvironment);
5042
return RUN_ALL_TESTS();
5143
}
52-
#endif

cpp/src/arrow/engine/substrait/serde_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,10 @@ NamedTableProvider AlwaysProvideSameTable(std::shared_ptr<Table> table) {
10651065
}
10661066

10671067
TEST(Substrait, ExecReadRelWithLocalFiles) {
1068+
#ifdef _WIN32
1069+
GTEST_SKIP()
1070+
<< "GH-47490: Substrait does not properly parse PARQUET_TEST_DATA path on Windows";
1071+
#endif
10681072
ASSERT_OK_AND_ASSIGN(std::string dir_string,
10691073
arrow::internal::GetEnvVar("PARQUET_TEST_DATA"));
10701074

cpp/src/arrow/testing/gtest_util_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@ TEST(TestWithinUlp, Float) {
287287
TEST(AssertTestWithinUlp, Basics) {
288288
AssertWithinUlp(123.4567, 123.45670000000015, 11);
289289
AssertWithinUlp(123.456f, 123.456085f, 11);
290+
#ifndef _WIN32
291+
// GH-47442
290292
EXPECT_FATAL_FAILURE(AssertWithinUlp(123.4567, 123.45670000000015, 10),
291293
"not within 10 ulps");
292294
EXPECT_FATAL_FAILURE(AssertWithinUlp(123.456f, 123.456085f, 10), "not within 10 ulps");
295+
#endif
293296
}
294297

295298
} // namespace arrow

cpp/src/gandiva/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ if(WIN32)
195195
list(APPEND GANDIVA_STATIC_TEST_LINK_LIBS ${GANDIVA_OPENSSL_LIBS})
196196
list(APPEND GANDIVA_SHARED_TEST_LINK_LIBS ${GANDIVA_OPENSSL_LIBS})
197197
endif()
198-
list(APPEND GANDIVA_STATIC_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN})
199-
list(APPEND GANDIVA_SHARED_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN})
198+
list(APPEND GANDIVA_STATIC_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK_MAIN})
199+
list(APPEND GANDIVA_SHARED_TEST_LINK_LIBS ${ARROW_GTEST_GMOCK_MAIN})
200200

201201
function(ADD_GANDIVA_TEST REL_TEST_NAME)
202202
set(options USE_STATIC_LINKING)

0 commit comments

Comments
 (0)