Skip to content

Commit

Permalink
Merge pull request #554 from common-workflow-language/fix/#552
Browse files Browse the repository at this point in the history
Add a default None value for dockerimg variable
  • Loading branch information
mr-c committed Nov 7, 2017
2 parents dc621b5 + 08c9913 commit 7457766
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cwltool/draft2tool.py
Expand Up @@ -264,6 +264,8 @@ def job(self,
dockerimg = docker_req.get("dockerImageId") or docker_req.get("dockerPull")
elif kwargs.get("default_container", None) is not None and kwargs.get("use_container"):
dockerimg = kwargs.get("default_container")
else:
dockerimg = None

if dockerimg:
cmdline = ["docker", "run", dockerimg] + cmdline
Expand Down
34 changes: 25 additions & 9 deletions tests/test_examples.py
Expand Up @@ -7,6 +7,8 @@

from io import StringIO

from cwltool.utils import onWindows

try:
reload
except:
Expand Down Expand Up @@ -530,19 +532,20 @@ def test_print_dot(self):
self.assertEquals(main(["--print-dot", get_data('tests/wf/revsort.cwl')]), 0)


class TestJsConsole(unittest.TestCase):
class TestCmdLine(unittest.TestCase):
def get_main_stderr(self, new_args):
cwltool_base = path.join(path.dirname(path.abspath(__name__)), "cwltool")

process = subprocess.Popen([
sys.executable,
"-m",
"cwltool"
] + new_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sys.executable,
"-m",
"cwltool"
] + new_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

stdout, stderr = process.communicate()
return process.returncode, stderr.decode()


class TestJsConsole(TestCmdLine):

def test_js_console_cmd_line_tool(self):
for test_file in ("js_output.cwl", "js_output_workflow.cwl"):
error_code, output = self.get_main_stderr(["--js-console", "--no-container",
Expand All @@ -555,11 +558,24 @@ def test_js_console_cmd_line_tool(self):

def test_no_js_console(self):
for test_file in ("js_output.cwl", "js_output_workflow.cwl"):
error_code, output = self.get_main_stderr(["--no-container",
error_code, output = self.get_main_stderr(["--no-container",
get_data("tests/wf/" + test_file)])

self.assertNotIn("[log] Log message", output)
self.assertNotIn("[err] Error message", output)



@pytest.mark.skipif(onWindows(),
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
"which is not supported on AppVeyor")
class TestCache(TestCmdLine):
def test_wf_without_container(self):
test_file = "hello-workflow.cwl"
error_code, output = self.get_main_stderr(["--cachedir", "cache",
get_data("tests/wf/" + test_file), "--usermessage", "hello"])
self.assertIn("completed success", output)
self.assertEquals(error_code, 0)


if __name__ == '__main__':
unittest.main()

0 comments on commit 7457766

Please sign in to comment.