Skip to content

Commit a2bd421

Browse files
Added tests
1 parent cf87713 commit a2bd421

File tree

5 files changed

+89
-11
lines changed

5 files changed

+89
-11
lines changed

cwltool/command_line_tool.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,17 +1258,18 @@ def collect_output_ports(
12581258
if compute_checksum:
12591259
adjustFileObjs(ret, partial(compute_checksums, fs_access))
12601260
expected_schema = cast(RecordSchema, self.names.get_name("outputs_record_schema", None))
1261-
for k in list(ret.keys()): # so we don't edit the loops iterable later
1262-
found = False
1263-
for field in expected_schema.fields:
1264-
if k == field.name:
1265-
found = True
1266-
break
1267-
if not found:
1268-
_logger.warning(
1269-
f"Discarded undeclared output named {k!r} from {custom_output}."
1270-
)
1271-
ret.pop(k)
1261+
if ORDERED_VERSIONS.index(cwl_version) >= ORDERED_VERSIONS.index("v1.3.0-dev1"):
1262+
for k in list(ret):
1263+
found = False
1264+
for field in expected_schema.fields:
1265+
if k == field.name:
1266+
found = True
1267+
break
1268+
if not found:
1269+
_logger.warning(
1270+
f"Discarded undeclared output named {k!r} from {custom_output}."
1271+
)
1272+
ret.pop(k)
12721273
validate_ex(
12731274
expected_schema,
12741275
ret,

tests/test-cwl-out-v1.0.cwl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.0
3+
requirements:
4+
- class: ShellCommandRequirement
5+
hints:
6+
DockerRequirement:
7+
dockerPull: docker.io/debian:stable-slim
8+
9+
inputs: []
10+
11+
baseCommand: sh
12+
13+
arguments:
14+
- -c
15+
- |
16+
echo foo > foo && echo '{"foo": {"location": "foo", "class": "File"} }'
17+
18+
stdout: cwl.output.json
19+
20+
outputs: {}

tests/test-cwl-out-v1.1.cwl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.1
3+
requirements:
4+
- class: ShellCommandRequirement
5+
hints:
6+
DockerRequirement:
7+
dockerPull: docker.io/debian:stable-slim
8+
9+
inputs: []
10+
11+
baseCommand: sh
12+
13+
arguments:
14+
- -c
15+
- |
16+
echo foo > foo && echo '{"foo": {"location": "foo", "class": "File"} }'
17+
18+
stdout: cwl.output.json
19+
20+
outputs: {}

tests/test-cwl-out-v1.2.cwl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.2
3+
requirements:
4+
- class: ShellCommandRequirement
5+
hints:
6+
DockerRequirement:
7+
dockerPull: docker.io/debian:stable-slim
8+
9+
inputs: []
10+
11+
baseCommand: sh
12+
13+
arguments:
14+
- -c
15+
- |
16+
echo foo > foo && echo '{"foo": {"location": "foo", "class": "File"} }'
17+
18+
stdout: cwl.output.json
19+
20+
outputs: {}

tests/test_cwl_output_json.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from main import main
2+
from util import get_data
3+
4+
5+
def test_cwl_outpu_json_missing_field_v1_0() -> None:
6+
"""Confirm that unknown outputs are propagated from cwl.output.json in CWL v1.0."""
7+
assert "foo" in main([get_data("tests/test-cwl-out-v1.0.cwl")])
8+
9+
10+
def test_cwl_outpu_json_missing_field_v1_1() -> None:
11+
"""Confirm that unknown outputs are propagated from cwl.output.json in CWL v1.1."""
12+
assert "foo" in main([get_data("tests/wf/test-cwl-out-v1.1.cwl")])
13+
14+
15+
def test_cwl_outpu_json_missing_field_v1_2() -> None:
16+
"""Confirm that unknown outputs are propagated from cwl.output.json in CWL v1.2."""
17+
assert "foo" in main([get_data("tests/wf/test-cwl-out-v1.2.cwl")])

0 commit comments

Comments
 (0)