|
3 | 3 |
|
4 | 4 | import pytest
|
5 | 5 | from cwltool.main import main
|
| 6 | +import cwltool.executors |
6 | 7 |
|
7 | 8 | from .util import get_data, needs_docker
|
8 | 9 |
|
9 |
| - |
10 | 10 | script_a = '''
|
11 | 11 | #!/usr/bin/env cwl-runner
|
12 | 12 | cwlVersion: v1.0
|
@@ -94,3 +94,38 @@ def test_argparse(name, script_contents, params, tmpdir):
|
94 | 94 | finally:
|
95 | 95 | if script and script.name and os.path.exists(script.name):
|
96 | 96 | os.unlink(script.name)
|
| 97 | + |
| 98 | + |
| 99 | +class NoopJobExecutor(cwltool.executors.JobExecutor): |
| 100 | + def run_jobs(self, |
| 101 | + process, # type: Process |
| 102 | + job_order_object, # type: Dict[Text, Any] |
| 103 | + logger, # type: logging.Logger |
| 104 | + runtime_context # type: RuntimeContext |
| 105 | + ): # type: (...) -> None |
| 106 | + pass |
| 107 | + |
| 108 | + def execute(self, |
| 109 | + process, # type: Process |
| 110 | + job_order_object, # type: Dict[Text, Any] |
| 111 | + runtime_context, # type: RuntimeContext |
| 112 | + logger=None, # type: logging.Logger |
| 113 | + ): # type: (...) -> Tuple[Optional[Union[Dict[Text, Any], List[Dict[Text, Any]]]], Text] |
| 114 | + return {}, "success" |
| 115 | + |
| 116 | +def test_dont_require_inputs(): |
| 117 | + script = None |
| 118 | + try: |
| 119 | + script = NamedTemporaryFile(mode='w', delete=False) |
| 120 | + script.write(script_a) |
| 121 | + script.close() |
| 122 | + |
| 123 | + assert main(argsl=[script.name, "--input", script.name], executor=NoopJobExecutor()) == 0 |
| 124 | + assert main(argsl=[script.name], executor=NoopJobExecutor()) == 2 |
| 125 | + assert main(argsl=[script.name], executor=NoopJobExecutor(), input_required=False) == 0 |
| 126 | + |
| 127 | + except SystemExit as err: |
| 128 | + assert err.code == 0, name |
| 129 | + finally: |
| 130 | + if script and script.name and os.path.exists(script.name): |
| 131 | + os.unlink(script.name) |
0 commit comments