Skip to content

Commit bc9746d

Browse files
authored
GH-47659: [C++] Fix Arrow Flight Testing's unresolved external symbol error (#47660)
### Rationale for this change Fixes issue at #47659 ### What changes are included in this PR? Include add gmock as a shared private link library to `arrow_flight_testing` ### Are these changes tested? Build for `arrow_flight_testing` succeeds on my Windows environment ### Are there any user-facing changes? No * GitHub Issue: #47659 Authored-by: Alina (Xi) Li <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 48a2e88 commit bc9746d

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

cpp/src/arrow/flight/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ if(ARROW_TESTING)
284284
ArrowTesting::arrow_testing_static)
285285
endif()
286286
list(APPEND ARROW_FLIGHT_TESTING_SHARED_LINK_LIBS ${ARROW_FLIGHT_TEST_INTERFACE_LIBS})
287+
list(APPEND ARROW_FLIGHT_TESTING_SHARED_LINK_LIBS ${ARROW_GTEST_GMOCK})
287288
list(APPEND ARROW_FLIGHT_TESTING_STATIC_LINK_LIBS ${ARROW_FLIGHT_TEST_INTERFACE_LIBS})
289+
list(APPEND ARROW_FLIGHT_TESTING_STATIC_LINK_LIBS ${ARROW_GTEST_GMOCK})
288290
add_arrow_lib(arrow_flight_testing
289291
CMAKE_PACKAGE_NAME
290292
ArrowFlightTesting

cpp/src/arrow/flight/test_util.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// We need Windows fixes before including Boost
2626
#include "arrow/util/windows_compatibility.h"
2727

28+
#include <gmock/gmock.h>
2829
#include <gtest/gtest.h>
2930

3031
#include "arrow/array.h"
@@ -105,6 +106,20 @@ arrow::Result<FlightPayload> NumberingStream::Next() {
105106
return payload;
106107
}
107108

109+
void AssertEqual(const FlightInfo& expected, const FlightInfo& actual) {
110+
ipc::DictionaryMemo expected_memo;
111+
ipc::DictionaryMemo actual_memo;
112+
ASSERT_OK_AND_ASSIGN(auto ex_schema, expected.GetSchema(&expected_memo));
113+
ASSERT_OK_AND_ASSIGN(auto actual_schema, actual.GetSchema(&actual_memo));
114+
115+
AssertSchemaEqual(*ex_schema, *actual_schema);
116+
ASSERT_EQ(expected.total_records(), actual.total_records());
117+
ASSERT_EQ(expected.total_bytes(), actual.total_bytes());
118+
119+
ASSERT_EQ(expected.descriptor(), actual.descriptor());
120+
ASSERT_THAT(actual.endpoints(), ::testing::ContainerEq(expected.endpoints()));
121+
}
122+
108123
std::shared_ptr<Schema> ExampleIntSchema() {
109124
auto f0 = field("f0", int8());
110125
auto f1 = field("f1", uint8());

cpp/src/arrow/flight/test_util.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#pragma once
1919

20-
#include <gmock/gmock.h>
2120
#include <gtest/gtest.h>
2221

2322
#include <cstdint>
@@ -42,20 +41,8 @@ namespace flight {
4241

4342
// ----------------------------------------------------------------------
4443
// Helpers to compare values for equality
45-
46-
inline void AssertEqual(const FlightInfo& expected, const FlightInfo& actual) {
47-
ipc::DictionaryMemo expected_memo;
48-
ipc::DictionaryMemo actual_memo;
49-
ASSERT_OK_AND_ASSIGN(auto ex_schema, expected.GetSchema(&expected_memo));
50-
ASSERT_OK_AND_ASSIGN(auto actual_schema, actual.GetSchema(&actual_memo));
51-
52-
AssertSchemaEqual(*ex_schema, *actual_schema);
53-
ASSERT_EQ(expected.total_records(), actual.total_records());
54-
ASSERT_EQ(expected.total_bytes(), actual.total_bytes());
55-
56-
ASSERT_EQ(expected.descriptor(), actual.descriptor());
57-
ASSERT_THAT(actual.endpoints(), ::testing::ContainerEq(expected.endpoints()));
58-
}
44+
ARROW_FLIGHT_EXPORT
45+
void AssertEqual(const FlightInfo& expected, const FlightInfo& actual);
5946

6047
// ----------------------------------------------------------------------
6148
// Fixture to use for running test servers

0 commit comments

Comments
 (0)