提交 f8e594c9 编写于 作者: B Bo Zhou 提交者: Hongsheng Zeng

add unittest for compling the docs (#87)

* add unittest for compling the docs

* record the time of change

* remove unused requirements

* reduce font size of the changelog
上级 96c58265
### [2019-07-09] 1.1-cuda9.0-cudnn7-docs:
add unnit test for compling the docs
- add an envionment `docs` in anaconda
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# A dev image based on paddle production image # A dev image based on paddle production image
FROM parl/parl-test:1.1-cuda9.0-cudnn7-v2 FROM parl/parl-test:1.1-cuda9.0-cudnn7-docs
COPY ./requirements.txt /root/ COPY ./requirements.txt /root/
......
...@@ -102,6 +102,23 @@ EOF ...@@ -102,6 +102,23 @@ EOF
rm -rf ${REPO_ROOT}/build rm -rf ${REPO_ROOT}/build
} }
function run_docs_test {
#export CUDA_VISIBLE_DEVICES=""
mkdir -p ${REPO_ROOT}/build
cd ${REPO_ROOT}/build
cmake .. -DIS_TESTING_DOCS=ON
cat <<EOF
========================================
Running docs test...
========================================
EOF
ctest --output-on-failure
rm -rf ${REPO_ROOT}/build
}
function main() { function main() {
set -e set -e
local CMD=$1 local CMD=$1
...@@ -119,6 +136,7 @@ function main() { ...@@ -119,6 +136,7 @@ function main() {
run_test_with_gpu run_test_with_gpu
run_test_with_cpu run_test_with_cpu
run_import_test run_import_test
run_docs_test
;; ;;
*) *)
print_usage print_usage
......
...@@ -18,6 +18,7 @@ enable_testing() ...@@ -18,6 +18,7 @@ enable_testing()
option(WITH_TESTING "Include unit testing" ON) option(WITH_TESTING "Include unit testing" ON)
option(IS_TESTING_IMPORT "Whether is testing import parl" OFF) option(IS_TESTING_IMPORT "Whether is testing import parl" OFF)
option(IS_TESTING_DOCS "Whether is testing compling the docs" OFF)
set(PADDLE_PYTHON_PATH "" CACHE STRING "Python path to PaddlePaddle Fluid") set(PADDLE_PYTHON_PATH "" CACHE STRING "Python path to PaddlePaddle Fluid")
...@@ -41,20 +42,31 @@ function(import_test TARGET_NAME) ...@@ -41,20 +42,31 @@ function(import_test TARGET_NAME)
set(oneValueArgs "") set(oneValueArgs "")
set(multiValueArgs SRCS DEPS ARGS ENVS) set(multiValueArgs SRCS DEPS ARGS ENVS)
cmake_parse_arguments(py_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(py_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_test(NAME ${TARGET_NAME}_with_empty_env add_test(NAME ${TARGET_NAME}_with_empty_env
COMMAND env PYTHONPATH=.:${py_test_ENVS} COMMAND env PYTHONPATH=.:${py_test_ENVS}
/root/miniconda3/envs/empty_env/bin/python -u ${py_test_SRCS} ${py_test_ARGS} /root/miniconda3/envs/empty_env/bin/python -u ${py_test_SRCS} ${py_test_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME ${TARGET_NAME}_with_paddle1.4.0 add_test(NAME ${TARGET_NAME}_with_paddle1.4.0
COMMAND env PYTHONPATH=.:${py_test_ENVS} COMMAND env PYTHONPATH=.:${py_test_ENVS}
/root/miniconda3/envs/paddle1.4.0/bin/python -u ${py_test_SRCS} ${py_test_ARGS} /root/miniconda3/envs/paddle1.4.0/bin/python -u ${py_test_SRCS} ${py_test_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()
function(docs_test)
add_test(NAME compling_docs_test
COMMAND bash ./docs/test.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endfunction() endfunction()
if (WITH_TESTING) if (WITH_TESTING)
if (IS_TESTING_IMPORT) if (IS_TESTING_IMPORT)
set(src "parl/tests/import_test") set(src "parl/tests/import_test")
import_test(${src} SRCS ${src}.py ENVS ${PADDLE_PYTHON_PATH}) import_test(${src} SRCS ${src}.py ENVS ${PADDLE_PYTHON_PATH})
elseif (IS_TESTING_DOCS)
docs_test()
else () else ()
file(GLOB_RECURSE TEST_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*_test.py") file(GLOB_RECURSE TEST_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*_test.py")
string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")
......
#!/bin/bash
cd "$(dirname "$0")"
source ~/.bashrc
export PATH="/root/miniconda3/bin:$PATH"
source activate docs
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple /work/
make html
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册