records -> results

This commit is contained in:
Daniel 2023-12-11 00:43:12 +01:00
parent 093818bc81
commit 7c1f1ff5d4
5 changed files with 13 additions and 18 deletions

View file

@ -37,7 +37,7 @@ def run():
# todo: move to Coordinator # todo: move to Coordinator
DIR = DirManager(output_dir=args.output_dir, session_id=session_id) DIR = DirManager(output_dir=args.output_dir, session_id=session_id)
log_file = DIR.RECORDS / "coordinator.log" log_file = DIR.RESULTS / "coordinator.log"
logger.add(log_file) logger.add(log_file)
# ---------------------------- initialize and run ---------------------------- # # ---------------------------- initialize and run ---------------------------- #

View file

@ -60,13 +60,13 @@ class Coordinator:
def combine_html(self) -> None: def combine_html(self) -> None:
"""combines all generated pytest html reports into one""" """combines all generated pytest html reports into one"""
in_dir_path = str(self.DIR.RECORDS / "html") in_dir_path = str(self.DIR.RESULTS / "html")
out_file_path = str(self.DIR.RECORDS / "full-report.html") out_file_path = str(self.DIR.RESULTS / "full-report.html")
title = "combined.html" title = "combined.html"
merge_html_reports(in_dir_path, out_file_path, title) merge_html_reports(in_dir_path, out_file_path, title)
def collect_traces(self): def collect_traces(self):
"""moves all traces into SESSION/RECORDS dir """moves all traces into SESSION/RESULTS dir
if tests are rerun and generate another trace, the new trace will get a unique name such as if tests are rerun and generate another trace, the new trace will get a unique name such as
tracename-0 tracename-0
@ -82,9 +82,9 @@ class Coordinator:
index += 1 index += 1
return get_new_path(root_dir, base_name, index=index) return get_new_path(root_dir, base_name, index=index)
trace_root_dir = self.DIR.RECORDS / "traces" trace_root_dir = self.DIR.RESULTS / "traces"
for f in trace_root_dir.rglob("*/trace.zip"): for f in trace_root_dir.rglob("*/trace.zip"):
new_path = get_new_path(self.DIR.RECORDS, f.parent.name) new_path = get_new_path(self.DIR.RESULTS, f.parent.name)
f.parent.rename(new_path) f.parent.rename(new_path)
rmtree(trace_root_dir) rmtree(trace_root_dir)

View file

@ -49,9 +49,9 @@ def DIR(request) -> DirManager:
DIR.OUTPUT DIR.OUTPUT
DIR.SESSION DIR.SESSION
DIR.RECORDS
DIR.STATES DIR.STATES
DIR.RESULTS""" DIR.RESULTS
DIR.STATUS"""
output_dir = request.config.getoption("--output_dir") output_dir = request.config.getoption("--output_dir")
assert output_dir, "pytest argument --output_dir not set" assert output_dir, "pytest argument --output_dir not set"

View file

@ -11,11 +11,11 @@ class DirManager:
The structures is as follows: The structures is as follows:
tests dir/ tests dir/
session_id-1/ session_id-1/
records
results results
states states
status
session_id-2/ session_id-2/
records results
... ...
""" """
@ -32,7 +32,6 @@ class DirManager:
dirs: list[Path] = [ dirs: list[Path] = [
self.OUTPUT_DIR, self.OUTPUT_DIR,
self.SESSION, self.SESSION,
self.RECORDS,
self.HTML, self.HTML,
self.STATES, self.STATES,
self.ENV_FILES, self.ENV_FILES,
@ -50,13 +49,9 @@ class DirManager:
def SESSION(self): def SESSION(self):
return self.OUTPUT_DIR / self.session_id return self.OUTPUT_DIR / self.session_id
@property
def RECORDS(self):
return self.SESSION / "records"
@property @property
def HTML(self): def HTML(self):
return self.RECORDS / "html" return self.RESULTS / "html"
@property @property
def STATES(self): def STATES(self):

View file

@ -158,7 +158,7 @@ class Runner:
# --output only works with the given context and page fixture # --output only works with the given context and page fixture
# folder needs to be unique! traces will not appear, if every pytest run has same output dir # folder needs to be unique! traces will not appear, if every pytest run has same output dir
command_arguments.append("--output") command_arguments.append("--output")
command_arguments.append(str(self.DIR.RECORDS / "traces" / full_test_path.stem)) command_arguments.append(str(self.DIR.RESULTS / "traces" / full_test_path.stem))
# tracing # tracing
command_arguments.append("--tracing") # "on", "off", "retain-on-failure" command_arguments.append("--tracing") # "on", "off", "retain-on-failure"
@ -173,7 +173,7 @@ class Runner:
# command_arguments.append("--headed") # command_arguments.append("--headed")
# html report. Will be combined into one file later. # html report. Will be combined into one file later.
command_arguments.append(f"--html={self.DIR.RECORDS / 'html' / full_test_path.with_suffix('.html').name}") command_arguments.append(f"--html={self.DIR.RESULTS / 'html' / full_test_path.with_suffix('.html').name}")
return pytest.main(command_arguments) return pytest.main(command_arguments)