Skip to content

Fix type mismatches that caused bad error messages #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ def generate_arg(self, binding): # type: (Dict[Text,Any]) -> List[Text]

prefix = binding.get("prefix")
sep = binding.get("separate", True)
if prefix is None and not sep:
with SourceLine(binding, "separate", WorkflowException, _logger.isEnabledFor(logging.DEBUG)):
raise WorkflowException("'separate' option can not be specified without prefix")

l = [] # type: List[Dict[Text,Text]]
if isinstance(value, list):
Expand Down
5 changes: 4 additions & 1 deletion cwltool/load_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from avro.schema import Names
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from schema_salad.ref_resolver import ContextType, Fetcher, Loader, file_uri
from schema_salad.sourceline import cmap
from schema_salad.sourceline import cmap, SourceLine
from schema_salad.validate import ValidationException

from . import process, update
Expand Down Expand Up @@ -124,6 +124,9 @@ def _convert_stdstreams_to_files(workflowobj):
if isinstance(workflowobj, dict):
if workflowobj.get('class') == 'CommandLineTool':
for out in workflowobj.get('outputs', []):
if type(out) is not CommentedMap:
with SourceLine(workflowobj, "outputs", ValidationException, _logger.isEnabledFor(logging.DEBUG)):
raise ValidationException("Output '%s' is not a valid OutputParameter." % out)
for streamtype in ['stdout', 'stderr']:
if out.get('type') == streamtype:
if 'outputBinding' in out:
Expand Down
15 changes: 15 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from io import StringIO

from cwltool.errors import WorkflowException
from cwltool.utils import onWindows

try:
Expand Down Expand Up @@ -525,6 +526,20 @@ def test_lifting(self):
echo = f.make(get_data("tests/test_bad_outputs_wf.cwl"))
self.assertEqual(echo(inp="foo"), {"out": "foo\n"})

def test_malformed_outputs(self):
# check that tool validation fails if one of the outputs is not a valid CWL type
f = cwltool.factory.Factory()
with self.assertRaises(schema_salad.validate.ValidationException):
echo = f.make(get_data("tests/wf/malformed_outputs.cwl"))
echo()

def test_separate_without_prefix(self):
# check that setting 'separate = false' on an inputBinding without prefix fails the workflow
with self.assertRaises(WorkflowException):
f = cwltool.factory.Factory()
echo = f.make(get_data("tests/wf/separate_without_prefix.cwl"))
echo()


def test_checker(self):
# check that the static checker raises exception when a source type
Expand Down
8 changes: 8 additions & 0 deletions tests/wf/malformed_outputs.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo

inputs:
[]
outputs:
-
22 changes: 22 additions & 0 deletions tests/wf/separate_without_prefix.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo

inputs:
src:
type: string
default:
string
inputBinding:
position: 1
separate: false

stdout: output.txt

outputs:
output:
type: string
outputBinding:
glob: output.txt
loadContents: true
outputEval: $(self[0].contents)