report: Add trial commit info to junit file
Change-Id: I997bbbeb3807af5cd927594a4155b824f0c6d03d
This commit is contained in:
parent
f3df1e4519
commit
ef919c0f1c
|
@ -46,6 +46,14 @@ def escape_xml_invalid_characters(str):
|
|||
replacement_char = '\uFFFD' # Unicode replacement character
|
||||
return invalid_xml_char_ranges_regex.sub(replacement_char, escape(str))
|
||||
|
||||
def hash_info_to_junit(testsuite, hash_info):
|
||||
properties = et.SubElement(testsuite, 'properties')
|
||||
for key, val in hash_info.items():
|
||||
prop = et.SubElement(properties, 'property')
|
||||
prop.set('name', 'ref:' + key)
|
||||
prop.set('value', val)
|
||||
|
||||
|
||||
def trial_to_junit_write(trial, junit_path):
|
||||
elements = et.ElementTree(element=trial_to_junit(trial))
|
||||
elements.write(junit_path)
|
||||
|
@ -57,8 +65,10 @@ def trial_to_junit(trial):
|
|||
num_errors = 0
|
||||
time = 0
|
||||
id = 0
|
||||
hash_info = trial.get_all_inst_hash_info()
|
||||
for suite in trial.suites:
|
||||
testsuite = suite_to_junit(suite)
|
||||
hash_info_to_junit(testsuite, hash_info)
|
||||
testsuite.set('id', str(id))
|
||||
id += 1
|
||||
testsuites.append(testsuite)
|
||||
|
|
|
@ -21,6 +21,7 @@ import os
|
|||
import time
|
||||
import shutil
|
||||
import tarfile
|
||||
import pathlib
|
||||
|
||||
from . import log
|
||||
from . import util
|
||||
|
@ -212,6 +213,22 @@ class Trial(log.Origin):
|
|||
self.log('Storing JUnit report in', junit_path)
|
||||
report.trial_to_junit_write(self, junit_path)
|
||||
|
||||
def get_all_inst_hash_info(self):
|
||||
d = {}
|
||||
pathlist = pathlib.Path(str(self.inst_dir)).glob('**/*git_hashes.txt')
|
||||
for path in pathlist:
|
||||
# because path is object not string
|
||||
abs_path_str = str(path) # because path is object not string
|
||||
dir, file = os.path.split(abs_path_str)
|
||||
reldir = os.path.relpath(dir, str(self.inst_dir)).rstrip(os.sep)
|
||||
with open(abs_path_str, 'r') as f:
|
||||
for line in [l.strip() for l in f.readlines()]:
|
||||
if not line:
|
||||
continue
|
||||
hash, proj = tuple(line.split(' ', 1))
|
||||
d[os.path.join(reldir,proj)] = hash
|
||||
return d
|
||||
|
||||
def log_report(self):
|
||||
log.large_separator(self.name(), self.status)
|
||||
self.log(report.trial_to_text(self))
|
||||
|
|
Loading…
Reference in New Issue