waf_unit_test¶
Unit testing system for C/C++/D and interpreted languages providing test execution:
in parallel, by using
waf -j
partial (only the tests that have changed) or full (by using
waf --alltests
)
The tests are declared by adding the test feature to programs:
def options(opt):
opt.load('compiler_cxx waf_unit_test')
def configure(conf):
conf.load('compiler_cxx waf_unit_test')
def build(bld):
bld(features='cxx cxxprogram test', source='main.cpp', target='app')
# or
bld.program(features='test', source='main2.cpp', target='app2')
When the build is executed, the program ‘test’ will be built and executed without arguments. The success/failure is detected by looking at the return code. The status and the standard output/error are stored on the build context.
The results can be displayed by registering a callback function. Here is how to call the predefined callback:
def build(bld):
bld(features='cxx cxxprogram test', source='main.c', target='app')
from waflib.Tools import waf_unit_test
bld.add_post_fun(waf_unit_test.summary)
By passing –dump-test-scripts the build outputs corresponding python files (with extension _run.py) that are useful for debugging purposes.
Features defined in this module: