|
4 | 4 | import logging |
5 | 5 | import re |
6 | 6 |
|
| 7 | +import pytest |
| 8 | + |
7 | 9 | from .util import get_data, get_main_output |
8 | 10 |
|
9 | 11 |
|
@@ -125,3 +127,37 @@ def test_validate_custom_logger() -> None: |
125 | 127 | assert "tests/CometAdapter.cwl#out' previously defined" not in stdout |
126 | 128 | assert "tests/CometAdapter.cwl#out' previously defined" not in stderr |
127 | 129 | assert "tests/CometAdapter.cwl#out' previously defined" in custom_log_text |
| 130 | + |
| 131 | + |
| 132 | +def test_validate_warns_on_basecommand_with_space() -> None: |
| 133 | + """A 'baseCommand' string containing whitespace warns but still validates.""" |
| 134 | + custom_log = io.StringIO() |
| 135 | + handler = logging.StreamHandler(custom_log) |
| 136 | + handler.setLevel(logging.DEBUG) |
| 137 | + exit_code, stdout, stderr = get_main_output( |
| 138 | + ["--validate", get_data("tests/wf/2240-basecommand-space.cwl")], |
| 139 | + logger_handler=handler, |
| 140 | + ) |
| 141 | + custom_log_text = re.sub(r"\s\s+", " ", custom_log.getvalue()) |
| 142 | + assert exit_code == 0 |
| 143 | + assert "is valid CWL" in stdout |
| 144 | + assert "'baseCommand' is a single string containing whitespace" in custom_log_text |
| 145 | + assert "'tar xf'" in custom_log_text |
| 146 | + assert "['tar', 'xf']" in custom_log_text |
| 147 | + |
| 148 | + |
| 149 | +@pytest.mark.parametrize( |
| 150 | + "cwl_file", |
| 151 | + ["tests/wf/2240-basecommand-list.cwl", "tests/CometAdapter.cwl"], |
| 152 | +) |
| 153 | +def test_validate_no_basecommand_space_warning(cwl_file: str) -> None: |
| 154 | + """A list-form (or absent) 'baseCommand' does not trigger the whitespace warning.""" |
| 155 | + custom_log = io.StringIO() |
| 156 | + handler = logging.StreamHandler(custom_log) |
| 157 | + handler.setLevel(logging.DEBUG) |
| 158 | + exit_code, _, _ = get_main_output( |
| 159 | + ["--validate", get_data(cwl_file)], |
| 160 | + logger_handler=handler, |
| 161 | + ) |
| 162 | + assert exit_code == 0 |
| 163 | + assert "single string containing whitespace" not in custom_log.getvalue() |
0 commit comments