Skip to content

Commit

Permalink
use proper tmpdir for jobfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias committed Mar 19, 2024
1 parent f803e2c commit 403fc20
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions planemo/engine/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import abc
import json
import os
import shutil
import tempfile
from typing import (
Callable,
Expand Down Expand Up @@ -97,23 +97,20 @@ def _collect_test_results(self, test_cases, test_timeout):
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_directory = tempfile.mkdtemp()
for test_case in test_cases:
if test_case.job_path is None:
job = test_case.job
with tempfile.NamedTemporaryFile(
dir=test_case.tests_directory,
dir=test_directory,
suffix=".json",
prefix="plnmotmptestjob",
delete=False,
mode="w+",
) as f:
tmp_path = f.name
job_path = tmp_path
tmp_paths.append(tmp_path)
json.dump(job, f)
job_paths.append(job_path)
job_paths.append(f.name)
else:
job_paths.append(test_case.job_path)
output_collectors.append(
Expand All @@ -122,8 +119,7 @@ def _run_test_cases(self, test_cases, test_timeout):
try:
run_responses = self._run(runnables, job_paths, output_collectors)
finally:
for tmp_path in tmp_paths:
os.remove(tmp_path)
shutil.rmtree(test_directory)
return run_responses


Expand Down

0 comments on commit 403fc20

Please sign in to comment.