Skip to content

Commit a3ba1a2

Browse files
committed
ARROW-3988: [C++] Do not build unit tests by default, fix building Gandiva unit tests when ARROW_BUILD_TESTS=OFF
I found while working on this that disabling `ARROW_GANDIVA_BUILD_TESTS` would break the build -- I think this was caused by some other changes I made. We should remove that option and instead use the new modular build targets and invoke unit tests using labels. So we would write ``` ninja gandiva # this will build all libraries and unit tests when ARROW_BUILD_TESTS=ON ctest -L gandiva ``` Author: Wes McKinney <wesm+git@apache.org> Closes apache#3156 from wesm/ARROW-3988 and squashes the following commits: 0420f9e <Wes McKinney> Remove arrow::PrimitiveBuilder from builder.rst for now because of Sphinx warning f8a33a5 <Wes McKinney> Fix gandiva test flag c489353 <Wes McKinney> Add ARROW_BUILD_TESTS to appveyor-cpp-test-cmake-script.bat 5c6a332 <Wes McKinney> Do not build unit tests by default, fix building Gandiva unit tests when ARROW_BUILD_TESTS=OFF
1 parent 67506d9 commit a3ba1a2

9 files changed

Lines changed: 44 additions & 21 deletions

File tree

ci/appveyor-cpp-build.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if "%JOB%" == "Static_Crt_Build" (
3434
-DARROW_USE_STATIC_CRT=ON ^
3535
-DARROW_BOOST_USE_SHARED=OFF ^
3636
-DARROW_BUILD_SHARED=OFF ^
37+
-DARROW_BUILD_TESTS=ON ^
3738
-DCMAKE_BUILD_TYPE=Debug ^
3839
-DARROW_TEST_LINKAGE=static ^
3940
-DARROW_CXXFLAGS="/MP" ^
@@ -51,6 +52,7 @@ if "%JOB%" == "Static_Crt_Build" (
5152
-DARROW_USE_STATIC_CRT=ON ^
5253
-DARROW_BOOST_USE_SHARED=OFF ^
5354
-DARROW_BUILD_SHARED=OFF ^
55+
-DARROW_BUILD_TESTS=ON ^
5456
-DCMAKE_BUILD_TYPE=Release ^
5557
-DARROW_TEST_LINKAGE=static ^
5658
-DCMAKE_CXX_FLAGS_RELEASE="/MT %CMAKE_CXX_FLAGS_RELEASE%" ^
@@ -76,6 +78,7 @@ if "%JOB%" == "Build_Debug" (
7678
cmake -G "%GENERATOR%" ^
7779
-DARROW_VERBOSE_THIRDPARTY_BUILD=OFF ^
7880
-DARROW_BOOST_USE_SHARED=OFF ^
81+
-DARROW_BUILD_TESTS=ON ^
7982
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
8083
-DARROW_BUILD_STATIC=OFF ^
8184
-DARROW_CXXFLAGS="/MP" ^

ci/appveyor-cpp-test-cmake-script.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ set FLATBUFFERS_HOME=WrongPath
3232

3333
cmake -G "%GENERATOR%" ^
3434
-DARROW_BOOST_USE_SHARED=OFF ^
35+
-DARROW_BUILD_TESTS=ON ^
3536
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
3637
-DARROW_CXXFLAGS="/MP" ^
3738
.. >nul 2>error.txt
@@ -49,6 +50,7 @@ set GFLAGS_HOME=WrongPath
4950

5051
cmake -G "%GENERATOR%" ^
5152
-DARROW_BOOST_USE_SHARED=OFF ^
53+
-DARROW_BUILD_TESTS=ON ^
5254
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
5355
-DARROW_CXXFLAGS="/MP" ^
5456
.. >nul 2>error.txt
@@ -66,6 +68,7 @@ set SNAPPY_HOME=WrongPath
6668

6769
cmake -G "%GENERATOR%" ^
6870
-DARROW_BOOST_USE_SHARED=OFF ^
71+
-DARROW_BUILD_TESTS=ON ^
6972
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
7073
-DARROW_CXXFLAGS="/MP" ^
7174
.. >nul 2>error.txt
@@ -83,6 +86,7 @@ set ZLIB_HOME=WrongPath
8386

8487
cmake -G "%GENERATOR%" ^
8588
-DARROW_BOOST_USE_SHARED=OFF ^
89+
-DARROW_BUILD_TESTS=ON ^
8690
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
8791
-DARROW_CXXFLAGS="/MP" ^
8892
.. >nul 2>error.txt
@@ -100,6 +104,7 @@ set BROTLI_HOME=WrongPath
100104

101105
cmake -G "%GENERATOR%" ^
102106
-DARROW_BOOST_USE_SHARED=OFF ^
107+
-DARROW_BUILD_TESTS=ON ^
103108
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
104109
-DARROW_CXXFLAGS="/MP" ^
105110
.. >nul 2>error.txt
@@ -117,6 +122,7 @@ set LZ4_HOME=WrongPath
117122

118123
cmake -G "%GENERATOR%" ^
119124
-DARROW_BOOST_USE_SHARED=OFF ^
125+
-DARROW_BUILD_TESTS=ON ^
120126
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
121127
-DARROW_CXXFLAGS="/MP" ^
122128
.. >nul 2>error.txt
@@ -134,6 +140,7 @@ set ZSTD_HOME=WrongPath
134140

135141
cmake -G "%GENERATOR%" ^
136142
-DARROW_BOOST_USE_SHARED=OFF ^
143+
-DARROW_BUILD_TESTS=ON ^
137144
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
138145
-DARROW_CXXFLAGS="/MP" ^
139146
.. >nul 2>error.txt
@@ -158,6 +165,7 @@ pushd %BUILD_DIR%
158165
set ARROW_BUILD_TOOLCHAIN=%CONDA_PREFIX%\Library
159166
cmake -G "%GENERATOR%" ^
160167
-DARROW_BOOST_USE_SHARED=OFF ^
168+
-DARROW_BUILD_TESTS=ON ^
161169
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
162170
-DARROW_CXXFLAGS="/MP" ^
163171
.. 2>output.txt

ci/cpp-msvc-build-main.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ cmake -G "%GENERATOR%" %CMAKE_ARGS% ^
4848
-DARROW_BOOST_USE_SHARED=OFF ^
4949
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
5050
-DARROW_BUILD_STATIC=OFF ^
51+
-DARROW_BUILD_TESTS=ON ^
5152
-DARROW_CXXFLAGS="%ARROW_CXXFLAGS%" ^
5253
-DCMAKE_CXX_FLAGS_RELEASE="/MD %CMAKE_CXX_FLAGS_RELEASE%" ^
5354
-DARROW_PARQUET=ON ^

ci/travis_before_script_cpp.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ if [ "$only_library_mode" == "no" ]; then
4141
fi
4242

4343
CMAKE_COMMON_FLAGS="\
44-
-DARROW_BUILD_BENCHMARKS=ON \
4544
-DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL \
4645
-DARROW_NO_DEPRECATED_API=ON \
4746
-DARROW_EXTRA_ERROR_CONTEXT=ON"
@@ -61,7 +60,13 @@ pushd $ARROW_CPP_BUILD_DIR
6160
if [ $only_library_mode == "yes" ]; then
6261
CMAKE_COMMON_FLAGS="\
6362
$CMAKE_COMMON_FLAGS \
64-
-DARROW_BUILD_TESTS=OFF \
63+
-DARROW_BUILD_UTILITIES=OFF \
64+
-DARROW_INSTALL_NAME_RPATH=OFF"
65+
else
66+
CMAKE_COMMON_FLAGS="\
67+
$CMAKE_COMMON_FLAGS \
68+
-DARROW_BUILD_BENCHMARKS=ON \
69+
-DARROW_BUILD_TESTS=ON \
6570
-DARROW_BUILD_UTILITIES=OFF \
6671
-DARROW_INSTALL_NAME_RPATH=OFF"
6772
fi
@@ -92,6 +97,9 @@ fi
9297

9398
if [ $ARROW_TRAVIS_GANDIVA == "1" ]; then
9499
CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GANDIVA=ON"
100+
if [ $only_library_mode == "no" ]; then
101+
CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GANDIVA_BUILD_TESTS=ON"
102+
fi
95103
fi
96104

97105
if [ $ARROW_TRAVIS_VALGRIND == "1" ]; then

cpp/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
115115
OFF)
116116

117117
option(ARROW_BUILD_TESTS
118-
"Build the Arrow googletest unit tests"
119-
ON)
118+
"Build the Arrow googletest unit tests, default OFF"
119+
OFF)
120+
121+
option(ARROW_BUILD_BENCHMARKS
122+
"Build the Arrow micro benchmarks, default OFF"
123+
OFF)
120124

121125
set(ARROW_TEST_LINKAGE "shared" CACHE STRING
122126
"Linkage of Arrow libraries with unit tests executables. \
@@ -126,10 +130,6 @@ static|shared (default shared)")
126130
"Only build unit tests having the indicated label or labels. \
127131
Pass multiple labels by dividing with semicolons")
128132

129-
option(ARROW_BUILD_BENCHMARKS
130-
"Build the Arrow micro benchmarks"
131-
OFF)
132-
133133
option(ARROW_NO_DEPRECATED_API
134134
"Exclude deprecated APIs from build"
135135
OFF)
@@ -322,7 +322,7 @@ Always OFF if building binaries"
322322

323323
option(ARROW_GANDIVA_BUILD_TESTS
324324
"Build the Gandiva googletest unit tests"
325-
ON)
325+
OFF)
326326

