@@ -559,36 +559,36 @@ def test_print_dot(self):
559
559
560
560
561
561
class TestCmdLine (unittest .TestCase ):
562
- def get_main_stderr (self , new_args ):
562
+ def get_main_output (self , new_args ):
563
563
process = subprocess .Popen ([
564
564
sys .executable ,
565
565
"-m" ,
566
566
"cwltool"
567
567
] + new_args , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
568
568
569
569
stdout , stderr = process .communicate ()
570
- return process .returncode , stderr .decode ()
570
+ return process .returncode , stdout . decode (), stderr .decode ()
571
571
572
572
573
573
class TestJsConsole (TestCmdLine ):
574
574
575
575
def test_js_console_cmd_line_tool (self ):
576
576
for test_file in ("js_output.cwl" , "js_output_workflow.cwl" ):
577
- error_code , output = self .get_main_stderr (["--js-console" , "--no-container" ,
578
- get_data ("tests/wf/" + test_file )])
577
+ error_code , stdout , stderr = self .get_main_output (["--js-console" , "--no-container" ,
578
+ get_data ("tests/wf/" + test_file )])
579
579
580
- self .assertIn ("[log] Log message" , output )
581
- self .assertIn ("[err] Error message" , output )
580
+ self .assertIn ("[log] Log message" , stderr )
581
+ self .assertIn ("[err] Error message" , stderr )
582
582
583
- self .assertEquals (error_code , 0 , output )
583
+ self .assertEquals (error_code , 0 , stderr )
584
584
585
585
def test_no_js_console (self ):
586
586
for test_file in ("js_output.cwl" , "js_output_workflow.cwl" ):
587
- error_code , output = self .get_main_stderr (["--no-container" ,
588
- get_data ("tests/wf/" + test_file )])
587
+ error_code , stdout , stderr = self .get_main_output (["--no-container" ,
588
+ get_data ("tests/wf/" + test_file )])
589
589
590
- self .assertNotIn ("[log] Log message" , output )
591
- self .assertNotIn ("[err] Error message" , output )
590
+ self .assertNotIn ("[log] Log message" , stderr )
591
+ self .assertNotIn ("[err] Error message" , stderr )
592
592
593
593
594
594
@pytest .mark .skipif (onWindows (),
@@ -597,11 +597,36 @@ def test_no_js_console(self):
597
597
class TestCache (TestCmdLine ):
598
598
def test_wf_without_container (self ):
599
599
test_file = "hello-workflow.cwl"
600
- error_code , output = self .get_main_stderr (["--cachedir" , "cache" ,
601
- get_data ("tests/wf/" + test_file ), "--usermessage" , "hello" ])
602
- self .assertIn ("completed success" , output )
600
+ error_code , stdout , stderr = self .get_main_output (["--cachedir" , "cache" ,
601
+ get_data ("tests/wf/" + test_file ), "--usermessage" , "hello" ])
602
+ self .assertIn ("completed success" , stderr )
603
603
self .assertEquals (error_code , 0 )
604
604
605
+ @pytest .mark .skipif (onWindows (),
606
+ reason = "Instance of cwltool is used, on Windows it invokes a default docker container"
607
+ "which is not supported on AppVeyor" )
608
+ class TestChecksum (TestCmdLine ):
609
+
610
+ def test_compute_checksum (self ):
611
+ f = cwltool .factory .Factory (compute_checksum = True , use_container = False )
612
+ echo = f .make (get_data ("tests/wf/cat-tool.cwl" ))
613
+ output = echo (file1 = {
614
+ "class" : "File" ,
615
+ "location" : get_data ("tests/wf/whale.txt" )
616
+ },
617
+ reverse = False
618
+ )
619
+ self .assertEquals (output ['output' ]["checksum" ], "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376" )
620
+
621
+ def test_no_compute_checksum (self ):
622
+ test_file = "tests/wf/wc-tool.cwl"
623
+ job_file = "tests/wf/wc-job.json"
624
+ error_code , stdout , stderr = self .get_main_output (["--no-compute-checksum" ,
625
+ get_data (test_file ), get_data (job_file )])
626
+ self .assertIn ("completed success" , stderr )
627
+ self .assertEquals (error_code , 0 )
628
+ self .assertNotIn ("checksum" , stdout )
629
+
605
630
606
631
if __name__ == '__main__' :
607
632
unittest .main ()
0 commit comments