Skip to content

Commit

Permalink
run_project_tests: Added print_tool_versions()
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Oct 20, 2019
1 parent 66e1e17 commit 892c8eb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions run_project_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,38 @@ def detect_system_compiler():
raise RuntimeError("Could not find C compiler.")
print()

def print_tool_versions():
tools = [
{
'tool': 'cmake',
'args': ['--version'],
'regex': re.compile(r'^cmake version ([0-9]+(\.[0-9]+)*)$'),
'match_group': 1,
},
]

def get_version(t: dict) -> str:
exe = shutil.which(t['tool'])
if not exe:
return 'not found'

args = [t['tool']] + t['args']
pc, o, e = Popen_safe(args)
if pc.returncode != 0:
return '{} (invalid {} executable)'.format(exe, t['tool'])
for i in o.split('\n'):
i = i.strip('\n\r\t ')
m = t['regex'].match(i)
if m is not None:
return '{} ({})'.format(exe, m.group(t['match_group']))

return '{} (unknown)'.format(exe)

max_width = max([len(x['tool']) for x in tools] + [7])
for tool in tools:
print('{0:<{2}}: {1}'.format(tool['tool'], get_version(tool), max_width))
print()

if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Run the test suite of Meson.")
parser.add_argument('extra_args', nargs='*',
Expand All @@ -882,6 +914,7 @@ def detect_system_compiler():
setup_commands(options.backend)

detect_system_compiler()
print_tool_versions()
script_dir = os.path.split(__file__)[0]
if script_dir != '':
os.chdir(script_dir)
Expand Down

0 comments on commit 892c8eb

Please sign in to comment.