Skip to content

Add a default None value for dockerimg variable #554

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 5 commits into from
Nov 7, 2017
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
2 changes: 2 additions & 0 deletions cwltool/draft2tool.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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()