2
2
import unittest
3
3
import pytest
4
4
import subprocess
5
+ from os import path
6
+ import sys
5
7
6
8
from io import StringIO
7
9
@@ -527,31 +529,23 @@ def test_print_dot(self):
527
529
# Require that --enable-ext is provided.
528
530
self .assertEquals (main (["--print-dot" , get_data ('tests/wf/revsort.cwl' )]), 0 )
529
531
530
- from multiprocessing import Process , Queue
531
532
532
533
class TestJsConsole (unittest .TestCase ):
533
- def get_main_stderr (self , queue , args ):
534
- pipe = StringIO ()
535
- queue .put (main (args , stderr = pipe ))
534
+ def get_main_stderr (self , new_args ):
535
+ cwltool_base = path .join (path .dirname (path .abspath (__name__ )), "cwltool" )
536
+
537
+ process = subprocess .Popen ([
538
+ sys .executable ,
539
+ "-m" ,
540
+ "cwltool"
541
+ ] + new_args , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
536
542
537
- queue .put (pipe .getvalue ())
538
- pipe .close ()
539
-
540
- def run_command (command ):
541
- process = subprocess .Popen (command , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
542
543
stdout , stderr = process .communicate ()
543
- exitcode = process .returncode
544
-
545
- return exitcode , stdout , stderr
544
+ return process .returncode , stderr .decode ()
546
545
547
546
def test_js_console_cmd_line_tool (self ):
548
547
for test_file in ("js_output.cwl" , "js_output_workflow.cwl" ):
549
- queue = Queue ()
550
- process = Process (target = self .get_main_stderr , args = (queue , ["--js-console" , get_data ("tests/wf/" + test_file )]))
551
- process .start ()
552
-
553
- error_code = queue .get ()
554
- output = queue .get ()
548
+ error_code , output = self .get_main_stderr (["--js-console" , get_data ("tests/wf/" + test_file )])
555
549
556
550
self .assertIn ("[log] Log message" , output )
557
551
self .assertIn ("[err] Error message" , output )
@@ -560,12 +554,7 @@ def test_js_console_cmd_line_tool(self):
560
554
561
555
def test_no_js_console (self ):
562
556
for test_file in ("js_output.cwl" , "js_output_workflow.cwl" ):
563
- queue = Queue ()
564
- process = Process (target = self .get_main_stderr , args = (queue , ["--debug" , get_data ("tests/wf/" + test_file )]))
565
- process .start ()
566
-
567
- error_code = queue .get ()
568
- output = queue .get ()
557
+ error_code , output = self .get_main_stderr ([get_data ("tests/wf/" + test_file )])
569
558
570
559
self .assertNotIn ("[log] Log message" , output )
571
560
self .assertNotIn ("[err] Error message" , output )
0 commit comments