diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 78402aae37593d79ed9dc241ba4168fb84a444b2..5fe9ac027bcc58429d6f2368e55b189eb1deea9e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -149,7 +149,6 @@ add_custom_target(paddle_python ALL set(PADDLE_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/) if(WITH_TESTING) - add_subdirectory(paddle/reader/tests) add_subdirectory(paddle/dataset/tests) add_subdirectory(paddle/tests) add_subdirectory(paddle/fluid/tests) diff --git a/python/paddle/reader/tests/CMakeLists.txt b/python/paddle/reader/tests/CMakeLists.txt deleted file mode 100644 index a6ac586b680cfc2f5cc184a81ef6f7ddc1d963f2..0000000000000000000000000000000000000000 --- a/python/paddle/reader/tests/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -py_test(decorator_test SRCS decorator_test.py) -set_tests_properties(decorator_test PROPERTIES TIMEOUT 120) diff --git a/python/paddle/reader/tests/__init__.py b/python/paddle/reader/tests/__init__.py deleted file mode 100644 index eca2dce114b069bf9b455d77ce670d73b5047fd2..0000000000000000000000000000000000000000 --- a/python/paddle/reader/tests/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. -# -# 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. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9aee96cdf24f6d13c003d9a247b6b8dbe6feea0c..5701aa445931fdff5c518a49b011d217fa5929dd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,8 +5,10 @@ set(PYTHON_TESTS_DIR ${PADDLE_BINARY_DIR}/test CACHE INTERNAL "python tests directory") -add_subdirectory(cpp) -add_subdirectory(legacy_test) +if(WITH_TESTING) + add_subdirectory(cpp) + add_subdirectory(legacy_test) +endif() get_property(test_srcs GLOBAL PROPERTY TEST_SRCS) get_property(test_names GLOBAL PROPERTY TEST_NAMES) diff --git a/test/legacy_test/CMakeLists.txt b/test/legacy_test/CMakeLists.txt index 735f420ca5e9609b21cd0db2ea6577060b3d9ff3..85204105a534b5384fad75246110a703b461dec5 100644 --- a/test/legacy_test/CMakeLists.txt +++ b/test/legacy_test/CMakeLists.txt @@ -1,81 +1,80 @@ -if(WITH_TESTING) - file( - GLOB TEST_OPS - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "test_*.py") - string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") +file( + GLOB TEST_OPS + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "test_*.py") +string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") - file( - GLOB DIST_TEST_OPS - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "test_dist_*.py") - string(REPLACE ".py" "" DIST_TEST_OPS "${DIST_TEST_OPS}") +file( + GLOB DIST_TEST_OPS + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "test_dist_*.py") +string(REPLACE ".py" "" DIST_TEST_OPS "${DIST_TEST_OPS}") - foreach(TEST_OP ${DIST_TEST_OPS}) - list(REMOVE_ITEM TEST_OPS ${TEST_OP}) - endforeach() +foreach(TEST_OP ${DIST_TEST_OPS}) + list(REMOVE_ITEM TEST_OPS ${TEST_OP}) +endforeach() - if(NOT WITH_COVERAGE) - list(REMOVE_ITEM TEST_OPS test_hapi_hub) - endif() - - foreach(src ${TEST_OPS}) - py_test(${src} SRCS ${src}.py) - endforeach() +if(NOT WITH_COVERAGE) + list(REMOVE_ITEM TEST_OPS test_hapi_hub) +endif() - function(py_dist_test TARGET_NAME) - if(WITH_TESTING) - set(options "") - set(oneValueArgs "") - set(multiValueArgs SRCS DEPS ARGS ENVS) - cmake_parse_arguments(py_dist_test "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN}) +foreach(src ${TEST_OPS}) + py_test(${src} SRCS ${src}.py) +endforeach() - if(WITH_COVERAGE - AND (WITH_GPU OR WITH_ROCM) - AND (WITH_NCCL OR WITH_RCCL) - AND NOT WIN32) - add_test( - NAME ${TARGET_NAME} - COMMAND - ${CMAKE_COMMAND} -E env FLAGS_init_allocated_mem=true - FLAGS_cudnn_deterministic=true FLAGS_cpu_deterministic=true - NCCL_P2P_DISABLE=1 NCCL_SHM_DISABLE=1 - PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_dist_test_ENVS} - COVERAGE_FILE=${PADDLE_BINARY_DIR}/python-coverage.data - ${PYTHON_EXECUTABLE} -u ${py_dist_test_SRCS} ${py_dist_test_ARGS} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # No unit test should exceed 10 minutes. - set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 600 LABELS - "RUN_TYPE=DIST") - endif() +function(py_dist_test TARGET_NAME) + if(WITH_TESTING) + set(options "") + set(oneValueArgs "") + set(multiValueArgs SRCS DEPS ARGS ENVS) + cmake_parse_arguments(py_dist_test "${options}" "${oneValueArgs}" + "${multiValueArgs}" ${ARGN}) + if(WITH_COVERAGE + AND (WITH_GPU OR WITH_ROCM) + AND (WITH_NCCL OR WITH_RCCL) + AND NOT WIN32) + add_test( + NAME ${TARGET_NAME} + COMMAND + ${CMAKE_COMMAND} -E env FLAGS_init_allocated_mem=true + FLAGS_cudnn_deterministic=true FLAGS_cpu_deterministic=true + NCCL_P2P_DISABLE=1 NCCL_SHM_DISABLE=1 + PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_dist_test_ENVS} + COVERAGE_FILE=${PADDLE_BINARY_DIR}/python-coverage.data + ${PYTHON_EXECUTABLE} -u ${py_dist_test_SRCS} ${py_dist_test_ARGS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + # No unit test should exceed 10 minutes. + set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 600 LABELS + "RUN_TYPE=DIST") endif() - endfunction() - foreach(src ${DIST_TEST_OPS}) - message(STATUS ${src}) - py_dist_test(${src} SRCS ${src}.py) - endforeach() - set_tests_properties(test_dataset_cifar PROPERTIES TIMEOUT 120) - set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 120) - set_tests_properties(test_model PROPERTIES TIMEOUT 300) - set_tests_properties(test_dataset_movielens PROPERTIES TIMEOUT 120) - set_tests_properties(test_datasets PROPERTIES TIMEOUT 300) - set_tests_properties(test_dataset_wmt PROPERTIES TIMEOUT 120) - set_tests_properties(test_vision_models PROPERTIES TIMEOUT 120) - set_tests_properties(test_dataset_uci_housing PROPERTIES TIMEOUT 120) - set_tests_properties(test_dataset_imdb PROPERTIES TIMEOUT 300) - set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 600) - set_tests_properties(test_callback_wandb PROPERTIES TIMEOUT 60) - if(WITH_COVERAGE) - set_tests_properties(test_hapi_hub PROPERTIES TIMEOUT 300) endif() +endfunction() - if(APPLE) - set_tests_properties(test_callback_early_stop PROPERTIES TIMEOUT 300) - set_tests_properties(test_callback_reduce_lr_on_plateau PROPERTIES TIMEOUT - 300) - set_tests_properties(test_vision_models PROPERTIES TIMEOUT 300) - endif() +foreach(src ${DIST_TEST_OPS}) + message(STATUS ${src}) + py_dist_test(${src} SRCS ${src}.py) +endforeach() +set_tests_properties(test_dataset_cifar PROPERTIES TIMEOUT 120) +set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 120) +set_tests_properties(test_model PROPERTIES TIMEOUT 300) +set_tests_properties(test_dataset_movielens PROPERTIES TIMEOUT 120) +set_tests_properties(test_datasets PROPERTIES TIMEOUT 300) +set_tests_properties(test_dataset_wmt PROPERTIES TIMEOUT 120) +set_tests_properties(test_vision_models PROPERTIES TIMEOUT 120) +set_tests_properties(test_dataset_uci_housing PROPERTIES TIMEOUT 120) +set_tests_properties(test_dataset_imdb PROPERTIES TIMEOUT 300) +set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 600) +set_tests_properties(test_callback_wandb PROPERTIES TIMEOUT 60) +if(WITH_COVERAGE) + set_tests_properties(test_hapi_hub PROPERTIES TIMEOUT 300) +endif() + +if(APPLE) + set_tests_properties(test_callback_early_stop PROPERTIES TIMEOUT 300) + set_tests_properties(test_callback_reduce_lr_on_plateau PROPERTIES TIMEOUT + 300) + set_tests_properties(test_vision_models PROPERTIES TIMEOUT 300) endif() +set_tests_properties(test_decorator PROPERTIES TIMEOUT 120) diff --git a/python/paddle/reader/tests/decorator_test.py b/test/legacy_test/test_decorator.py similarity index 100% rename from python/paddle/reader/tests/decorator_test.py rename to test/legacy_test/test_decorator.py