Skip to content

Build and run unit tests of Paddle #815

@wangkuiyi

Description

@wangkuiyi

I need to add the following stuff to Docker-related documents, or maybe a How to Develop and Test guide.


How to build and run tests

Paddle uses cmake as the build system. Usually, we run cmake and make from without a directory other than the source code directory paddle, but somewhere like paddle/build. After building, we can run ctest from within the same directory for tests.

For detailed messages on failure

ctest suppresses detailed outputs by default. This fits the cases of CI, but not for development, where we would like to see detailed outputs. To do so, we can set the environment variable CTEST_OUTPUT_ON_FAILURE to 1:

CTEST_OUTPUT_ON_FAILURE=1 ctest

No cmake install before running tests

In our Dockerfiles, we have RUN make install which installs the built Python libraries of Paddle. But some of our tests require a clean Python environment. When we see error messages like the following, we just need to run pip uninstall paddle and re-run tests.

38/56 Test #38: test_RecurrentGradientMachine .......***Failed    0.02 sec
paddle package is already in your PYTHONPATH. But unittest need a clean environment.
Please uninstall paddle package before start unittest. Try to 'pip uninstall paddle'

      Start 39: test_NetworkCompare
39/56 Test #39: test_NetworkCompare .................***Failed    0.02 sec
paddle package is already in your PYTHONPATH. But unittest need a clean environment.
Please uninstall paddle package before start unittest. Try to 'pip uninstall paddle'

      Start 40: test_PyDataProvider2
40/56 Test #40: test_PyDataProvider2 ................***Failed    0.02 sec
paddle package is already in your PYTHONPATH. But unittest need a clean environment.
Please uninstall paddle package before start unittest. Try to 'pip uninstall paddle'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions