From 67f631e44e9f09be86fc6fda126181d3702f20c0 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 20 Jun 2013 04:43:45 +0000 Subject: [PATCH] make sure to always clean up the bjam xml file --- tools/run_tests.py | 118 +++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/tools/run_tests.py b/tools/run_tests.py index 387709b93..9b10075cb 100755 --- a/tools/run_tests.py +++ b/tools/run_tests.py @@ -80,69 +80,71 @@ def svn_info(): def run_tests(toolset, tests, features, options, test_dir, time_limit, incremental): xml_file = 'bjam_build.%d.xml' % random.randint(0, 100000) + try: - results = {} - toolset_found = False - - os.chdir(test_dir) - - if not incremental: - p = subprocess.Popen(['bjam', '--abbreviate-paths', toolset, 'clean'] + options + features.split(' '), stdout=subprocess.PIPE) - for l in p.stdout: pass - p.wait() - - for t in tests: - p = subprocess.Popen(['bjam', '--out-xml=%s' % xml_file, '-l%d' % time_limit, '-q', '--abbreviate-paths', toolset, t] + options + features.split(' '), stdout=subprocess.PIPE) - output = '' - for l in p.stdout: - output += l.decode('latin-1') - p.wait() - - # parse out the toolset version from the xml file - compiler = '' - compiler_version = '' - command = '' - - # make this parse the actual test to pick up the time - # spent runnin the test - try: - dom = et.parse(xml_file) - - command = dom.find('./command').text - - prop = dom.findall('./action/properties/property') - for a in prop: - name = a.attrib['name'] - if name == 'toolset': - compiler = a.text - if compiler_version != '': break - if name.startswith('toolset-') and name.endswith(':version'): - compiler_version = a.text - if compiler != '': break - - if compiler != '' and compiler_version != '': - toolset = compiler + '-' + compiler_version - except: pass + results = {} + toolset_found = False + + os.chdir(test_dir) + + if not incremental: + p = subprocess.Popen(['bjam', '--abbreviate-paths', toolset, 'clean'] + options + features.split(' '), stdout=subprocess.PIPE) + for l in p.stdout: pass + p.wait() + + for t in tests: + p = subprocess.Popen(['bjam', '--out-xml=%s' % xml_file, '-l%d' % time_limit, '-q', '--abbreviate-paths', toolset, t] + options + features.split(' '), stdout=subprocess.PIPE) + output = '' + for l in p.stdout: + output += l.decode('latin-1') + p.wait() + + # parse out the toolset version from the xml file + compiler = '' + compiler_version = '' + command = '' + + # make this parse the actual test to pick up the time + # spent runnin the test + try: + dom = et.parse(xml_file) + + command = dom.find('./command').text + + prop = dom.findall('./action/properties/property') + for a in prop: + name = a.attrib['name'] + if name == 'toolset': + compiler = a.text + if compiler_version != '': break + if name.startswith('toolset-') and name.endswith(':version'): + compiler_version = a.text + if compiler != '': break + + if compiler != '' and compiler_version != '': + toolset = compiler + '-' + compiler_version + except: pass + + r = { 'status': p.returncode, 'output': output, 'command': command } + results[t + '|' + features] = r + + fail_color = '\033[31;1m' + pass_color = '\033[32;1m' + end_seq = '\033[0m' + + if platform.system() == 'Windows': + fail_color == '' + pass_color == '' + end_seq = '' + + if p.returncode == 0: sys.stdout.write('.') + else: sys.stdout.write('X') + sys.stdout.flush() + finally: try: os.unlink(xml_file) except: pass - r = { 'status': p.returncode, 'output': output, 'command': command } - results[t + '|' + features] = r - - fail_color = '\033[31;1m' - pass_color = '\033[32;1m' - end_seq = '\033[0m' - - if platform.system() == 'Windows': - fail_color == '' - pass_color == '' - end_seq = '' - - if p.returncode == 0: sys.stdout.write('.') - else: sys.stdout.write('X') - sys.stdout.flush() - return (toolset, results) def print_usage():