Skip to content

Commit d96ddbf

Browse files
tetronmr-c
andauthored
Call fsaccess.realpath before comparing paths in _relocate. (#1560)
Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent 29d8279 commit d96ddbf

File tree

8 files changed

+44
-5
lines changed

8 files changed

+44
-5
lines changed

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ include tests/tmp4/alpha/*
1010
include tests/wf/*
1111
include tests/wf/operation/*
1212
include tests/override/*
13+
include tests/reloc/*.cwl
14+
include tests/reloc/dir1/*
15+
include tests/reloc/dir2/*
1316
include tests/checker_wf/*
1417
include tests/subgraph/*
1518
include tests/trs/*

cwltool/process.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,13 @@ def _collectDirEntries(
354354
yield from _collectDirEntries(sub_obj)
355355

356356
def _relocate(src: str, dst: str) -> None:
357+
src = fs_access.realpath(src)
358+
dst = fs_access.realpath(dst)
359+
357360
if src == dst:
358361
return
359362

360363
# If the source is not contained in source_directories we're not allowed to delete it
361-
src = fs_access.realpath(src)
362364
src_can_deleted = any(
363365
os.path.commonprefix([p, src]) == p for p in source_directories
364366
)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ requests>=2.4.3
22
ruamel.yaml>=0.15,<0.17.17
33
rdflib>=4.2.2,<6.1
44
shellescape>=3.4.1,<3.9
5-
schema-salad>=8.2.20210914115719,<9
5+
schema-salad>=8.2.20211104054942,<9
66
prov==1.5.1
77
bagit==1.8.1
88
mypy-extensions

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@
111111
"ruamel.yaml >= 0.15, < 0.17.17",
112112
"rdflib >= 4.2.2, < 6.1.0",
113113
"shellescape >= 3.4.1, < 3.9",
114-
# 7.1.20210518142926 or later required due to
115-
# https://github.com/common-workflow-language/schema_salad/issues/385
116-
"schema-salad >= 8.2.20210914115719, < 9",
114+
"schema-salad >= 8.2.20211104054942, < 9",
117115
"mypy-extensions",
118116
"psutil >= 5.6.6",
119117
"prov == 1.5.1",

tests/reloc/dir1/foo

Whitespace-only changes.

tests/reloc/dir2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dir1

tests/reloc/test.cwl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cwlVersion: v1.2
2+
class: CommandLineTool
3+
inputs:
4+
inp: Directory
5+
outputs:
6+
bar:
7+
type: File
8+
outputBinding:
9+
glob: dir2/foo
10+
requirements:
11+
InlineJavascriptRequirement: {}
12+
InitialWorkDirRequirement:
13+
listing:
14+
- $(inputs.inp)
15+
arguments: [ls, -l]

tests/test_relocate.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import json
22
import sys
33
from pathlib import Path
4+
import tempfile
45

56
from cwltool.main import main
7+
from cwltool.process import relocateOutputs
8+
from cwltool.stdfsaccess import StdFsAccess
9+
from cwltool.pathmapper import PathMapper
610

711
from .util import get_data, needs_docker
812

@@ -33,3 +37,19 @@ def test_for_conflict_file_names(tmp_path: Path) -> None:
3337
out = json.loads(stream.getvalue())
3438
assert out["b1"]["basename"] == out["b2"]["basename"]
3539
assert out["b1"]["location"] != out["b2"]["location"]
40+
41+
42+
def test_relocate_symlinks(tmp_path: Path) -> None:
43+
assert (
44+
main(
45+
[
46+
"--debug",
47+
"--outdir",
48+
get_data("tests/reloc") + "/dir2",
49+
get_data("tests/reloc/test.cwl"),
50+
"--inp",
51+
get_data("tests/reloc") + "/dir2",
52+
]
53+
)
54+
== 0
55+
)

0 commit comments

Comments
 (0)