[CMake] Running python nose tests

Eric Noulard eric.noulard at gmail.com
Fri Jun 5 13:59:10 EDT 2009


2009/6/5 Tyler Roscoe <tyler at cryptio.net>:
> On Thu, Jun 04, 2009 at 04:02:54PM -0400, Eric Jonas wrote:
>> I've written a server that serves up an interface using a cross-language
>> RPC mechanism (dbus) and currently build and unit test with cmake. But
>> testing cross-language (and more functional) aspects of the server is
>> easier to do from python, where I can rapidly test the RPC API. I've
>> written a collection of tests that I can run using the nose unit test
>> framework, but now I'm curious about how to include these in my
>> CMake-based test infrastructure. Has anyone had success running what are
>> basically python unit tests (or a framework like nose) from within
>> cmake?
>
> I don't know anything about nose but CTest is highly configurable. When
> you do add_test(), you can specify any executable. For example, we wrap
> our unit tests with a python script to insure that the environment is
> configured in a known way. You can also configure CTest to understand
> what nose reports as a successful or failed unit test run if the
> defaults don't work.

Same for me we used python script runned through CTest for testing
distributed application.

The python scripts are located within a C++ CMake build source tree.
The C++ programs are built using CMake and the python scripts are
launched with CTest. (add_test).

Each python scripts are running several programs previously built
(and installed) with CMake. CTest only checks whether if those scripts
return non NULL values as OK/NOK test results.

In my particular case the executables and libs needs to be installed
because each process launched by the python scripts are controlled
through an SSH terminal/pty (using paramiko [ssh in python]).

But I guess  you could perfectly run any python scripts
which uses/runs executable previously built with CMake "locally".

The project using the python scripts is there:
http://cvs.savannah.gnu.org/viewvc/applications/HLA_TestsSuite/?root=certi
the python scripts launched by CTest are those called "dtest_<XXXX>.py".

The CMake machinery is done by the file:
http://cvs.savannah.gnu.org/viewvc/applications/HLA_TestsSuite/HLATestsSuiteTools.cmake?root=certi&view=markup

look at HLATestsSuite_ADD_TEST CMake macro
which essentialy copy (CONFIGURE_FILE(... COPYLONY) the python scripts from
source tree to build tree and add the test (ADD_TEST).

[The python scripts are using dtest
 http://mirrors.linhub.com/savannah/tsp/dtest/what_is_dtest.pdf
 http://cvs.savannah.gnu.org/viewvc/dtest/?root=tsp
 but this may not be useful for you]

-- 
Erk


More information about the CMake mailing list