Skip to content

Commit

Permalink
Print doc field in one line (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-tan authored May 21, 2022
1 parent c2f9c45 commit 9dac068
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
27 changes: 19 additions & 8 deletions cwltest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,20 @@ def run_test(
test_number,
total_tests,
test.get("short_name"),
test.get("doc"),
test.get("doc", "").replace("\n", " ").strip(),
suffix,
)
)
else:
sys.stderr.write(
"%sTest [%i/%i] %s%s\n"
% (prefix, test_number, total_tests, test.get("doc"), suffix)
% (
prefix,
test_number,
total_tests,
test.get("doc", "").replace("\n", " ").strip(),
suffix,
)
)
if verbose:
sys.stderr.write(f"Running: {' '.join(test_command)}\n")
Expand Down Expand Up @@ -174,7 +180,7 @@ def run_test(
test_number,
" ".join([quote(tc) for tc in test_command]),
)
_logger.error(test.get("doc"))
_logger.error(test.get("doc", "").replace("\n", " ").strip())
if err.returncode == UNSUPPORTED_FEATURE:
_logger.error("Does not support required feature")
else:
Expand Down Expand Up @@ -203,7 +209,7 @@ def run_test(
test_number,
" ".join([quote(tc) for tc in test_command]),
)
_logger.error(test.get("doc"))
_logger.error(test.get("doc", "").replace("\n", " ").strip())
# Kill and re-communicate to get the logs and reap the child, as
# instructed in the subprocess docs.
if process:
Expand All @@ -229,7 +235,7 @@ def run_test(
test_number,
" ".join([quote(tc) for tc in test_command]),
)
_logger.warning(test.get("doc"))
_logger.warning(test.get("doc", "").replace("\n", " ").strip())
_logger.warning("Returned zero but it should be non-zero")
return TestResult(1, outstr, outerr, duration, args.classname)

Expand All @@ -241,7 +247,7 @@ def run_test(
test_number,
" ".join([quote(tc) for tc in test_command]),
)
_logger.warning(test.get("doc"))
_logger.warning(test.get("doc", "").replace("\n", " ").strip())
_logger.warning("Compare failure %s", ex)
fail_message = str(ex)

Expand Down Expand Up @@ -456,10 +462,15 @@ def main(): # type: () -> int
for i, t in enumerate(tests):
if t.get("short_name"):
print(
"[%i] %s: %s" % (i + 1, t["short_name"], t.get("doc", "").strip())
"[%i] %s: %s"
% (
i + 1,
t["short_name"],
t.get("doc", "").replace("\n", " ").strip(),
)
)
else:
print("[%i] %s" % (i + 1, t.get("doc", "").strip()))
print("[%i] %s" % (i + 1, t.get("doc", "").replace("\n", " ").strip()))

return 0

Expand Down
15 changes: 15 additions & 0 deletions cwltest/tests/test-data/multi-lined-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- job: v1.0/cat-job.json
output: {}
tool: return-0.cwl
doc: |
Test with
label
label: opt-error
tags: [ js, init_work_dir ]
- job: v1.0/cat-job.json
output: {}
tool: return-0.cwl
doc: |
Test without
label
tags: [ js, init_work_dir ]
20 changes: 20 additions & 0 deletions cwltest/tests/test_multi_lined_doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
from os import linesep as n
from pathlib import Path

from .util import run_with_mock_cwl_runner, get_data
import defusedxml.ElementTree as ET


def test_run():
args = ["--test", get_data("tests/test-data/multi-lined-doc.yml")]
error_code, stdout, stderr = run_with_mock_cwl_runner(args)
assert f"Test [1/2] opt-error: Test with label{n}" in stderr
assert f"Test [2/2] Test without label{n}" in stderr


def test_list():
args = ["--test", get_data("tests/test-data/multi-lined-doc.yml"), "-l"]
error_code, stdout, stderr = run_with_mock_cwl_runner(args)
assert f"[1] opt-error: Test with label{n}" in stdout
assert f"[2] Test without label{n}" in stdout

0 comments on commit 9dac068

Please sign in to comment.