12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- """
- Execute Python tests during build
- To force all tests, run with "waf build --alltests"
- """
- top = '.'
- out = 'build'
- def test_results(bld):
- """
- Custom post- function that prints out test results.
- """
- lst = getattr(bld, 'utest_results', [])
- if not lst:
- return
- for (f, code, out, err) in lst:
- print(out.decode('utf-8'))
- print(err.decode('utf-8'))
- def options(opt):
- opt.load('python compiler_c')
- opt.load('waf_unit_test pytest')
- def configure(cnf):
- cnf.load('python compiler_c waf_unit_test pytest buildcopy')
-
- cnf.check_python_version(minver=(3, 0, 0))
- cnf.check_python_headers()
- def build(bld):
-
-
-
-
- bld(name = 'foo_ext',
- features = 'c cshlib pyext',
- source = 'src/foo_ext.c',
- target = 'src/foo/foo_ext',
- install_path = '${PYTHONDIR}/foo')
-
- bld(name = 'baz_ext',
- features = 'c cshlib pyext',
- source = 'src/baz/baz_ext.c',
- target = 'src/baz/baz_ext',
- install_path = '${PYTHONDIR}',
- pytest_path = [bld.path.find_dir('src/baz').get_bld()])
-
-
-
-
-
- bld(name = 'foo',
- features = 'py buildcopy',
- use = 'foo_ext',
- source = bld.path.ant_glob('src/foo/*.py'),
- install_from = 'src')
-
-
-
- bld(name = 'bar',
- features = 'py buildcopy',
- source = bld.path.ant_glob('src/bar/*.py'),
- buildcopy_source = bld.path.ant_glob('src/bar/*.py') + ['src/bar/resource.txt'],
- install_from = 'src')
-
-
-
-
-
-
-
-
-
-
-
-
- bld(name = 'py_test',
- features = 'pytest',
- use = 'foo bar baz_ext',
- pytest_source = bld.path.ant_glob('test/*.py'),
- ut_str = '${PYTHON} -B -m unittest discover')
- bld.add_post_fun(test_results)
|