Skip to content

Commit 5b75ff1

Browse files
committed
Enable testing of cwl-inputs-schema-gen
1 parent 062da72 commit 5b75ff1

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

cwltest/argparser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ def arg_parser() -> argparse.ArgumentParser:
110110
help="Create JSON badges, one for each tag (plus a computed 'all' tag) "
111111
" and store them in this directory.",
112112
)
113+
parser.add_argument(
114+
"--parse-inputs-only",
115+
action="store_true",
116+
help="Only run the supplied tool, don't compare the output. Tests "
117+
"tagged with 'inputs_should_parse' will also be expected to pass, "
118+
"even if marked with 'should_fail: True'. Primirily intended to test "
119+
"cwl-inputs-schema-gen.",
120+
)
113121

114122
try:
115123
ver = version("cwltest")

cwltest/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def _run_test(
7474
timeout=args.timeout,
7575
verbose=args.verbose,
7676
runner_quiet=not args.junit_verbose,
77+
parse_inputs_only=args.parse_inputs_only,
7778
)
7879
return utils.run_test_plain(config, test, test_number)
7980

cwltest/utils.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(
4747
timeout: Optional[int] = None,
4848
verbose: Optional[bool] = None,
4949
runner_quiet: Optional[bool] = None,
50+
parse_inputs_only: Optional[bool] = None,
5051
) -> None:
5152
"""Initialize test configuration."""
5253
self.basedir: str = basedir or os.getcwd()
@@ -63,6 +64,7 @@ def __init__(
6364
self.timeout: Optional[int] = timeout
6465
self.verbose: bool = verbose or False
6566
self.runner_quiet: bool = runner_quiet or True
67+
self.parse_inputs_only: bool = parse_inputs_only or False
6668

6769

6870
class CWLTestReport:
@@ -468,7 +470,7 @@ def run_test_plain(
468470
raise subprocess.CalledProcessError(return_code, " ".join(test_command))
469471

470472
logger.debug('outstr: "%s".', outstr)
471-
out = json.loads(outstr) if outstr else {}
473+
out = json.loads(outstr) if not config.parse_inputs_only and outstr else {}
472474
except subprocess.CalledProcessError as err:
473475
if err.returncode == UNSUPPORTED_FEATURE and REQUIRED not in test.get(
474476
"tags", ["required"]
@@ -593,7 +595,9 @@ def run_test_plain(
593595

594596
fail_message = ""
595597

596-
if test.get("should_fail", False):
598+
if test.get("should_fail", False) and not (
599+
config.parse_inputs_only and "inputs_should_parse" in test.get("tags", [])
600+
):
597601
logger.warning(
598602
"""Test %s failed: %s""",
599603
number,
@@ -612,17 +616,18 @@ def run_test_plain(
612616
joburi,
613617
)
614618

615-
try:
616-
compare(test.get("output"), out)
617-
except CompareFail as ex:
618-
logger.warning(
619-
"""Test %s failed: %s""",
620-
number,
621-
shlex.join(test_command),
622-
)
623-
logger.warning(test.get("doc", "").replace("\n", " ").strip())
624-
logger.warning("Compare failure %s", ex)
625-
fail_message = str(ex)
619+
if not config.parse_inputs_only:
620+
try:
621+
compare(test.get("output"), out)
622+
except CompareFail as ex:
623+
logger.warning(
624+
"""Test %s failed: %s""",
625+
number,
626+
shlex.join(test_command),
627+
)
628+
logger.warning(test.get("doc", "").replace("\n", " ").strip())
629+
logger.warning("Compare failure %s", ex)
630+
fail_message = str(ex)
626631

627632
if config.outdir:
628633
shutil.rmtree(config.outdir, True)

0 commit comments

Comments
 (0)