diff options
author | Peter Goldsborough <psag@fb.com> | 2018-09-21 21:12:37 -0700 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2018-09-21 21:28:16 -0700 |
commit | 825181ea9d25d62796354fb9b2b112e4844f6d3d (patch) | |
tree | 969ccbd9c1a12c29baea9f424adaf341979217d4 /torch/CMakeLists.txt | |
parent | d0db23e95adf7ee50af0a3c109ad90fa57c21590 (diff) | |
download | pytorch-825181ea9d25d62796354fb9b2b112e4844f6d3d.tar.gz pytorch-825181ea9d25d62796354fb9b2b112e4844f6d3d.tar.bz2 pytorch-825181ea9d25d62796354fb9b2b112e4844f6d3d.zip |
Rewrite C++ API tests in gtest (#11953)
Summary:
This PR is a large codemod to rewrite all C++ API tests with GoogleTest (gtest) instead of Catch.
You can largely trust me to have correctly code-modded the tests, so it's not required to review every of the 2000+ changed lines. However, additional things I changed were:
1. Moved the cmake parts for these tests into their own `CMakeLists.txt` under `test/cpp/api` and calling `add_subdirectory` from `torch/CMakeLists.txt`
2. Fixing DataParallel tests which weren't being compiled because `USE_CUDA` wasn't correctly being set at all.
3. Updated README
ezyang ebetica
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11953
Differential Revision: D9998883
Pulled By: goldsborough
fbshipit-source-id: affe3f320b0ca63e7e0019926a59076bb943db80
Diffstat (limited to 'torch/CMakeLists.txt')
-rw-r--r-- | torch/CMakeLists.txt | 68 |
1 files changed, 2 insertions, 66 deletions
diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt index c8ead88e30..be13aaa61b 100644 --- a/torch/CMakeLists.txt +++ b/torch/CMakeLists.txt @@ -243,7 +243,7 @@ if (NOT NO_API AND NOT USE_ROCM) ${TORCH_SRC_DIR}/csrc/api/src/serialize/input-archive.cpp ${TORCH_SRC_DIR}/csrc/api/src/serialize/output-archive.cpp ${TORCH_SRC_DIR}/csrc/api/src/utils.cpp - ) + ) endif() @@ -434,71 +434,7 @@ if (BUILD_TEST AND NOT MSVC AND NOT APPLE AND NOT USE_ROCM) endif() if (BUILD_TEST AND NOT NO_API AND NOT USE_ROCM) - - #Catch test of api. - #TODO: Change all these tests to Google test. - set(TORCH_API_TEST_DIR "${TORCH_ROOT}/test/cpp/api") - set(TORCH_API_TEST_SOURCES - ${TORCH_API_TEST_DIR}/any.cpp - ${TORCH_API_TEST_DIR}/cursor.cpp - ${TORCH_API_TEST_DIR}/integration.cpp - ${TORCH_API_TEST_DIR}/jit.cpp - ${TORCH_API_TEST_DIR}/main.cpp - ${TORCH_API_TEST_DIR}/misc.cpp - ${TORCH_API_TEST_DIR}/module.cpp - ${TORCH_API_TEST_DIR}/modules.cpp - ${TORCH_API_TEST_DIR}/optim.cpp - ${TORCH_API_TEST_DIR}/parallel.cpp - ${TORCH_API_TEST_DIR}/rnn.cpp - ${TORCH_API_TEST_DIR}/sequential.cpp - ${TORCH_API_TEST_DIR}/serialize.cpp - ${TORCH_API_TEST_DIR}/tensor_cuda.cpp - ${TORCH_API_TEST_DIR}/tensor_options_cuda.cpp - ${TORCH_API_TEST_DIR}/tensor_options.cpp - ${TORCH_API_TEST_DIR}/tensor.cpp - ) - - add_executable(test_api ${TORCH_API_TEST_SOURCES}) - - target_include_directories(test_api - PUBLIC - "${TORCH_ROOT}/third_party/catch/single_include" - ${ATen_CPU_INCLUDE}) - - target_link_libraries(test_api torch ${TORCH_CUDA_LIBRARIES} ${CUDA_NVRTC_LIB} ${CUDA_CUDA_LIB}) - - #Google test of api. - set(TORCH_API_GTEST_DIR "${TORCH_ROOT}/test/cpp/api/") - add_executable(gtest_api - ${TORCH_API_GTEST_DIR}/static.cpp - ) - target_include_directories(gtest_api PRIVATE ${ATen_CPU_INCLUDE}) - target_link_libraries(gtest_api torch gtest_main) - if (USE_CUDA) - target_link_libraries(gtest_api ${CUDA_LIBRARIES} ${CUDA_NVRTC_LIB} ${CUDA_CUDA_LIB} ${TORCH_CUDA_LIBRARIES}) - endif() - - #Adding compile options for both tests. - if (NOT MSVC) - if (APPLE) - target_compile_options(test_api PRIVATE - # Clang has an unfixed bug leading to spurious missing braces - # warnings, see https://bugs.llvm.org/show_bug.cgi?id=21629 - -Wno-missing-braces) - target_compile_options(gtest_api PRIVATE - -Wno-missing-braces) - else() - target_compile_options(test_api PRIVATE - # Considered to be flaky. See the discussion at - # https://github.com/pytorch/pytorch/pull/9608 - -Wno-maybe-uninitialized - # gcc gives nonsensical warnings about variadic.h - -Wno-unused-but-set-parameter) - target_compile_options(gtest_api PRIVATE - -Wno-maybe-uninitialized - -Wno-unused-but-set-parameter) - endif() - endif() + add_subdirectory(${TORCH_ROOT}/test/cpp/api ${CMAKE_BINARY_DIR}/test_api) endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |