Skip to content

Commit 2c65fad

Browse files
committed
Test js-console with the command line
1 parent be92b41 commit 2c65fad

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

tests/test_examples.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import unittest
33
import pytest
44
import subprocess
5+
from os import path
6+
import sys
57

68
from io import StringIO
79

@@ -527,31 +529,23 @@ def test_print_dot(self):
527529
# Require that --enable-ext is provided.
528530
self.assertEquals(main(["--print-dot", get_data('tests/wf/revsort.cwl')]), 0)
529531

530-
from multiprocessing import Process, Queue
531532

532533
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)
536542

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)
542543
stdout, stderr = process.communicate()
543-
exitcode = process.returncode
544-
545-
return exitcode, stdout, stderr
544+
return process.returncode, stderr.decode()
546545

547546
def test_js_console_cmd_line_tool(self):
548547
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)])
555549

556550
self.assertIn("[log] Log message", output)
557551
self.assertIn("[err] Error message", output)
@@ -560,12 +554,7 @@ def test_js_console_cmd_line_tool(self):
560554

561555
def test_no_js_console(self):
562556
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)])
569558

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

0 commit comments

Comments
 (0)