This is an automated email from the ASF dual-hosted git repository.
marong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 39ca883d56 [GLUTEN-10595][VL] Separate cpp test utils from the utils
directory (#10596)
39ca883d56 is described below
commit 39ca883d566e773121cf1ffedec588925f1f55ed
Author: Rong Ma <[email protected]>
AuthorDate: Tue Sep 2 07:20:13 2025 +0100
[GLUTEN-10595][VL] Separate cpp test utils from the utils directory (#10596)
---
cpp/CMakeLists.txt | 1 +
cpp/velox/CMakeLists.txt | 11 +++++++++--
cpp/velox/benchmarks/GenericBenchmark.cc | 9 ++++-----
cpp/velox/tests/VeloxColumnarBatchSerializerTest.cc | 2 +-
cpp/velox/tests/VeloxRowToColumnarTest.cc | 2 +-
cpp/velox/tests/VeloxRssSortShuffleWriterTest.cc | 5 +----
cpp/velox/tests/VeloxShuffleWriterSpillTest.cc | 2 +-
cpp/velox/tests/VeloxShuffleWriterTest.cc | 4 ++--
cpp/velox/tests/VeloxShuffleWriterTestBase.h | 2 +-
cpp/velox/{ => tests}/utils/LocalRssClient.cc | 2 +-
cpp/velox/{ => tests}/utils/LocalRssClient.h | 0
cpp/velox/{ => tests}/utils/TestAllocationListener.cc | 2 +-
cpp/velox/{ => tests}/utils/TestAllocationListener.h | 0
cpp/{core => velox/tests}/utils/TestUtils.h | 17 -----------------
14 files changed, 23 insertions(+), 36 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 1399525311..923ef2751d 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -46,6 +46,7 @@ option(BUILD_VELOX_BACKEND "Build Velox backend" ON)
option(BUILD_TESTS "Build Tests" OFF)
option(BUILD_EXAMPLES "Build Examples" OFF)
option(BUILD_BENCHMARKS "Build Benchmarks" OFF)
+option(BUILD_TEST_UTILS "Build utils for tests/benchmarks" OFF)
option(ENABLE_JEMALLOC_STATS "Prints Jemalloc stats for debugging" OFF)
option(BUILD_GLOG "Build Glog from Source" OFF)
option(ENABLE_QAT "Enable QAT for de/compression" OFF)
diff --git a/cpp/velox/CMakeLists.txt b/cpp/velox/CMakeLists.txt
index 30fd383c9b..f5f20024ec 100644
--- a/cpp/velox/CMakeLists.txt
+++ b/cpp/velox/CMakeLists.txt
@@ -189,8 +189,6 @@ set(VELOX_SRCS
udf/UdfLoader.cc
utils/Common.cc
utils/ConfigExtractor.cc
- utils/LocalRssClient.cc
- utils/TestAllocationListener.cc
utils/VeloxArrowUtils.cc
utils/VeloxBatchResizer.cc
utils/VeloxWholeStageDumper.cc
@@ -209,6 +207,15 @@ if(ENABLE_ENHANCED_FEATURES)
compute/iceberg/IcebergWriter.cc)
endif()
+if(BUILD_TESTS OR BUILD_BENCHMARKS)
+ set(BUILD_TEST_UTILS ON)
+endif()
+
+if(BUILD_TEST_UTILS)
+ list(APPEND VELOX_SRCS tests/utils/LocalRssClient.cc
+ tests/utils/TestAllocationListener.cc)
+endif()
+
add_library(velox SHARED ${VELOX_SRCS})
if(ENABLE_GLUTEN_VCPKG AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
diff --git a/cpp/velox/benchmarks/GenericBenchmark.cc
b/cpp/velox/benchmarks/GenericBenchmark.cc
index 98c92b732b..ee91aa950c 100644
--- a/cpp/velox/benchmarks/GenericBenchmark.cc
+++ b/cpp/velox/benchmarks/GenericBenchmark.cc
@@ -35,10 +35,10 @@
#include "shuffle/LocalPartitionWriter.h"
#include "shuffle/VeloxShuffleWriter.h"
#include "shuffle/rss/RssPartitionWriter.h"
+#include "tests/utils/LocalRssClient.h"
+#include "tests/utils/TestAllocationListener.h"
#include "utils/Exception.h"
-#include "utils/LocalRssClient.h"
#include "utils/StringUtil.h"
-#include "utils/TestAllocationListener.h"
#include "utils/Timer.h"
#include "utils/VeloxArrowUtils.h"
#include "velox/exec/PlanNodeStats.h"
@@ -429,9 +429,8 @@ auto BM_Generic = [](::benchmark::State& state,
std::vector<FileReaderIterator*> inputItersRaw;
if (!dataFiles.empty()) {
for (const auto& input : dataFiles) {
- inputIters.push_back(
- FileReaderIterator::getInputIteratorFromFileReader(
- readerType, input, FLAGS_batch_size,
runtime->memoryManager()->getLeafMemoryPool()));
+
inputIters.push_back(FileReaderIterator::getInputIteratorFromFileReader(
+ readerType, input, FLAGS_batch_size,
runtime->memoryManager()->getLeafMemoryPool()));
}
std::transform(
inputIters.begin(),
diff --git a/cpp/velox/tests/VeloxColumnarBatchSerializerTest.cc
b/cpp/velox/tests/VeloxColumnarBatchSerializerTest.cc
index 19c340effa..7833b0cfea 100644
--- a/cpp/velox/tests/VeloxColumnarBatchSerializerTest.cc
+++ b/cpp/velox/tests/VeloxColumnarBatchSerializerTest.cc
@@ -17,11 +17,11 @@
#include <gtest/gtest.h>
+#include "../utils/VeloxArrowUtils.h"
#include "compute/VeloxBackend.h"
#include "memory/ArrowMemoryPool.h"
#include "memory/VeloxColumnarBatch.h"
#include "operators/serializer/VeloxColumnarBatchSerializer.h"
-#include "utils/VeloxArrowUtils.h"
#include "velox/vector/arrow/Bridge.h"
#include "velox/vector/tests/utils/VectorTestBase.h"
diff --git a/cpp/velox/tests/VeloxRowToColumnarTest.cc
b/cpp/velox/tests/VeloxRowToColumnarTest.cc
index 2bda948f59..16001cc6d6 100644
--- a/cpp/velox/tests/VeloxRowToColumnarTest.cc
+++ b/cpp/velox/tests/VeloxRowToColumnarTest.cc
@@ -15,11 +15,11 @@
* limitations under the License.
*/
+#include "../utils/VeloxArrowUtils.h"
#include "memory/ArrowMemoryPool.h"
#include "memory/VeloxColumnarBatch.h"
#include "operators/serializer//VeloxColumnarToRowConverter.h"
#include "operators/serializer//VeloxRowToColumnarConverter.h"
-#include "utils/VeloxArrowUtils.h"
#include "velox/vector/tests/utils/VectorTestBase.h"
using namespace facebook;
diff --git a/cpp/velox/tests/VeloxRssSortShuffleWriterTest.cc
b/cpp/velox/tests/VeloxRssSortShuffleWriterTest.cc
index a787c78039..9741c2b672 100644
--- a/cpp/velox/tests/VeloxRssSortShuffleWriterTest.cc
+++ b/cpp/velox/tests/VeloxRssSortShuffleWriterTest.cc
@@ -21,16 +21,13 @@
#include "memory/VeloxMemoryManager.h"
#include "shuffle/VeloxRssSortShuffleWriter.h"
#include "tests/VeloxShuffleWriterTestBase.h"
-#include "utils/TestAllocationListener.h"
-#include "utils/TestUtils.h"
+#include "tests/utils/TestUtils.h"
#include "velox/buffer/Buffer.h"
#include "velox/type/Type.h"
#include "velox/vector/tests/VectorTestUtils.h"
#include "velox/vector/tests/utils/VectorTestBase.h"
-#include <cstdint>
-
using namespace facebook::velox;
using namespace facebook::velox::test;
diff --git a/cpp/velox/tests/VeloxShuffleWriterSpillTest.cc
b/cpp/velox/tests/VeloxShuffleWriterSpillTest.cc
index 45d25eb260..489c0eafbe 100644
--- a/cpp/velox/tests/VeloxShuffleWriterSpillTest.cc
+++ b/cpp/velox/tests/VeloxShuffleWriterSpillTest.cc
@@ -20,8 +20,8 @@
#include "config/GlutenConfig.h"
#include "shuffle/VeloxHashShuffleWriter.h"
#include "tests/VeloxShuffleWriterTestBase.h"
+#include "tests/utils/TestUtils.h"
#include "utils/TestAllocationListener.h"
-#include "utils/TestUtils.h"
using namespace facebook::velox;
diff --git a/cpp/velox/tests/VeloxShuffleWriterTest.cc
b/cpp/velox/tests/VeloxShuffleWriterTest.cc
index 03f0f8c4a1..27fc300372 100644
--- a/cpp/velox/tests/VeloxShuffleWriterTest.cc
+++ b/cpp/velox/tests/VeloxShuffleWriterTest.cc
@@ -18,14 +18,14 @@
#include <arrow/c/bridge.h>
#include <arrow/io/api.h>
+#include "../utils/VeloxArrowUtils.h"
#include "config/GlutenConfig.h"
#include "shuffle/VeloxHashShuffleWriter.h"
#include "shuffle/VeloxRssSortShuffleWriter.h"
#include "shuffle/VeloxSortShuffleWriter.h"
#include "tests/VeloxShuffleWriterTestBase.h"
+#include "tests/utils/TestUtils.h"
#include "utils/TestAllocationListener.h"
-#include "utils/TestUtils.h"
-#include "utils/VeloxArrowUtils.h"
#include "velox/vector/tests/utils/VectorTestBase.h"
diff --git a/cpp/velox/tests/VeloxShuffleWriterTestBase.h
b/cpp/velox/tests/VeloxShuffleWriterTestBase.h
index ba3de8db95..03d9dda046 100644
--- a/cpp/velox/tests/VeloxShuffleWriterTestBase.h
+++ b/cpp/velox/tests/VeloxShuffleWriterTestBase.h
@@ -22,6 +22,7 @@
#include <gtest/gtest.h>
#include <compute/VeloxBackend.h>
+#include "../utils/VeloxArrowUtils.h"
#include "memory/VeloxColumnarBatch.h"
#include "shuffle/LocalPartitionWriter.h"
#include "shuffle/PartitionWriter.h"
@@ -29,7 +30,6 @@
#include "shuffle/rss/RssPartitionWriter.h"
#include "utils/LocalRssClient.h"
#include "utils/TestAllocationListener.h"
-#include "utils/VeloxArrowUtils.h"
#include "velox/type/Type.h"
#include "velox/vector/tests/VectorTestUtils.h"
diff --git a/cpp/velox/utils/LocalRssClient.cc
b/cpp/velox/tests/utils/LocalRssClient.cc
similarity index 97%
rename from cpp/velox/utils/LocalRssClient.cc
rename to cpp/velox/tests/utils/LocalRssClient.cc
index 3ef3c61444..832d37ca25 100644
--- a/cpp/velox/utils/LocalRssClient.cc
+++ b/cpp/velox/tests/utils/LocalRssClient.cc
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-#include "utils/LocalRssClient.h"
+#include "tests/utils/LocalRssClient.h"
#include "utils/Common.h"
#include <arrow/io/file.h>
diff --git a/cpp/velox/utils/LocalRssClient.h
b/cpp/velox/tests/utils/LocalRssClient.h
similarity index 100%
rename from cpp/velox/utils/LocalRssClient.h
rename to cpp/velox/tests/utils/LocalRssClient.h
diff --git a/cpp/velox/utils/TestAllocationListener.cc
b/cpp/velox/tests/utils/TestAllocationListener.cc
similarity index 98%
rename from cpp/velox/utils/TestAllocationListener.cc
rename to cpp/velox/tests/utils/TestAllocationListener.cc
index 835ec263eb..dabc44dec6 100644
--- a/cpp/velox/utils/TestAllocationListener.cc
+++ b/cpp/velox/tests/utils/TestAllocationListener.cc
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-#include "utils/TestAllocationListener.h"
+#include "tests/utils/TestAllocationListener.h"
#include "velox/common/base/SuccinctPrinter.h"
#include <fmt/format.h>
diff --git a/cpp/velox/utils/TestAllocationListener.h
b/cpp/velox/tests/utils/TestAllocationListener.h
similarity index 100%
rename from cpp/velox/utils/TestAllocationListener.h
rename to cpp/velox/tests/utils/TestAllocationListener.h
diff --git a/cpp/core/utils/TestUtils.h b/cpp/velox/tests/utils/TestUtils.h
similarity index 60%
rename from cpp/core/utils/TestUtils.h
rename to cpp/velox/tests/utils/TestUtils.h
index ba158172b4..5de4b729f3 100644
--- a/cpp/core/utils/TestUtils.h
+++ b/cpp/velox/tests/utils/TestUtils.h
@@ -17,8 +17,6 @@
#pragma once
-#include <arrow/status.h>
-
#define ASSERT_NOT_OK(status) \
do { \
arrow::Status __s = (status); \
@@ -26,18 +24,3 @@
throw std::runtime_error(__s.message()); \
} \
} while (false);
-
-#define ARROW_ASSIGN_OR_THROW_IMPL(status_name, lhs, rexpr) \
- do { \
- auto status_name = (rexpr); \
- auto __s = status_name.status(); \
- if (!__s.ok()) { \
- throw std::runtime_error(__s.message()); \
- } \
- lhs = std::move(status_name).ValueOrDie(); \
- } while (false);
-
-#define ARROW_ASSIGN_OR_THROW_NAME(x, y) ARROW_CONCAT(x, y)
-
-#define ARROW_ASSIGN_OR_THROW(lhs, rexpr) \
- ARROW_ASSIGN_OR_THROW_IMPL(ARROW_ASSIGN_OR_THROW_NAME(_error_or_value,
__COUNTER__), lhs, rexpr);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]