diff options
author | David Robillard <d@drobilla.net> | 2018-11-24 13:44:09 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-24 13:44:09 +0100 |
commit | 93c6f4621370a98c1b03e2e29f856baff09428be (patch) | |
tree | d9b620bfba1e7462df4ddb3f6225cc5216c0ca81 /extras/autowaf.py | |
parent | 7c85df31925cbb97913b78ebf34af574955c0412 (diff) | |
download | fomp.lv2-93c6f4621370a98c1b03e2e29f856baff09428be.tar.gz fomp.lv2-93c6f4621370a98c1b03e2e29f856baff09428be.tar.bz2 fomp.lv2-93c6f4621370a98c1b03e2e29f856baff09428be.zip |
Squashed 'waflib/' changes from 3e43d09..5ea8f99
5ea8f99 Improve test output spacing
0e23b29 Raise exception when test suite fails to ensure non-zero exit status
d6de073 Show run time of unit tests
5b65554 Add short configure option for ultra-strict flags
4687ba6 Use gtest-like test output
258903d Fix failure count in test group summaries
da07e73 Fix verbose tests with Python 3
6e726eb Add support for suppressing warnings from system libraries
git-subtree-dir: waflib
git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d
Diffstat (limited to 'extras/autowaf.py')
-rw-r--r-- | extras/autowaf.py | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/extras/autowaf.py b/extras/autowaf.py index be3bfe2..feaae3c 100644 --- a/extras/autowaf.py +++ b/extras/autowaf.py @@ -2,6 +2,7 @@ import glob import os import subprocess import sys +import time from waflib import Build, Context, Logs, Options, Utils from waflib.TaskGen import feature, before, after @@ -69,7 +70,7 @@ def set_options(opt, debug_by_default=False, test=False): opts.add_option('-s', '--strict', action='store_true', default=False, dest='strict', help="use strict compiler flags and show all warnings") - opts.add_option('--ultra-strict', action='store_true', default=False, + opts.add_option('-S', '--ultra-strict', action='store_true', default=False, dest='ultra_strict', help="use extremely strict compiler flags (likely noisy)") opts.add_option('--docs', action='store_true', default=False, dest='docs', @@ -180,6 +181,16 @@ def check_pkg(conf, name, **args): else: conf.env[var_name] = CheckType.OPTIONAL + if not conf.env.MSVC_COMPILER and 'system' in args and args['system']: + includes = conf.env['INCLUDES_' + nameify(args['uselib_store'])] + for path in includes: + if 'COMPILER_CC' in conf.env: + conf.env.append_value('CFLAGS', ['-isystem', path]) + if 'COMPILER_CXX' in conf.env: + conf.env.append_value('CXXFLAGS', ['-isystem', path]) + + conf.env.append_value('CXXFLAGS', ['-isystem', '/usr/local/include']) + def normpath(path): if sys.platform == 'win32': return os.path.normpath(path).replace('\\', '/') @@ -721,8 +732,6 @@ def cd_to_build_dir(ctx, appname): os.chdir(os.path.join('build', appname)) else: os.chdir('build') - Logs.pprint('GREEN', ("Waf: Entering directory `%s'" % - os.path.abspath(os.getcwd()))) def cd_to_orig_dir(ctx, child): if child: @@ -731,7 +740,10 @@ def cd_to_orig_dir(ctx, child): os.chdir('..') def pre_test(ctx, appname, dirs=['src']): + Logs.pprint('GREEN', '\n[==========] Running %s tests' % appname) + if not hasattr(ctx, 'autowaf_tests_total'): + ctx.autowaf_tests_start_time = time.clock() ctx.autowaf_tests_total = 0 ctx.autowaf_tests_failed = 0 ctx.autowaf_local_tests_total = 0 @@ -756,6 +768,9 @@ def pre_test(ctx, appname, dirs=['src']): finally: clear_log.close() +class TestFailed(Exception): + pass + def post_test(ctx, appname, dirs=['src'], remove=['*boost*', 'c++*']): if not ctx.env.NO_COVERAGE: diropts = '' @@ -796,21 +811,22 @@ def post_test(ctx, appname, dirs=['src'], remove=['*boost*', 'c++*']): coverage_lcov.close() coverage_log.close() - if ctx.autowaf_tests[appname]['failed'] > 0: - Logs.pprint('RED', '\nSummary: %d / %d %s tests failed' % ( - ctx.autowaf_tests[appname]['failed'], - ctx.autowaf_tests[appname]['total'], - appname)) - else: - Logs.pprint('GREEN', '\nSummary: All %d %s tests passed' % ( - ctx.autowaf_tests[appname]['total'], appname)) - + duration = (time.clock() - ctx.autowaf_tests_start_time) * 1000.0 + total_tests = ctx.autowaf_tests[appname]['total'] + failed_tests = ctx.autowaf_tests[appname]['failed'] + passed_tests = total_tests - failed_tests + Logs.pprint('GREEN', '\n[==========] %d tests from %s ran (%d ms total)' % ( + total_tests, appname, duration)) if not ctx.env.NO_COVERAGE: - Logs.pprint('GREEN', 'Coverage: <file://%s>\n' + Logs.pprint('GREEN', '[----------] Coverage: <file://%s>' % os.path.abspath('coverage/index.html')) - Logs.pprint('GREEN', ("Waf: Leaving directory `%s'" % - os.path.abspath(os.getcwd()))) + Logs.pprint('GREEN', '[ PASSED ] %d tests' % passed_tests) + if failed_tests > 0: + Logs.pprint('RED', '[ FAILED ] %d tests' % failed_tests) + raise TestFailed('Tests from %s failed' % appname) + Logs.pprint('', '') + top_level = (len(ctx.stack_path) > 1) if top_level: cd_to_orig_dir(ctx, top_level) @@ -844,7 +860,7 @@ def run_test(ctx, if isinstance(test, type([])): s = ' '.join(test) if header and not quiet: - Logs.pprint('Green', '\n** Test %s' % s) + Logs.pprint('Green', '\n[ RUN ] %s' % s) cmd = test if Options.options.test_wrapper: cmd = Options.options.test_wrapper + ' ' + test @@ -859,17 +875,18 @@ def run_test(ctx, success = desired_status is None or returncode == desired_status if success: if not quiet: - Logs.pprint('GREEN', '** Pass %s' % name) + Logs.pprint('GREEN', '[ OK ] %s' % name) else: - Logs.pprint('RED', '** FAIL %s' % name) + Logs.pprint('RED', '[ FAILED ] %s' % name) ctx.autowaf_tests_failed += 1 + ctx.autowaf_local_tests_failed += 1 ctx.autowaf_tests[appname]['failed'] += 1 if type(test) != list and not callable(test): Logs.pprint('RED', test) if Options.options.verbose_tests and type(test) != list and not callable(test): - sys.stdout.write(out[0]) - sys.stderr.write(out[1]) + sys.stdout.write(out[0].decode('utf-8')) + sys.stderr.write(out[1].decode('utf-8')) return (success, out) @@ -882,7 +899,8 @@ def tests_name(ctx, appname, name='*'): def begin_tests(ctx, appname, name='*'): ctx.autowaf_local_tests_failed = 0 ctx.autowaf_local_tests_total = 0 - Logs.pprint('GREEN', '\n** Begin %s tests' % ( + ctx.autowaf_local_tests_start_time = time.clock() + Logs.pprint('GREEN', '\n[----------] %s' % ( tests_name(ctx, appname, name))) class Handle: @@ -895,13 +913,15 @@ def begin_tests(ctx, appname, name='*'): return Handle() def end_tests(ctx, appname, name='*'): + duration = (time.clock() - ctx.autowaf_local_tests_start_time) * 1000.0 + total = ctx.autowaf_local_tests_total failures = ctx.autowaf_local_tests_failed if failures == 0: - Logs.pprint('GREEN', '** Passed all %d %s tests' % ( - ctx.autowaf_local_tests_total, tests_name(ctx, appname, name))) + Logs.pprint('GREEN', '[----------] %d tests from %s (%d ms total)' % ( + ctx.autowaf_local_tests_total, tests_name(ctx, appname, name), duration)) else: - Logs.pprint('RED', '** Failed %d / %d %s tests' % ( - failures, ctx.autowaf_local_tests_total, tests_name(ctx, appname, name))) + Logs.pprint('RED', '[----------] %d/%d tests from %s (%d ms total)' % ( + total - failures, total, tests_name(ctx, appname, name), duration)) def run_tests(ctx, appname, |