Skip to content

Commit

Permalink
Simplify test result collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Nov 14, 2023
1 parent ff4e465 commit e8828fa
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions planemo/engine/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,21 @@ def test(self, runnables, test_timeout):
"""Test runnable artifacts (workflow or tool)."""
self._check_can_run_all(runnables)
test_cases = [t for tl in map(cases, runnables) for t in tl]
test_results = self._collect_test_results(test_cases, test_timeout)
tests = []
for test_case, run_response in test_results:
test_case_data = test_case.structured_test_data(run_response)
tests.append(test_case_data)
test_results = self._run_test_cases(test_cases, test_timeout)
test_data = {
"version": "0.1",
"tests": tests,
"tests": test_results,
}
structured_results = StructuredData(data=test_data)
structured_results.calculate_summary_data()
return structured_results

def _collect_test_results(self, test_cases, test_timeout):
run_responses = self._run_test_cases(test_cases, test_timeout)
return [(test_case, run_response) for test_case, run_response in zip(test_cases, run_responses)]

def _run_test_cases(self, test_cases, test_timeout):
runnables = [test_case.runnable for test_case in test_cases]
job_paths = []
tmp_paths = []
output_collectors = []
test_results = []
for test_case in test_cases:
if test_case.job_path is None:
job = test_case.job
Expand All @@ -116,13 +109,15 @@ def _run_test_cases(self, test_cases, test_timeout):
job_paths.append(job_path)
else:
job_paths.append(test_case.job_path)
output_collectors.append(lambda run_response, test_case=test_case: test_case.structured_test_data(run_response))
output_collectors.append(
lambda run_response, test_case=test_case: test_results.append(test_case.structured_test_data(run_response))
)
try:
run_responses = self._run(runnables, job_paths, output_collectors)
self._run(runnables, job_paths, output_collectors)
finally:
for tmp_path in tmp_paths:
os.remove(tmp_path)
return run_responses
return test_results


__all__ = (
Expand Down

0 comments on commit e8828fa

Please sign in to comment.