327327
endif()
328328

cpp/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Simple debug build:
6464
cd arrow/cpp
6565
mkdir debug
6666
cd debug
67-
cmake ..
67+
cmake -DARROW_BUILD_TESTS=ON ..
6868
make unittest
6969

7070
Simple release build:
@@ -73,10 +73,14 @@ Simple release build:
7373
cd arrow/cpp
7474
mkdir release
7575
cd release
76-
cmake .. -DCMAKE_BUILD_TYPE=Release
76+
cmake -DARROW_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release ..
7777
make unittest
7878

79-
Detailed unit test logs will be placed in the build directory under `build/test-logs`.
79+
If you do not need to build the test suite, you can omit the
80+
`ARROW_BUILD_TESTS` option (the default is not to build the unit tests).
81+
82+
Detailed unit test logs will be placed in the build directory under
83+
`build/test-logs`.
8084

8185
On some Linux distributions, running the test suite might require setting an
8286
explicit locale. If you see any locale-related errors, try setting the
@@ -132,7 +136,7 @@ not use the macro.
132136
Follow the directions for simple build except run cmake
133137
with the `--ARROW_BUILD_BENCHMARKS` parameter set correctly:
134138

135-
cmake -DARROW_BUILD_BENCHMARKS=ON ..
139+
cmake -DARROW_BUILD_TESTS=ON -DARROW_BUILD_BENCHMARKS=ON ..
136140

137141
and instead of make unittest run either `make; ctest` to run both unit tests
138142
and benchmarks or `make benchmark` to run only the benchmark tests.
@@ -265,7 +269,7 @@ The optional `gandiva` libraries and tests can be built by passing
265269
`-DARROW_GANDIVA=on`.
266270

267271
```shell
268-
cmake .. -DARROW_GANDIVA=on
272+
cmake .. -DARROW_GANDIVA=ON -DARROW_GANDIVA_BUILD_TESTS=ON
269273
make
270274
ctest -L gandiva
271275
```

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,11 @@ message(STATUS "double-conversion static library: ${DOUBLE_CONVERSION_STATIC_LIB
525525
# ----------------------------------------------------------------------
526526
# Google gtest & gflags
527527

528-
if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
529-
add_custom_target(unittest ctest -L unittest)
528+
add_custom_target(unittest ctest -L unittest)
529+
add_custom_target(benchmark ctest -L benchmark)
530530

531+
if(ARROW_BUILD_TESTS OR ARROW_GANDIVA_BUILD_TESTS
532+
OR ARROW_BUILD_BENCHMARKS)
531533
if("${GTEST_HOME}" STREQUAL "")
532534
if(APPLE)
533535
set(GTEST_CMAKE_CXX_FLAGS "-fPIC -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes")
@@ -627,7 +629,6 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
627629
endif()
628630

629631
if(ARROW_BUILD_BENCHMARKS)
630-
add_custom_target(benchmark ctest -L benchmark)
631632

632633
if("$ENV{GBENCHMARK_HOME}" STREQUAL "")
633634
if(NOT MSVC)

cpp/src/arrow/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ if (ARROW_BUILD_STATIC AND WIN32)
213213
target_compile_definitions(arrow_static PUBLIC ARROW_STATIC)
214214
endif()
215215

216-
if (ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
216+
if (ARROW_BUILD_TESTS OR ARROW_GANDIVA_BUILD_TESTS
217+
OR ARROW_BUILD_BENCHMARKS)
217218
# that depend on gtest
218219
ADD_ARROW_LIB(arrow_testing
219220
SOURCES test-util.cc

docs/source/cpp/api/builder.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ Concrete builder subclasses
3131
.. doxygenclass:: arrow::BooleanBuilder
3232
:members:
3333

34-
.. doxygenclass:: arrow::PrimitiveBuilder
35-
:members:
36-
3734
.. doxygenclass:: arrow::NumericBuilder
3835
:members:
3936

0 commit comments

Comments
 (0)