Repository: common-workflow-language/cwltool

Issue:
--no-compute-checksum doesn't seem to be honored
## Expected Behavior

checksum should not be calculated when `cwltool --no-compute-checksum ...` is in use

## Actual Behavior

I'm seeing the checksum's being written to stdout.

## Executing with

```
cwltool --no-compute-checksum --enable-dev --non-strict\
 --outdir /home/ubuntu/datastore//launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/\
 --tmpdir-prefix /home/ubuntu/datastore//launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/tmp/\
 --tmp-outdir-prefix /home/ubuntu/datastore//launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/working/\
 /home/ubuntu/Dockstore_bam.cwl\
 /home/ubuntu/datastore//launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/workflow_params.json
```

## Output

```json
{
    "out_bam": {
        "checksum": "sha1$e9e4c479937e797baf0f570b71bff0fd6de71138", 
        "basename": "test.bam", 
        "location": "file:///home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam", 
        "secondaryFiles": [
            {
                "checksum": "sha1$1338447f52c9973e9bcb7ea79a2c4edffd3d815a", 
                "basename": "test.bam.bai", 
                "location": "file:///home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.bai", 
                "path": "/home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.bai", 
                "class": "File", 
                "size": 951528
            }, 
            {
                "checksum": "sha1$1a70259925f883e4a4856b225339e943c535996d", 
                "basename": "test.bam.bas", 
                "location": "file:///home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.bas", 
                "path": "/home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.bas", 
                "class": "File", 
                "size": 660
            }, 
            {
                "checksum": "sha1$12ad46945f5daae7afe44f59d84b6d3a3334ca40", 
                "basename": "test.bam.md5", 
                "location": "file:///home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.md5", 
                "path": "/home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.md5", 
                "class": "File", 
                "size": 32
            }, 
            {
                "checksum": "sha1$6414f4853c802bc08ac9e89acd33325b6846ece9", 
                "basename": "test.bam.met", 
                "location": "file:///home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.met", 
                "path": "/home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.met", 
                "class": "File", 
                "size": 1471
            }, 
            {
                "checksum": "sha1$02cd48fc01ed7aa23b42e285a84bc36acf923eb3", 
                "basename": "test.bam.maptime", 
                "location": "file:///home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.maptime", 
                "path": "/home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam.maptime", 
                "class": "File", 
                "size": 394
            }
        ], 
        "path": "/home/ubuntu/datastore/launcher-da4b0f53-f4bd-41b7-95d3-7de71a519054/outputs/test.bam", 
        "class": "File", 
        "size": 6600410
    }
}
```

## Your Environment

```
/usr/local/bin/cwltool 1.0.20170828135420
```



Discussion:
Just confirmed this occurs on configs without secondaryFiles directives.

Resolving patch:
diff --git a/cwltool/executors.py b/cwltool/executors.py
--- a/cwltool/executors.py
+++ b/cwltool/executors.py
@@ -71,7 +71,8 @@ def execute(self, t,  # type: Process
         if self.final_output and self.final_output[0] and finaloutdir:
             self.final_output[0] = relocateOutputs(self.final_output[0], finaloutdir,
                                                    self.output_dirs, kwargs.get("move_outputs"),
-                                                   kwargs["make_fs_access"](""))
+                                                   kwargs["make_fs_access"](""),
+                                                   kwargs["compute_checksum"])
 
         if kwargs.get("rm_tmpdir"):
             cleanIntermediate(self.output_dirs)
diff --git a/cwltool/process.py b/cwltool/process.py
--- a/cwltool/process.py
+++ b/cwltool/process.py
@@ -256,8 +256,8 @@ def collectFilesAndDirs(obj, out):
             collectFilesAndDirs(l, out)
 
 
-def relocateOutputs(outputObj, outdir, output_dirs, action, fs_access):
-    # type: (Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Set[Text], Text, StdFsAccess) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
+def relocateOutputs(outputObj, outdir, output_dirs, action, fs_access, compute_checksum):
+    # type: (Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Set[Text], Text, StdFsAccess, bool) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
     adjustDirObjs(outputObj, functools.partial(get_listing, fs_access, recursive=True))
 
     if action not in ("move", "copy"):
