Skip to content

Commit 15ec9ef

Browse files
committed
test --leave-tmpdir
1 parent e79d1a0 commit 15ec9ef

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/test_tmpdir.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test that all temporary directories respect the --tmpdir-prefix and --tmp-outdir-prefix options."""
2+
import re
23
import subprocess
34
import sys
45
from pathlib import Path
@@ -20,7 +21,7 @@
2021
from cwltool.utils import create_tmp_dir
2122
from ruamel.yaml.comments import CommentedMap
2223

23-
from .util import get_data, needs_docker
24+
from .util import get_data, get_main_output, needs_docker
2425

2526

2627
def test_docker_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None:
@@ -273,3 +274,22 @@ def test_remove_tmpdirs(tmp_path: Path) -> None:
273274
== 0
274275
)
275276
assert len(list(tmp_path.iterdir())) == 0
277+
278+
279+
def test_leave_tmpdirs(tmp_path: Path) -> None:
280+
"""Test that the tmpdirs including input staging directories are retained after the job execution."""
281+
error_code, stdout, stderr = get_main_output(
282+
[
283+
"--debug",
284+
"--tmpdir-prefix",
285+
str(f"{tmp_path}/tmp/"),
286+
"--leave-tmpdir",
287+
"--outdir",
288+
str(f"{tmp_path}/out/"),
289+
get_data("tests/env4.cwl"),
290+
]
291+
)
292+
assert error_code == 0
293+
assert re.search(rf"\"{re.escape(str(tmp_path))}/tmp/.*/env0\.py\"", stderr)
294+
assert len(list((tmp_path / "tmp").iterdir())) == 3
295+
assert len(list((tmp_path / "tmp").glob("**/env0.py"))) == 1

0 commit comments

Comments
 (0)