improve run_tests.py robustness as well as support cleaning of test directory after each full run-through of the tests

This commit is contained in:
Arvid Norberg 2013-06-20 03:20:02 +00:00
parent 7d49a0d148
commit a5926e5177
3 changed files with 29 additions and 4 deletions

View File

@ -5,6 +5,9 @@ project: libtorrent
branch: trunk
clean:
- test_tmp_*
time_limit: 500
features:

View File

@ -137,7 +137,7 @@ def parse_tests(rev_dir):
j = json.loads(open(f, 'rb').read())
timestamp = os.stat(f).st_mtime
except:
print 'FAILED TO LOAD "%s"' %f
print '\nFAILED TO LOAD "%s"\n' %f
continue
platform = platform_toolset[0]

View File

@ -183,7 +183,7 @@ def main(argv):
try:
cfg = open('.regression.yml', 'r')
except:
print '.regressions.yml not found in current directory'
print '.regression.yml not found in current directory'
sys.exit(1)
cfg = yaml.load(cfg.read())
@ -196,7 +196,7 @@ def main(argv):
for d in cfg['test_dirs']:
test_dirs.append(d)
else:
print 'no test directory specified by .regressions.yml'
print 'no test directory specified by .regression.yml'
sys.exit(1)
configs = []
@ -206,6 +206,10 @@ def main(argv):
else:
configs = [['']]
clean_files = []
if 'clean' in cfg:
clean_files = cfg['clean']
branch_name = 'trunk'
if 'branch' in cfg:
branch_name = cfg['branch']
@ -272,9 +276,27 @@ def main(argv):
print ''
# each file contains a full set of tests for one speific toolset and platform
f = open(os.path.join(rev_dir, build_platform + '#' + toolset + '.json'), 'w+')
try:
f = open(os.path.join(rev_dir, build_platform + '#' + toolset + '.json'), 'w+')
except IOError:
rev_dir = os.path.join(current_dir, 'regression_tests')
try: os.mkdir(rev_dir)
except: pass
rev_dir = os.path.join(rev_dir, '%s-%d' % (branch_name, revision))
try: os.mkdir(rev_dir)
except: pass
f = open(os.path.join(rev_dir, build_platform + '#' + toolset + '.json'), 'w+')
print >>f, json.dumps(results)
f.close()
if len(clean_files) > 0:
for filt in clean_files:
for f in glob.glob(filt):
# a precautio to make sure a malicious repo
# won't clean things outside of the test directory
if not os.path.abspath(f).startswith(test_dir): continue
os.rmdirs(f)
finally:
# always restore current directory
os.chdir(current_dir)