Skip to content

Commit 9dac068

Browse files
authored
Print doc field in one line (#136)
1 parent c2f9c45 commit 9dac068

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

cwltest/__init__.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,20 @@ def run_test(
127127
test_number,
128128
total_tests,
129129
test.get("short_name"),
130-
test.get("doc"),
130+
test.get("doc", "").replace("\n", " ").strip(),
131131
suffix,
132132
)
133133
)
134134
else:
135135
sys.stderr.write(
136136
"%sTest [%i/%i] %s%s\n"
137-
% (prefix, test_number, total_tests, test.get("doc"), suffix)
137+
% (
138+
prefix,
139+
test_number,
140+
total_tests,
141+
test.get("doc", "").replace("\n", " ").strip(),
142+
suffix,
143+
)
138144
)
139145
if verbose:
140146
sys.stderr.write(f"Running: {' '.join(test_command)}\n")
@@ -174,7 +180,7 @@ def run_test(
174180
test_number,
175181
" ".join([quote(tc) for tc in test_command]),
176182
)
177-
_logger.error(test.get("doc"))
183+
_logger.error(test.get("doc", "").replace("\n", " ").strip())
178184
if err.returncode == UNSUPPORTED_FEATURE:
179185
_logger.error("Does not support required feature")
180186
else:
@@ -203,7 +209,7 @@ def run_test(
203209
test_number,
204210
" ".join([quote(tc) for tc in test_command]),
205211
)
206-
_logger.error(test.get("doc"))
212+
_logger.error(test.get("doc", "").replace("\n", " ").strip())
207213
# Kill and re-communicate to get the logs and reap the child, as
208214
# instructed in the subprocess docs.
209215
if process:
@@ -229,7 +235,7 @@ def run_test(
229235
test_number,
230236
" ".join([quote(tc) for tc in test_command]),
231237
)
232-
_logger.warning(test.get("doc"))
238+
_logger.warning(test.get("doc", "").replace("\n", " ").strip())
233239
_logger.warning("Returned zero but it should be non-zero")
234240
return TestResult(1, outstr, outerr, duration, args.classname)
235241

@@ -241,7 +247,7 @@ def run_test(
241247
test_number,
242248
" ".join([quote(tc) for tc in test_command]),
243249
)
244-
_logger.warning(test.get("doc"))
250+
_logger.warning(test.get("doc", "").replace("\n", " ").strip())
245251
_logger.warning("Compare failure %s", ex)
246252
fail_message = str(ex)
247253

@@ -456,10 +462,15 @@ def main(): # type: () -> int
456462
for i, t in enumerate(tests):
457463
if t.get("short_name"):
458464
print(
459-
"[%i] %s: %s" % (i + 1, t["short_name"], t.get("doc", "").strip())
465+
"[%i] %s: %s"
466+
% (
467+
i + 1,
468+
t["short_name"],
469+
t.get("doc", "").replace("\n", " ").strip(),
470+
)
460471
)
461472
else:
462-
print("[%i] %s" % (i + 1, t.get("doc", "").strip()))
473+
print("[%i] %s" % (i + 1, t.get("doc", "").replace("\n", " ").strip()))
463474

464475
return 0
465476

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- job: v1.0/cat-job.json
2+
output: {}
3+
tool: return-0.cwl
4+
doc: |
5+
Test with
6+
label
7+
label: opt-error
8+
tags: [ js, init_work_dir ]
9+
- job: v1.0/cat-job.json
10+
output: {}
11+
tool: return-0.cwl
12+
doc: |
13+
Test without
14+
label
15+
tags: [ js, init_work_dir ]

cwltest/tests/test_multi_lined_doc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
from os import linesep as n
3+
from pathlib import Path
4+
5+
from .util import run_with_mock_cwl_runner, get_data
6+
import defusedxml.ElementTree as ET
7+
8+
9+
def test_run():
10+
args = ["--test", get_data("tests/test-data/multi-lined-doc.yml")]
11+
error_code, stdout, stderr = run_with_mock_cwl_runner(args)
12+
assert f"Test [1/2] opt-error: Test with label{n}" in stderr
13+
assert f"Test [2/2] Test without label{n}" in stderr
14+
15+
16+
def test_list():
17+
args = ["--test", get_data("tests/test-data/multi-lined-doc.yml"), "-l"]
18+
error_code, stdout, stderr = run_with_mock_cwl_runner(args)
19+
assert f"[1] opt-error: Test with label{n}" in stdout
20+
assert f"[2] Test without label{n}" in stdout

0 commit comments

Comments
 (0)