1
0
Fork 0

write results on failures

This commit is contained in:
Christian Kühnel 2020-04-02 09:44:13 +02:00
parent ace846991e
commit e77f46914c

View file

@ -42,9 +42,13 @@ class Cmd:
self.execution_time = None # type: Optional[datetime.timedelta]
@property
def has_title(self):
def has_title(self) -> bool:
return self.title is not None
@property
def was_executed(self) -> bool:
return self.execution_time is not None
class Remove(Cmd):
"""Remove command, sensitive to OS."""
@ -86,8 +90,10 @@ def run_benchmark(commit: str, name: str, result_file_path: str, workdir: str, p
if os.path.exists(workdir):
run_cmd(Remove(workdir), cmd_parameters, '.')
os.makedirs(workdir)
try:
for command in COMMANDS:
run_cmd(command, cmd_parameters, workdir)
finally:
write_results(COMMANDS, result_file_path, name)
@ -107,7 +113,7 @@ def write_results(commands: List[Cmd], result_file_path : str, name: str):
'timestamp': datetime.datetime.now().timestamp(),
'OS': platform.platform()
}
for command in (cmd for cmd in commands if cmd.has_title):
for command in (cmd for cmd in commands if (cmd.has_title and cmd.was_executed)):
row[command.title] = command.execution_time.total_seconds()
writer.writerow(row)
print('Benchmark completed.')