From 9df271968e56cf181a1512ea8bdf2016b449fa78 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 2 Jul 2013 05:24:10 +0000 Subject: [PATCH] drop yaml dependency in parse_test_results.py and don't require it to be run from a repository --- tools/parse_test_results.py | 153 +++++++++++++++--------------------- 1 file changed, 64 insertions(+), 89 deletions(-) diff --git a/tools/parse_test_results.py b/tools/parse_test_results.py index 4d2851682..0c73b4acf 100755 --- a/tools/parse_test_results.py +++ b/tools/parse_test_results.py @@ -36,7 +36,6 @@ import os import sys import glob import json -import yaml # TODO: different parsers could be run on output from different actions # if we would use the xml output in stead of stdout/stderr @@ -172,112 +171,88 @@ def parse_tests(rev_dir): # TODO: remove this dependency by encoding it in the output files # this script should work from outside of the repo, just having # access to the shared folder -project_name = '' +project_name = 'libtorrent' -try: - cfg = open('.regression.yml', 'r') -except: - print '.regression.yml not found in current directory' - sys.exit(1) -cfg = yaml.load(cfg.read()) - -if 'project' in cfg: - project_name = cfg['project'] - -branch_name = 'trunk' -if 'branch' in cfg: - branch_name = cfg['branch'].strip() - -print 'branch: %s' % branch_name +# maps branch name to latest rev +revs = {} os.chdir('regression_tests') -if len(sys.argv) > 1: - latest_rev = int(sys.argv[1]) -else: - latest_rev = 0 +for rev in os.listdir('.'): + try: + branch = rev.split('-')[0] + if branch == 'logs': continue + r = int(rev.split('-')[1]) + if not branch in revs: + revs[branch] = r + else: + if r > revs[branch]: + revs[branch] = r + except: + print 'ignoring %s' % rev - for rev in os.listdir('.'): - try: - if not rev.startswith('%s-' % branch_name): continue - r = int(rev[len(branch_name)+1:]) - if r > latest_rev: latest_rev = r - except: pass +if revs == {}: + print 'no test files found' + sys.exit(1) - if latest_rev == 0: - print 'no test files found' - sys.exit(1) +print 'latest versions' +for b in revs: + print '%s\t%d' % (b, revs[b]) -print 'latest version: %d' % latest_rev +for branch_name in revs: -html_file = 'index.html' + latest_rev = revs[branch_name] -''' -html_file = '%s.html' % rev_dir -index_mtime = modification_time(html_file) + html_file = '%s.html' % branch_name -need_refresh = False + html = open(html_file, 'w+') -for f in glob.glob(os.path.join(rev_dir, '*.json')): - mtime = modification_time(f) + print >>html, '''regression tests, %s +

%s - %s

''' % (project_name, project_name, branch_name) - if mtime > index_mtime: - need_refresh = True - break + print >>html, '' -if not need_refresh: - print 'all up to date' - sys.exit(0) -''' + for r in range(latest_rev, latest_rev - 20, -1): + sys.stdout.write('.') + sys.stdout.flush() -html = open(html_file, 'w+') + print >>html, '' % r -print >>html, '''regression tests, %s -

%s - %s

''' % (project_name, project_name, branch_name) + rev_dir = '%s-%d' % (branch_name, r) + (platforms, tests) = parse_tests(rev_dir) -print >>html, '
revision %d
' + for f in tests: + print >>html, '' % (len(tests[f]), len(tests[f])*9 - 5, f) + print >>html, '' -for r in range(latest_rev, latest_rev - 20, -1): - sys.stdout.write('.') - sys.stdout.flush() + for p in platforms: + print >>html, '' % (len(platforms[p]), p) + idx = 0 + for toolset in platforms[p]: + if idx > 0: print >>html, '' + print >>html, '' % toolset + for f in platforms[p][toolset]: + for t in platforms[p][toolset][f]: + details = platforms[p][toolset][f][t] + if details['status'] == 0: c = 'passed' + else: c = 'failed' + log_name = os.path.join('logs-%s-%d' % (branch_name, r), p + '~' + toolset + '~' + t + '~' + f.replace(' ', '.') + '.html') + print >>html, '' % (t, f, c, log_name) + save_log_file(log_name, project_name, branch_name, '%s - %s' % (t, f), int(details['timestamp']), details['output']) - print >>html, '' % r + print >>html, '' + idx += 1 - rev_dir = '%s-%d' % (branch_name, r) - (platforms, tests) = parse_tests(rev_dir) + print >>html, '
%s
%s
%s
revision %d
' + html.close() - for f in tests: - print >>html, '%s' % (len(tests[f]), len(tests[f])*9 - 5, f) - print >>html, '' - - for p in platforms: - print >>html, '%s' % (len(platforms[p]), p) - idx = 0 - for toolset in platforms[p]: - if idx > 0: print >>html, '' - print >>html, '%s' % toolset - for f in platforms[p][toolset]: - for t in platforms[p][toolset][f]: - details = platforms[p][toolset][f][t] - if details['status'] == 0: c = 'passed' - else: c = 'failed' - log_name = os.path.join('logs-%s-%d' % (branch_name, r), p + '~' + toolset + '~' + t + '~' + f.replace(' ', '.') + '.html') - print >>html, '' % (t, f, c, log_name) - save_log_file(log_name, project_name, branch_name, '%s - %s' % (t, f), int(details['timestamp']), details['output']) - - print >>html, '' - idx += 1 - -print >>html, '' -html.close() - -print '' + print ''