From 966e89cd683219000fcd2101fdb2308028c119cf Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Thu, 27 Apr 2017 13:43:06 +0800 Subject: [PATCH] Disable some unit tests when PYTHON or SWIG_PY are not enabled. * When SWIG_PY is not enabled, paddle.v2 package cannot be used. * When PYTHON is not enabled, PyDataProvider cannot be used. Fix issue #1920 --- paddle/trainer/tests/CMakeLists.txt | 19 +++++++++++-------- python/CMakeLists.txt | 9 ++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/paddle/trainer/tests/CMakeLists.txt b/paddle/trainer/tests/CMakeLists.txt index c5c76a030d..08b2d8a38e 100644 --- a/paddle/trainer/tests/CMakeLists.txt +++ b/paddle/trainer/tests/CMakeLists.txt @@ -17,14 +17,17 @@ add_test(NAME test_Trainer WORKING_DIRECTORY ${PROJ_ROOT}/paddle/) ############### test_TrainerOnePass ########################## -add_unittest_without_exec(test_TrainerOnePass - test_TrainerOnePass.cpp) -add_test(NAME test_TrainerOnePass - COMMAND ${PROJ_ROOT}/paddle/.set_python_path.sh -d - ${PROJ_ROOT}/python/:${PROJ_ROOT}/paddle/trainer/tests - ${PROJ_ROOT}/paddle/.set_port.sh -p port ${CMAKE_CURRENT_BINARY_DIR}/test_TrainerOnePass - WORKING_DIRECTORY ${PROJ_ROOT}/paddle/) - +if(WITH_PYTHON) + # only run test_TrainerOnePass when PYTHON is enabled, because train one pass + # is using PyDataProvider2. + add_unittest_without_exec(test_TrainerOnePass + test_TrainerOnePass.cpp) + add_test(NAME test_TrainerOnePass + COMMAND ${PROJ_ROOT}/paddle/.set_python_path.sh -d + ${PROJ_ROOT}/python/:${PROJ_ROOT}/paddle/trainer/tests + ${PROJ_ROOT}/paddle/.set_port.sh -p port ${CMAKE_CURRENT_BINARY_DIR}/test_TrainerOnePass + WORKING_DIRECTORY ${PROJ_ROOT}/paddle/) +endif() ################ test_CompareTwoNets ###################### add_unittest_without_exec(test_CompareTwoNets test_CompareTwoNets.cpp) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e7a0895533..bfa19d5ecc 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -24,9 +24,12 @@ add_custom_target(paddle_python ALL DEPENDS ${OUTPUT_DIR}/.timestamp) add_subdirectory(paddle/trainer_config_helpers/tests) -add_subdirectory(paddle/v2/tests) -add_subdirectory(paddle/v2/reader/tests) -add_subdirectory(paddle/v2/plot/tests) +if (WITH_SWIG_PY) + # enable v2 API unittest only when paddle swig api is compiled + add_subdirectory(paddle/v2/tests) + add_subdirectory(paddle/v2/reader/tests) + add_subdirectory(paddle/v2/plot/tests) +endif() install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dist/ DESTINATION opt/paddle/share/wheels -- GitLab