Skip to content

Commit

Permalink
Build googletest only if testing is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed May 20, 2022
1 parent d7f683f commit 6d6beb9
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ if(VELOX_BUILD_TESTING AND NOT VELOX_ENABLE_DUCKDB)
)
endif()

if(VELOX_BUILD_TESTING)
add_definitions(-DVELOX_BUILD_TESTING)
endif()

include_directories(SYSTEM velox)
include_directories(SYSTEM velox/external)
include_directories(SYSTEM velox/external/duckdb)
Expand Down
8 changes: 7 additions & 1 deletion third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_subdirectory(googletest)

# Benchmarks and tests at some places are coupled which is not great. See
# velox/vector/CMakeLists.txt. TODO: Decouple.
if(VELOX_BUILD_TESTING OR VELOX_ENABLE_BENCHMARKS_BASIC)
add_subdirectory(googletest)
endif()

add_subdirectory(xsimd)
2 changes: 0 additions & 2 deletions velox/benchmarks/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ set(velox_benchmark_deps
${FOLLY}
${FOLLY_BENCHMARK}
${DOUBLE_CONVERSION}
gtest
gtest_main
${gflags_LIBRARIES}
glog::glog)

Expand Down
3 changes: 0 additions & 3 deletions velox/benchmarks/tpch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ target_link_libraries(
velox_type
velox_caching
velox_vector
velox_vector_test_lib
gtest
gtest_main
${FOLLY_WITH_DEPENDENCIES}
${FOLLY_BENCHMARK}
${FMT})
23 changes: 23 additions & 0 deletions velox/common/base/GTestMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#ifdef VELOX_BUILD_TESTING
#include <gtest/gtest_prod.h>
#else
#define FRIEND_TEST(X, Y)
#endif
4 changes: 4 additions & 0 deletions velox/common/memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ add_library(

target_link_libraries(velox_memory velox_flag_definitions velox_exception gtest
${FOLLY_WITH_DEPENDENCIES})

if(VELOX_BUILD_TESTING)
target_link_libraries(velox_memory gtest)
endif()
3 changes: 1 addition & 2 deletions velox/common/memory/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
#include <string>

#include <fmt/format.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest_prod.h>

#include "folly/CPortability.h"
#include "folly/Likely.h"
#include "folly/Random.h"
#include "folly/SharedMutex.h"
#include "folly/experimental/FunctionScheduler.h"
#include "velox/common/base/GTestMacros.h"
#include "velox/common/memory/MemoryUsage.h"
#include "velox/common/memory/MemoryUsageTracker.h"

Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/common/ChainedBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

#pragma once

#include <gtest/gtest_prod.h>
#include <bitset>
#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/common/DataBuffer.h"

namespace facebook {
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/common/IntEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#pragma once

#include <folly/Varint.h>
#include <gtest/gtest_prod.h>
#include "velox/common/base/BitUtil.h"
#include "velox/common/base/GTestMacros.h"
#include "velox/common/base/Nulls.h"
#include "velox/common/encode/Coding.h"
#include "velox/dwio/dwrf/common/IntCodecCommon.h"
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/common/RLEv1.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <gtest/gtest_prod.h>
#include "velox/common/base/GTestMacros.h"
#include "velox/common/base/Nulls.h"
#include "velox/dwio/dwrf/common/Adaptor.h"
#include "velox/dwio/dwrf/common/DecoderUtil.h"
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/common/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <gtest/gtest_prod.h>
#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/common/exception/Exception.h"

namespace facebook::velox::dwrf {
Expand Down
3 changes: 1 addition & 2 deletions velox/dwio/dwrf/reader/StripeDictionaryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

#pragma once

#include <gtest/gtest_prod.h>

#include <folly/Function.h>

#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/dwrf/common/Common.h"
#include "velox/dwio/dwrf/common/IntDecoder.h"
#include "velox/vector/BaseVector.h"
Expand Down
3 changes: 1 addition & 2 deletions velox/dwio/dwrf/writer/ColumnWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

#pragma once

#include "gtest/gtest_prod.h"

#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/dwrf/common/ByteRLE.h"
#include "velox/dwio/dwrf/common/Common.h"
#include "velox/dwio/dwrf/common/IntEncoder.h"
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/writer/IndexBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <gtest/gtest_prod.h>
#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/dwrf/common/OutputStream.h"
#include "velox/dwio/dwrf/common/wrap/dwrf-proto-wrapper.h"
#include "velox/dwio/dwrf/writer/StatisticsBuilder.h"
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/writer/IntegerDictionaryEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#pragma once

#include <folly/container/F14Set.h>
#include <gtest/gtest_prod.h>
#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/common/DataBuffer.h"
#include "velox/dwio/dwrf/common/IntEncoder.h"
#include "velox/dwio/dwrf/writer/DictionaryEncodingUtils.h"
Expand Down
3 changes: 2 additions & 1 deletion velox/dwio/dwrf/writer/StringDictionaryEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#include <folly/container/F14Set.h>
#include <folly/hash/Checksum.h>
#include <gtest/gtest_prod.h>

#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/common/DataBuffer.h"

namespace facebook::velox::dwrf {
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/writer/WriterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include "gtest/gtest_prod.h"
#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/dwrf/writer/WriterContext.h"
#include "velox/dwio/dwrf/writer/WriterSink.h"

Expand Down
3 changes: 1 addition & 2 deletions velox/dwio/dwrf/writer/WriterContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

#pragma once

#include <gtest/gtest_prod.h>

#include "velox/common/base/GTestMacros.h"
#include "velox/common/time/CpuWallTimer.h"
#include "velox/dwio/dwrf/common/Compression.h"
#include "velox/dwio/dwrf/writer/IndexBuilder.h"
Expand Down
3 changes: 1 addition & 2 deletions velox/dwio/dwrf/writer/WriterShared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <iterator>
#include <limits>

#include <gtest/gtest_prod.h>

#include "velox/common/base/GTestMacros.h"
#include "velox/dwio/dwrf/common/Encryption.h"
#include "velox/dwio/dwrf/common/wrap/dwrf-proto-wrapper.h"
#include "velox/dwio/dwrf/proto/dwrf_proto.pb.h"
Expand Down
10 changes: 2 additions & 8 deletions velox/expression/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
# limitations under the License.

set(BENCHMARK_DEPENDENCIES
velox_functions_test_lib
velox_exec
velox_exec_test_util
gtest
gtest_main
${gflags_LIBRARIES}
${FOLLY_WITH_DEPENDENCIES}
${FOLLY_BENCHMARK})
velox_functions_test_lib velox_exec velox_exec_test_util
${gflags_LIBRARIES} ${FOLLY_WITH_DEPENDENCIES} ${FOLLY_BENCHMARK})

add_executable(velox_benchmark_call_null_free_no_nulls
CallNullFreeBenchmark.cpp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ target_link_libraries(
velox_dwio_common_exception
${FOLLY_WITH_DEPENDENCIES}
${FOLLY_BENCHMARK}
gtest
gtest_main
${GFLAGS_LIBRARIES})
10 changes: 2 additions & 8 deletions velox/functions/prestosql/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
# limitations under the License.

set(BENCHMARK_DEPENDENCIES_NO_FUNC
velox_functions_test_lib
velox_exec
velox_exec_test_util
gtest
gtest_main
${gflags_LIBRARIES}
${FOLLY_WITH_DEPENDENCIES}
${FOLLY_BENCHMARK})
velox_functions_test_lib velox_exec velox_exec_test_util
${gflags_LIBRARIES} ${FOLLY_WITH_DEPENDENCIES} ${FOLLY_BENCHMARK})

set(BENCHMARK_DEPENDENCIES
velox_functions_prestosql velox_functions_lib velox_vector_fuzzer
Expand Down

0 comments on commit 6d6beb9

Please sign in to comment.