Skip to content

Commit

Permalink
[Test Mv] move dygraph_to_static to test dir (PaddlePaddle#52069)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ainavo authored Mar 31, 2023
1 parent 3ebb7e4 commit 404162b
Show file tree
Hide file tree
Showing 121 changed files with 69 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ ignore =
W503
per-file-ignores =
# These files need tabs for testing.
python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py:E101,W191
test/dygraph_to_static/test_error.py:E101,W191
python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py:E101,W191
# Ignore unused imports in __init__.py
__init__.py: F401
# Ignore undefined variables in CMake config and some dygraph_to_static tests
.cmake-format.py: F821
python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py: F821
python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py: F821
test/dygraph_to_static/test_loop.py: F821
test/dygraph_to_static/test_closure_analysis.py: F821
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
(?x)^(
python/paddle/fluid/(?!tests).+|
python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py|
python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py
test/dygraph_to_static/test_error.py
)$
- repo: local
hooks:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ ignore = [
# Ignore version check in setup.py
"setup.py" = ["UP036"]
# Ignore unnecessary comprehension in dy2st unittest test_loop
"python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py" = ["C416"]
"test/dygraph_to_static/test_loop.py" = ["C416"]
# Ignore unnecessary lambda in dy2st unittest test_lambda
"python/paddle/fluid/tests/unittests/dygraph_to_static/test_lambda.py" = ["PLC3002"]
"test/dygraph_to_static/test_lambda.py" = ["PLC3002"]
1 change: 0 additions & 1 deletion python/paddle/fluid/tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ if(NOT WIN32)
endif()

add_subdirectory(sequence)
add_subdirectory(dygraph_to_static)
add_subdirectory(rnn)
add_subdirectory(distribution)

Expand Down
64 changes: 63 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,68 @@ set(PYTHON_TESTS_DIR
${PADDLE_BINARY_DIR}/test
CACHE INTERNAL "python tests directory")

function(py_test_modules TARGET_NAME)
if(WITH_TESTING)
set(options SERIAL)
set(oneValueArgs "")
set(multiValueArgs MODULES DEPS ENVS)
cmake_parse_arguments(py_test_modules "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})

if(WITH_COVERAGE AND NOT (WITH_INCREMENTAL_COVERAGE
AND "$ENV{PADDLE_GIT_DIFF_PY_FILE}" STREQUAL ""))
if(WITH_ASCEND_CL)
add_test(
NAME ${TARGET_NAME}
COMMAND
${CMAKE_COMMAND} -E env
PYTHONPATH=${PADDLE_BINARY_DIR}/python:$ENV{PYTHONPATH}
${py_test_modules_ENVS}
COVERAGE_FILE=${PADDLE_BINARY_DIR}/python-coverage.data
${PYTHON_EXECUTABLE} -m coverage run --branch -p
${PADDLE_SOURCE_DIR}/tools/test_runner.py ${py_test_modules_MODULES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME ${TARGET_NAME}
COMMAND
${CMAKE_COMMAND} -E env PYTHONPATH=${PADDLE_BINARY_DIR}/python
${py_test_modules_ENVS}
COVERAGE_FILE=${PADDLE_BINARY_DIR}/python-coverage.data
${PYTHON_EXECUTABLE} -m coverage run --branch -p
${PADDLE_SOURCE_DIR}/tools/test_runner.py ${py_test_modules_MODULES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
else()
if(WITH_ASCEND_CL)
add_test(
NAME ${TARGET_NAME}
COMMAND
${CMAKE_COMMAND} -E env
PYTHONPATH=${PADDLE_BINARY_DIR}/python:$ENV{PYTHONPATH}
${py_test_modules_ENVS} ${PYTHON_EXECUTABLE}
${PADDLE_SOURCE_DIR}/tools/test_runner.py ${py_test_modules_MODULES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME ${TARGET_NAME}
COMMAND
${CMAKE_COMMAND} -E env PYTHONPATH=${PADDLE_BINARY_DIR}/python
${py_test_modules_ENVS} ${PYTHON_EXECUTABLE}
${PADDLE_SOURCE_DIR}/tools/test_runner.py ${py_test_modules_MODULES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()

if(py_test_modules_SERIAL)
set_property(TEST ${TARGET_NAME} PROPERTY RUN_SERIAL 1)
endif()
if(WIN32)
set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 150)
endif()
endif()
endfunction()

function(bash_test_modules TARGET_NAME)
if(NOT WITH_TESTING)
return()
Expand Down Expand Up @@ -68,7 +130,7 @@ if(WITH_TESTING)
add_subdirectory(dataset)
# add_subdirectory(distributed_passes)
# add_subdirectory(distribution)
# add_subdirectory(dygraph_to_static)
add_subdirectory(dygraph_to_static)
# add_subdirectory(fft)
# add_subdirectory(fleet)
if(WITH_IPU)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 404162b

Please sign in to comment.