Skip to content

Commit

Permalink
【paddle_test No.31, No.32】replace cc_test with paddle_test (#60959)
Browse files Browse the repository at this point in the history
* feat(cmake): push paddle_test of utils

* feat(ctest): move ut to test

* feat(cmake): push paddle_test

* feat(windows): add TEST_API for windows

* fix(ctest): support ut on windows
  • Loading branch information
xiaoyewww authored Feb 19, 2024
1 parent bd281c9 commit bab377b
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 29 deletions.
5 changes: 3 additions & 2 deletions paddle/common/flags_native.cc
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,9 @@ T GetFromEnv(const std::string& name, const T& default_val) {
}
}

#define INSTANTIATE_GET_FROM_ENV(type) \
template type GetFromEnv(const std::string& name, const type& default_val)
#define INSTANTIATE_GET_FROM_ENV(type) \
template TEST_API type GetFromEnv(const std::string& name, \
const type& default_val)

INSTANTIATE_GET_FROM_ENV(bool);
INSTANTIATE_GET_FROM_ENV(int32_t);
Expand Down
17 changes: 0 additions & 17 deletions paddle/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ add_subdirectory(string)
# DEPS paddle_flags)
# endif()

cc_test(
array_ref_test
SRCS array_ref_test.cc
DEPS gtest phi common)
cc_test(
small_vector_test
SRCS small_vector_test.cc
DEPS gtest phi common)
cc_test(
variant_test
SRCS variant_test.cc
DEPS gtest)
cc_test(
span_test
SRCS span_test.cc
DEPS gtest)

if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
cc_library(
pybind_util
Expand Down
10 changes: 0 additions & 10 deletions paddle/utils/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,3 @@ cc_library(
string_helper
SRCS string_helper.cc
DEPS phi common)
cc_test(
stringprintf_test
SRCS printf_test.cc
DEPS phi common)
cc_test(to_string_test SRCS to_string_test.cc)
cc_test(split_test SRCS split_test.cc)
cc_test(
string_helper_test
SRCS string_helper_test.cc
DEPS string_helper)
1 change: 1 addition & 0 deletions test/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ add_subdirectory(pir)
add_subdirectory(inference)
add_subdirectory(eager)
add_subdirectory(fluid)
add_subdirectory(utils)
19 changes: 19 additions & 0 deletions test/cpp/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# if(NOT WITH_GFLAGS)
# paddle_test(flags_native_test SRCS flags_native_test.cc)
# endif()

add_subdirectory(string)

paddle_test(array_ref_test SRCS array_ref_test.cc)
paddle_test(small_vector_test SRCS small_vector_test.cc)
paddle_test(variant_test SRCS variant_test.cc)
paddle_test(span_test SRCS span_test.cc)

if(WITH_ONNXRUNTIME AND WIN32)
# Copy onnxruntime for some c++ test in Windows, since the test will
# be build only in CI, so suppose the generator in Windows is Ninja.
copy_onnx(array_ref_test)
copy_onnx(small_vector_test)
copy_onnx(variant_test)
copy_onnx(span_test)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions test/cpp/utils/string/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
paddle_test(stringprintf_test SRCS printf_test.cc)
paddle_test(to_string_test SRCS to_string_test.cc)
paddle_test(split_test SRCS split_test.cc)
paddle_test(string_helper_test SRCS string_helper_test.cc DEPS string_helper)

if(WITH_ONNXRUNTIME AND WIN32)
# Copy onnxruntime for some c++ test in Windows, since the test will
# be build only in CI, so suppose the generator in Windows is Ninja.
copy_onnx(stringprintf_test)
copy_onnx(to_string_test)
copy_onnx(split_test)
copy_onnx(string_helper_test)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bab377b

Please sign in to comment.