diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2017-06-14 05:09:42 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-06-22 06:04:59 -0400 |
commit | a681348b057e3ef8df3d0e35fd146ec75a880b4a (patch) | |
tree | 8a4579c01429b12b03099a480bba1ebaf0f2d4d0 | |
parent | 39c75d39fb2d8eb7b621c24d92357c5c761f869e (diff) | |
download | meson-a681348b057e3ef8df3d0e35fd146ec75a880b4a.zip meson-a681348b057e3ef8df3d0e35fd146ec75a880b4a.tar.gz meson-a681348b057e3ef8df3d0e35fd146ec75a880b4a.tar.bz2 |
Add some colour to test output.
Bold the section names and colourize errors&skips.
-rwxr-xr-x | run_project_tests.py | 33 | ||||
-rwxr-xr-x | run_tests.py | 7 |
2 files changed, 31 insertions, 9 deletions
diff --git a/run_project_tests.py b/run_project_tests.py index 3c89d75..76216a4 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -250,6 +250,23 @@ def log_text_file(logfile, testdir, stdo, stde): executor.shutdown() raise StopException() + +def bold(text): + return mlog.bold(text).get_text(mlog.colorize_console) + + +def green(text): + return mlog.green(text).get_text(mlog.colorize_console) + + +def red(text): + return mlog.red(text).get_text(mlog.colorize_console) + + +def yellow(text): + return mlog.yellow(text).get_text(mlog.colorize_console) + + def run_test_inprocess(testdir): old_stdout = sys.stdout sys.stdout = mystdout = StringIO() @@ -475,10 +492,12 @@ def run_tests(all_tests, log_name_base, extra_args): for name, test_cases, skipped in all_tests: current_suite = ET.SubElement(junit_root, 'testsuite', {'name': name, 'tests': str(len(test_cases))}) + print() if skipped: - print('\nNot running %s tests.\n' % name) + print(bold('Not running %s tests.' % name)) else: - print('\nRunning %s tests.\n' % name) + print(bold('Running %s tests.' % name)) + print() futures = [] for t in test_cases: # Jenkins screws us over by automatically sorting test cases by name @@ -494,7 +513,7 @@ def run_tests(all_tests, log_name_base, extra_args): sys.stdout.flush() result = result.result() if result is None or 'MESON_SKIP_TEST' in result.stdo: - print('Skipping:', t) + print(yellow('Skipping:'), t) current_test = ET.SubElement(current_suite, 'testcase', {'name': testname, 'classname': name}) ET.SubElement(current_test, 'skipped', {}) @@ -502,7 +521,7 @@ def run_tests(all_tests, log_name_base, extra_args): else: without_install = "" if len(install_commands) > 0 else " (without install)" if result.msg != '': - print('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t)) + print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t))) print('Reason:', result.msg) failing_tests += 1 if result.step == BuildStep.configure and result.mlog != no_meson_log_msg: @@ -648,9 +667,9 @@ if __name__ == '__main__': pass for f in pbfiles: os.unlink(f) - print('\nTotal passed tests:', passing_tests) - print('Total failed tests:', failing_tests) - print('Total skipped tests:', skipped_tests) + print('\nTotal passed tests:', green(str(passing_tests))) + print('Total failed tests:', red(str(failing_tests))) + print('Total skipped tests:', yellow(str(skipped_tests))) if failing_tests > 0: print('\nMesonlogs of failing tests\n') for l in failing_logs: diff --git a/run_tests.py b/run_tests.py index 1549979..040f958 100755 --- a/run_tests.py +++ b/run_tests.py @@ -23,6 +23,7 @@ import tempfile import platform from mesonbuild import mesonlib from mesonbuild import mesonmain +from mesonbuild import mlog from mesonbuild.environment import detect_ninja from io import StringIO from enum import Enum @@ -177,7 +178,8 @@ if __name__ == '__main__': if 'APPVEYOR' in os.environ and os.environ['arch'] == 'x86': os.environ.pop('platform') # Run tests - print('Running unittests.\n') + print(mlog.bold('Running unittests.').get_text(mlog.colorize_console)) + print() units = ['InternalTests', 'AllPlatformTests', 'FailureTests'] if mesonlib.is_linux(): units += ['LinuxlikeTests'] @@ -200,7 +202,8 @@ if __name__ == '__main__': returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'] + units, env=env) # Ubuntu packages do not have a binary without -6 suffix. if should_run_linux_cross_tests(): - print('Running cross compilation tests.\n') + print(mlog.bold('Running cross compilation tests.').get_text(mlog.colorize_console)) + print() returncode += subprocess.call([sys.executable, 'run_cross_test.py', 'cross/ubuntu-armhf.txt'], env=env) returncode += subprocess.call([sys.executable, 'run_project_tests.py'] + sys.argv[1:], env=env) sys.exit(returncode) |