diff --git a/cwltest/__init__.py b/cwltest/__init__.py index f89f413..5a63b77 100755 --- a/cwltest/__init__.py +++ b/cwltest/__init__.py @@ -470,9 +470,17 @@ def main(): # type: () -> int for t in tests: if t.get("label"): + _logger.warning("The `label` field is deprecated. Use `id` field instead.") t["short_name"] = t["label"] - elif t.get("id") and isinstance(t.get("id"), str): - t["short_name"] = shortname(t["id"]) + elif t.get("id"): + if isinstance(t.get("id"), str): + t["short_name"] = shortname(t["id"]) + else: + _logger.warning( + "The `id` field with integer is deprecated. Use string identifier instead." + ) + else: + _logger.warning("The `id` field is missing.") if args.show_tags: alltags = set() # type: Set[str] diff --git a/cwltest/tests/test-data/integer-id.yml b/cwltest/tests/test-data/integer-id.yml new file mode 100644 index 0000000..8223cef --- /dev/null +++ b/cwltest/tests/test-data/integer-id.yml @@ -0,0 +1,5 @@ +- job: v1.0/cat1-job.json + output: {} + tool: return-0.cwl + doc: Test with an integer id + id: 1 diff --git a/cwltest/tests/test_categories.py b/cwltest/tests/test_categories.py index 77e8711..9da4e30 100644 --- a/cwltest/tests/test_categories.py +++ b/cwltest/tests/test_categories.py @@ -31,6 +31,8 @@ def test_unsupported_with_required_tests(): else: q = "" assert ( + "The `id` field is missing.{n}" + "The `id` field is missing.{n}" "Test [1/2] Required test that is unsupported (without tags){n}" "{n}" "Test 1 failed: mock-cwl-runner --quiet return-unsupported.cwl {q}v1.0{p}cat-job.json{q}{n}" @@ -57,6 +59,7 @@ def test_unsupported_with_optional_tests(): error_code, stdout, stderr = run_with_mock_cwl_runner(args) assert error_code == 0 assert ( + "The `id` field is missing.{n}" "Test [1/1] Optional test that is unsupported{n}{n}" "0 tests passed, 1 unsupported " "features{n}".format(n=n) diff --git a/cwltest/tests/test_integer_id.py b/cwltest/tests/test_integer_id.py new file mode 100644 index 0000000..7993111 --- /dev/null +++ b/cwltest/tests/test_integer_id.py @@ -0,0 +1,19 @@ +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_warning_with_integer_id(): + args = [ + "--test", + get_data("tests/test-data/integer-id.yml"), + "-l", + ] + error_code, stdout, stderr = run_with_mock_cwl_runner(args) + assert ( + "The `id` field with integer is deprecated. Use string identifier instead." + in stderr + ) diff --git a/cwltest/tests/test_multi_lined_doc.py b/cwltest/tests/test_multi_lined_doc.py index 1fa1501..9b6f4b3 100644 --- a/cwltest/tests/test_multi_lined_doc.py +++ b/cwltest/tests/test_multi_lined_doc.py @@ -9,6 +9,7 @@ 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 "The `label` field is deprecated. Use `id` field instead." in stderr assert f"Test [1/2] opt-error: Test with label{n}" in stderr assert f"Test [2/2] Test without label{n}" in stderr