@@ -299,8 +299,8 @@ def _check_adjust(f):
         return f
 
     visit_class(outputObj, ("File", "Directory"), _check_adjust)
-
-    visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
+    if compute_checksum:
+        visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
 
     # If there are symlinks to intermediate output directories, we want to move
     # the real files into the final output location.  If a file is linked more than once,


Test patch:
diff --git a/tests/test_examples.py b/tests/test_examples.py
--- a/tests/test_examples.py
+++ b/tests/test_examples.py
@@ -559,7 +559,7 @@ def test_print_dot(self):
 
 
 class TestCmdLine(unittest.TestCase):
-    def get_main_stderr(self, new_args):
+    def get_main_output(self, new_args):
         process = subprocess.Popen([
                                        sys.executable,
                                        "-m",
@@ -567,28 +567,28 @@ def get_main_stderr(self, new_args):
                                    ] + new_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 
         stdout, stderr = process.communicate()
-        return process.returncode, stderr.decode()
+        return process.returncode, stdout.decode(), 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",
-                get_data("tests/wf/" + test_file)])
+            error_code, stdout, stderr = self.get_main_output(["--js-console", "--no-container",
+                                                               get_data("tests/wf/" + test_file)])
 
-            self.assertIn("[log] Log message", output)
-            self.assertIn("[err] Error message", output)
+            self.assertIn("[log] Log message", stderr)
+            self.assertIn("[err] Error message", stderr)
 
-            self.assertEquals(error_code, 0, output)
+            self.assertEquals(error_code, 0, stderr)
 
     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",
-                get_data("tests/wf/" + test_file)])
+            error_code, stdout, stderr = self.get_main_output(["--no-container",
+                                                               get_data("tests/wf/" + test_file)])
 
-            self.assertNotIn("[log] Log message", output)
-            self.assertNotIn("[err] Error message", output)
+            self.assertNotIn("[log] Log message", stderr)
+            self.assertNotIn("[err] Error message", stderr)
 
 
 @pytest.mark.skipif(onWindows(),
@@ -597,11 +597,36 @@ def test_no_js_console(self):
 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)
+        error_code, stdout, stderr = self.get_main_output(["--cachedir", "cache",
+                                                   get_data("tests/wf/" + test_file), "--usermessage", "hello"])
+        self.assertIn("completed success", stderr)
         self.assertEquals(error_code, 0)
 
+@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 TestChecksum(TestCmdLine):
+
+    def test_compute_checksum(self):
+        f = cwltool.factory.Factory(compute_checksum=True, use_container=False)
+        echo = f.make(get_data("tests/wf/cat-tool.cwl"))
+        output = echo(file1={
+                "class": "File",
+                "location": get_data("tests/wf/whale.txt")
+            },
+            reverse=False
+        )
+        self.assertEquals(output['output']["checksum"], "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376")
+
+    def test_no_compute_checksum(self):
+        test_file = "tests/wf/wc-tool.cwl"
+        job_file = "tests/wf/wc-job.json"
+        error_code, stdout, stderr = self.get_main_output(["--no-compute-checksum",
+                                                   get_data(test_file), get_data(job_file)])
+        self.assertIn("completed success", stderr)
+        self.assertEquals(error_code, 0)
+        self.assertNotIn("checksum", stdout)
+
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/wf/cat-tool.cwl b/tests/wf/cat-tool.cwl
new file mode 100644
--- /dev/null
+++ b/tests/wf/cat-tool.cwl
@@ -0,0 +1,17 @@
+#!/usr/bin/env cwl-runner
+
+class: CommandLineTool
+cwlVersion: v1.0
+
+inputs:
+  file1: File
+
+outputs:
+  output:
+    type: File
+    outputBinding: { glob: output }
+
+baseCommand: [cat]
+
+stdin: $(inputs.file1.path)
+stdout: output