Skip to content

Commit 8d0236e

Browse files
Added tests
1 parent cf87713 commit 8d0236e

File tree

5 files changed

+98
-11
lines changed

5 files changed

+98
-11
lines changed

cwltool/command_line_tool.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,17 +1258,20 @@ 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(cast(str, cwl_version)) >= ORDERED_VERSIONS.index(
1262+
"v1.3.0-dev1"
1263+
):
1264+
for k in list(ret):
1265+
found = False
1266+
for field in expected_schema.fields:
1267+
if k == field.name:
1268+
found = True
1269+
break
1270+
if not found:
1271+
_logger.warning(
1272+
f"Discarded undeclared output named {k!r} from {custom_output}."
1273+
)
1274+
ret.pop(k)
12721275
validate_ex(
12731276
expected_schema,
12741277
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
3+
from .util import get_data, get_main_output
4+
5+
6+
def test_cwl_outpu_json_missing_field_v1_0() -> None:
7+
"""Confirm that unknown outputs are propagated from cwl.output.json in CWL v1.0."""
8+
err_code, stdout, _ = get_main_output([get_data("tests/test-cwl-out-v1.0.cwl")])
9+
assert err_code == 0
10+
assert "foo" in json.loads(stdout)
11+
12+
13+
def test_cwl_outpu_json_missing_field_v1_1() -> None:
14+
"""Confirm that unknown outputs are propagated from cwl.output.json in CWL v1.1."""
15+
err_code, stdout, _ = get_main_output([get_data("tests/test-cwl-out-v1.1.cwl")])
16+
assert err_code == 0
17+
assert "foo" in json.loads(stdout)
18+
19+
20+
def test_cwl_outpu_json_missing_field_v1_2() -> None:
21+
"""Confirm that unknown outputs are propagated from cwl.output.json in CWL v1.2."""
22+
err_code, stdout, _ = get_main_output([get_data("tests/test-cwl-out-v1.2.cwl")])
23+
assert err_code == 0
24+
assert "foo" in json.loads(stdout)

0 commit comments

Comments
 (0)