Skip to content

Commit 80f4a7a

Browse files
committed
Add option for testing without Arrow
1 parent 3ffc2f7 commit 80f4a7a

16 files changed

+78
-60
lines changed

.github/workflows/build-and-test-device.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ jobs:
9898
cd build
9999
export VERBOSE=1
100100
cmake .. -DCMAKE_BUILD_TYPE=Debug -DNANOARROW_DEVICE=ON \
101-
-DNANOARROW_BUILD_TESTS=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
102-
${{ matrix.config.cmake_args }}
101+
-DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON \
102+
-DCMAKE_PREFIX_PATH="${ARROW_PATH}" ${{ matrix.config.cmake_args }}
103103
104104
cmake --build .
105105

.github/workflows/build-and-test-ipc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ jobs:
9191
cd build
9292
9393
cmake .. -DCMAKE_BUILD_TYPE=Debug -DNANOARROW_BUILD_TESTS=ON \
94-
-DNANOARROW_IPC=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
95-
${{ matrix.config.cmake_args }}
94+
-DNANOARROW_BUILD_TESTS_WITH_ARROW=ON -DNANOARROW_IPC=ON \
95+
-DCMAKE_PREFIX_PATH="${ARROW_PATH}" ${{ matrix.config.cmake_args }}
9696
9797
cmake --build .
9898

.github/workflows/build-and-test.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ jobs:
8282
cd build
8383
8484
cmake .. -DNANOARROW_BUILD_TESTS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
85-
-DCMAKE_PREFIX_PATH="${ARROW_PATH}" ${{ matrix.config.cmake_args }}
85+
-DNANOARROW_BUILD_TESTS_WITH_ARROW=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
86+
${{ matrix.config.cmake_args }}
8687
8788
cmake --build .
8889
@@ -167,8 +168,8 @@ jobs:
167168

168169
- name: Build nanoarrow
169170
run: |
170-
cmake -S . -B build -DNANOARROW_BUILD_TESTS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
171-
-DCMAKE_PREFIX_PATH="${ARROW_PATH}"
171+
cmake -S . -B build -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=OFF \
172+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}"
172173
173174
cmake --build build
174175

.github/workflows/clang-tidy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ jobs:
6666
cd build
6767
6868
cmake .. -DNANOARROW_DEVICE=ON -DNANOARROW_IPC=ON \
69-
-DNANOARROW_BUILD_TESTS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
70-
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
71-
-DCMAKE_PREFIX_PATH="${ARROW_PATH}"
69+
-DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON \
70+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Debug \
71+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}"
7272
7373
cmake --build .
7474

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ option(NANOARROW_DEVICE_WITH_CUDA "Build CUDA libraries" OFF)
4545
# Development options
4646
option(NANOARROW_BUILD_APPS "Build utility applications" OFF)
4747
option(NANOARROW_BUILD_TESTS "Build tests" OFF)
48+
option(NANOARROW_BUILD_TESTS_WITH_ARROW "Build tests that require Arrow" OFF)
4849
option(NANOARROW_BUILD_BENCHMARKS "Build benchmarks" OFF)
4950
option(NANOARROW_BUILD_INTEGRATION_TESTS
5051
"Build cross-implementation Arrow integration tests" OFF)
@@ -428,7 +429,9 @@ if(NANOARROW_BUILD_TESTS)
428429
message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}")
429430

430431
# TODO: does this propoagate to projects using as a subproject?
431-
add_compile_definitions("-DNANOARROW_ARROW_FOUND")
432+
if(NANOARROW_BUILD_TESTS_WITH_ARROW)
433+
add_compile_definitions("-DNANOARROW_BUILD_TESTS_WITH_ARROW")
434+
endif()
432435

433436
# Give caller the option to link a static version of Arrow C++
434437
if(NANOARROW_ARROW_STATIC)

CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"cacheVariables": {
2222
"CMAKE_BUILD_TYPE": "Debug",
2323
"NANOARROW_BUILD_TESTS": "ON"
24+
"NANOARROW_BUILD_TESTS_WITH_ARROW": "ON"
2425
}
2526
},
2627
{

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,23 @@ cmake ..
127127
cmake --build .
128128
```
129129

130-
Building nanoarrow with tests currently requires [Arrow C++](https://arrow.apache.org/install/).
131-
If installed via a system package manager like `apt`, `dnf`, or `brew`, the tests can be
132-
built with:
130+
To build nanoarrow along with tests run:
133131

134132
```sh
135133
mkdir build && cd build
136134
cmake .. -DNANOARROW_BUILD_TESTS=ON
137135
cmake --build .
138136
```
139137

138+
If you are able to install [Arrow C++](https://arrow.apache.org/install/) you can enable
139+
more testing:
140+
141+
```sh
142+
mkdir build && cd build
143+
cmake .. -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
144+
cmake --build .
145+
```
146+
140147
Tests can be run with `ctest`.
141148

142149
### Building with Meson

ci/scripts/coverage.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function main() {
7474

7575
cmake "${TARGET_NANOARROW_DIR}" \
7676
-DNANOARROW_DEVICE=ON -DNANOARROW_IPC=ON \
77-
-DNANOARROW_BUILD_TESTS=ON -DNANOARROW_CODE_COVERAGE=ON
77+
-DNANOARROW_BUILD_TESTS=ON -DNANOARROW_BUILD_TESTS_WITH_ARROW=ON \
78+
-DNANOARROW_CODE_COVERAGE=ON
7879
cmake --build .
7980
CTEST_OUTPUT_ON_FAILURE=1 ctest .
8081

dev/release/verify-release-candidate.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,14 @@ test_cmake_project() {
243243

244244
test_c() {
245245
show_header "Build and test C library"
246-
test_cmake_project build . -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_IPC=ON
246+
test_cmake_project build . -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_IPC=ON \
247+
-DNANOARROW_BUILD_TESTS_WITH_ARROW=ON
247248
}
248249

249250
test_c_bundled() {
250251
show_header "Build test bundled C library"
251-
test_cmake_project build-bundled . -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_IPC=ON -DNANOARROW_BUNDLE=ON
252+
test_cmake_project build-bundled . -DNANOARROW_BUILD_TESTS=ON -DNANOARROW_IPC=ON \
253+
-DNANOARROW_BUILD_TESTS_WITH_ARROW=ON -DNANOARROW_BUNDLE=ON
252254
}
253255

254256
test_r() {

meson.build

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ add_project_arguments(
4848

4949
# The system include suppresses compilation warnings from Arrow
5050
arrow_dep = dependency('arrow', include_type: 'system', required: false)
51-
if arrow_dep.found()
52-
add_project_arguments('-DNANOARROW_ARROW_FOUND', language : 'c')
53-
add_project_arguments('-DNANOARROW_ARROW_FOUND', language : 'cpp')
51+
if get_option('tests_with_arrow') and not arrow_dep.found()
52+
error('tests_with_arrow=true but could not find Arrow')
53+
elif get_option('tests_with_arrow')
54+
add_project_arguments('-DNANOARROW_BUILD_TESTS_WITH_ARROW', language : 'c')
55+
add_project_arguments('-DNANOARROW_BUILD_TESTS_WITH_ARROW', language : 'cpp')
5456
endif
5557

5658
if get_option('buildtype') in ['debug', 'debugoptimized']

meson.options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
option('tests', type: 'boolean', description: 'Build tests', value: false)
19+
option('tests_with_arrow', type: 'boolean', description: 'Build tests with Arrow', value: false)
1920
option('benchmarks', type: 'boolean', description: 'Build benchmarks', value: false)
2021
option('apps', type: 'boolean', description: 'Build utility applications', value: false)
2122
option('ipc', type: 'boolean', description: 'Build IPC libraries', value: false)

src/nanoarrow/common/array_test.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <cmath>
2121
#include <cstdint>
2222

23-
#if defined(NANOARROW_ARROW_FOUND)
23+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
2424
#include <arrow/array.h>
2525
#include <arrow/array/builder_binary.h>
2626
#include <arrow/array/builder_decimal.h>
@@ -40,7 +40,7 @@
4040

4141
#include "nanoarrow/nanoarrow.hpp"
4242

43-
#if defined(NANOARROW_ARROW_FOUND)
43+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
4444
using namespace arrow;
4545
#endif
4646
using namespace nanoarrow::literals;
@@ -50,7 +50,7 @@ using testing::ElementsAre;
5050
// Lightweight versions of ArrowTesting's ARROW_EXPECT_OK. This
5151
// version accomplishes the task of making sure the status message
5252
// ends up in the ctests log.
53-
#if defined(NANOARROW_ARROW_FOUND)
53+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
5454
void ARROW_EXPECT_OK(Status status) {
5555
if (!status.ok()) {
5656
throw std::runtime_error(status.message());
@@ -386,7 +386,7 @@ INSTANTIATE_TEST_SUITE_P(NanoarrowIpcTest, UnparameterizedTypeTestFixture,
386386
::testing::Values(NANOARROW_TYPE_NA, NANOARROW_TYPE_INT32,
387387
NANOARROW_TYPE_BINARY, NANOARROW_TYPE_STRUCT));
388388

389-
#if defined(NANOARROW_ARROW_FOUND)
389+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
390390
TEST(ArrayTest, ArrayTestAppendToNullArray) {
391391
struct ArrowArray array;
392392
ASSERT_EQ(ArrowArrayInitFromType(&array, NANOARROW_TYPE_NA), NANOARROW_OK);
@@ -585,7 +585,7 @@ TEST(ArrayTest, ArrayTestAppendEmptyToString) {
585585
ArrowArrayRelease(&array);
586586
}
587587

588-
#if defined(NANOARROW_ARROW_FOUND)
588+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
589589
TEST(ArrayTest, ArrayTestAppendToUInt64Array) {
590590
struct ArrowArray array;
591591

@@ -639,7 +639,7 @@ TEST(ArrayTest, ArrayTestAppendToUInt32Array) {
639639
ArrowArrayRelease(&array);
640640
}
641641

642-
#if defined(NANOARROW_ARROW_FOUND)
642+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
643643
TEST(ArrayTest, ArrayTestAppendToUInt16Array) {
644644
struct ArrowArray array;
645645

@@ -1107,7 +1107,7 @@ TEST(ArrayTest, ArrayTestAppendToIntervalArrayYearMonth) {
11071107
ArrowArrayRelease(&array);
11081108
}
11091109

1110-
#if defined(NANOARROW_ARROW_FOUND)
1110+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
11111111
TEST(ArrayTest, ArrayTestAppendToIntervalArrayDayTime) {
11121112
struct ArrowArray array;
11131113

@@ -1549,7 +1549,7 @@ TEST(ArrayTest, ArrayTestAppendToListArrayErrors) {
15491549
ArrowSchemaRelease(&schema);
15501550
}
15511551

1552-
#if defined(NANOARROW_ARROW_FOUND)
1552+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
15531553
TEST(ArrayTest, ArrayTestAppendToStructArray) {
15541554
struct ArrowArray array;
15551555
struct ArrowSchema schema;
@@ -1792,7 +1792,7 @@ TEST(ArrayTest, ArrayTestUnionUtils) {
17921792
EXPECT_FALSE(_ArrowUnionTypeIdsWillEqualChildIndices("0,2", 2));
17931793
}
17941794

1795-
#if defined(NANOARROW_ARROW_FOUND)
1795+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
17961796
TEST(ArrayTest, ArrayTestAppendToDenseUnionArray) {
17971797
struct ArrowArray array;
17981798
struct ArrowSchema schema;
@@ -3268,7 +3268,7 @@ TEST(ArrayTest, ArrayViewTestSparseUnionGet) {
32683268
// the "value type" that would correspond to what ArrowArrayViewGetDoubleUnsafe()
32693269
// or ArrowArrayAppendDouble() do since they operate on the logical/represented
32703270
// value.
3271-
#if defined(NANOARROW_ARROW_FOUND)
3271+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
32723272
template <typename TypeClass, typename BuilderValueT>
32733273
BuilderValueT logical_value_to_builder_value(int64_t value) {
32743274
return static_cast<BuilderValueT>(value);
@@ -3439,7 +3439,7 @@ TEST(ArrayViewTest, ArrayViewTestGetFloat16) {
34393439
ArrowSchemaRelease(&schema);
34403440
}
34413441

3442-
#if defined(NANOARROW_ARROW_FOUND)
3442+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
34433443
template <typename BuilderClass>
34443444
void TestGetFromBinary(BuilderClass& builder) {
34453445
struct ArrowArray array;
@@ -3655,7 +3655,7 @@ TEST(ArrayViewTest, ArrayViewTestGetIntervalYearMonth) {
36553655
ArrowArrayRelease(&array);
36563656
}
36573657

3658-
#if defined(NANOARROW_ARROW_FOUND)
3658+
#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
36593659
TEST(ArrayViewTest, ArrayViewTestGetIntervalDayTime) {
36603660
struct ArrowArray array;
36613661
struct ArrowSchema schema;

0 commit comments

Comments
 (0)