Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Make Arrow C++ dependency optional #677

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Nov 9, 2024

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Nov 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.63%. Comparing base (44e8eb9) to head (e7959e0).
Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #677      +/-   ##
==========================================
+ Coverage   86.29%   87.63%   +1.34%     
==========================================
  Files          94      101       +7     
  Lines       13604    14537     +933     
==========================================
+ Hits        11739    12739    +1000     
+ Misses       1865     1798      -67     
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you're still working on this, but just two high level comments to think about:

  • We probably want a CMake option of -DNANOARROW_TESTS_WITH_ARROW (where if it's ON, configuration will fail if Arrow is not found, and if it's OFF, tests are never built with arrow). Having it be automatic makes it relatively easy to accidentally think you are testing with Arrow C++ when CMake actually failed to locate it.
  • There are a few tests where the entire test is useless, but many of them only have Arrow C++ as a small component (notably: the schema init ones). It doesn't have to be perfect at the end of this PR, but before the next release we will ideally have full (or at least not reduced) test coverage without any of the Arrow C++ integration tests running.
  • An alternative to compiling tests with a define is to move the (portions of) tests that need Arrow C++ to separate files (Arrow C++-specific integration tests, perhaps under integration/).

CMakeLists.txt Outdated
Comment on lines 430 to 431
# TODO: does this propoagate to projects using as a subproject?
add_compile_definitions("-DNANOARROW_ARROW_FOUND")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does. You probably want target_compile_definitions(xxxx_test PRIVATE -DNANOARROW_ARROW_FOUND) for every test because the tests are what actually need this define set. You could do something fancy like we do with the nanoarrow_coverage_config (define an interface target that the tests "link to"), or bite the bullet and use a foreach() loop to link tests (sort of like you do in the meson config), which we probably should have done a while ago anyway.

@@ -517,6 +520,27 @@ if(NANOARROW_BUILD_TESTS)
gmock_main
nanoarrow_coverage_config)

list(APPEND
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just kept the loop scoped to adding the define for now, although there is (as you've already mentioned) potential to use this for other parts of the config

@@ -1719,7 +1812,8 @@ TEST(ArrayTest, ArrayTestAppendToRunEndEncodedArray) {
EXPECT_EQ(ArrowArrayFinishBuilding(&array, NANOARROW_VALIDATION_LEVEL_FULL, &error),
NANOARROW_OK);

#if !defined(ARROW_VERSION_MAJOR) || ARROW_VERSION_MAJOR < 12
#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) || !defined(ARROW_VERSION_MAJOR) || \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add this here or leave as is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either is OK by me! I think it makes sense that if the version isn't defined that we didn't build with arrow C++ (but also it might make searching for all the Arrow C++ conditional test blocks easier to include the extra check).

CMakeLists.txt Outdated
find_package(Arrow REQUIRED)
message(STATUS "Arrow version: ${ARROW_VERSION}")
message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")
find_package(Arrow)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
find_package(Arrow)
if(NANOARROW_BUILD_TESTS_WITH_ARROW)
find_package(Arrow REQUIRED)
endif()

...maybe?

@@ -21,6 +21,7 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"NANOARROW_BUILD_TESTS": "ON"
"NANOARROW_BUILD_TESTS_WITH_ARROW": "ON"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably leave this out of the defaults (I would keep it in my own CMakeUserPresets, but most people wouldn't need this when making their first contribution).

@@ -243,12 +243,14 @@ test_cmake_project() {

test_c() {
show_header "Build and test C library"
test_cmake_project build . -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_IPC=ON
test_cmake_project build . -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_IPC=ON \
-DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For verification it would be useful to default this to OFF (because it significantly improves the instructions required for verifying). It can always be turned on (and perhaps we should turn it on in .github/workflows/verify.yaml) via the extra cmake args.

@@ -1719,7 +1812,8 @@ TEST(ArrayTest, ArrayTestAppendToRunEndEncodedArray) {
EXPECT_EQ(ArrowArrayFinishBuilding(&array, NANOARROW_VALIDATION_LEVEL_FULL, &error),
NANOARROW_OK);

#if !defined(ARROW_VERSION_MAJOR) || ARROW_VERSION_MAJOR < 12
#if !defined(NANOARROW_BUILD_TESTS_WITH_ARROW) || !defined(ARROW_VERSION_MAJOR) || \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either is OK by me! I think it makes sense that if the version isn't defined that we didn't build with arrow C++ (but also it might make searching for all the Arrow C++ conditional test blocks easier to include the extra check).

@WillAyd WillAyd force-pushed the optional-arrow branch 2 times, most recently from f0b8ca9 to 01ce608 Compare November 14, 2024 19:26
@WillAyd WillAyd marked this pull request as ready for review November 14, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants