From 3e128934b7bfd13ac3e2f4a47255dab2e1b634c8 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Mon, 23 May 2022 21:28:54 +0000 Subject: [PATCH 1/5] Add deprecation message --- cwltest/tests/test_categories.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cwltest/tests/test_categories.py b/cwltest/tests/test_categories.py index 77e8711..5d56ca2 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. It will become an error since 2023/1/1.{n}" + "The `id` field is missing. It will become an error since 2023/1/1.{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. It will become an error since 2023/1/1.{n}" "Test [1/1] Optional test that is unsupported{n}{n}" "0 tests passed, 1 unsupported " "features{n}".format(n=n) From ea0d21400771b041538605e0830565138997e3ce Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Mon, 23 May 2022 21:40:44 +0000 Subject: [PATCH 2/5] Add missing `__init__.py` --- cwltest/__init__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cwltest/__init__.py b/cwltest/__init__.py index f89f413..1cb26ee 100755 --- a/cwltest/__init__.py +++ b/cwltest/__init__.py @@ -470,9 +470,21 @@ def main(): # type: () -> int for t in tests: if t.get("label"): + _logger.warning( + "The `label` field is deprecated. Use `id` field instead. It will become an error since 2023/1/1." + ) 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. It will become an error since 2023/1/1." + ) + else: + _logger.warning( + "The `id` field is missing. It will become an error since 2023/1/1." + ) if args.show_tags: alltags = set() # type: Set[str] From 9afd6d3ddb7b2832989fffb2277a096301c42fc1 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Mon, 23 May 2022 21:47:34 +0000 Subject: [PATCH 3/5] Fix style --- cwltest/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cwltest/__init__.py b/cwltest/__init__.py index 1cb26ee..91e1332 100755 --- a/cwltest/__init__.py +++ b/cwltest/__init__.py @@ -471,7 +471,8 @@ def main(): # type: () -> int for t in tests: if t.get("label"): _logger.warning( - "The `label` field is deprecated. Use `id` field instead. It will become an error since 2023/1/1." + "The `label` field is deprecated. Use `id` field instead. " + "It will become an error since 2023/1/1." ) t["short_name"] = t["label"] elif t.get("id"): @@ -479,7 +480,8 @@ def main(): # type: () -> int t["short_name"] = shortname(t["id"]) else: _logger.warning( - "The `id` field with integer is deprecated. Use string identifier instead. It will become an error since 2023/1/1." + "The `id` field with integer is deprecated. Use string identifier instead. " + "It will become an error since 2023/1/1." ) else: _logger.warning( From 8aa79f989d7c748340fb6532d944a1f65e6fee25 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Mon, 30 May 2022 11:15:04 +0000 Subject: [PATCH 4/5] Remove deadline --- cwltest/__init__.py | 12 +++--------- cwltest/tests/test_categories.py | 6 +++--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cwltest/__init__.py b/cwltest/__init__.py index 91e1332..5a63b77 100755 --- a/cwltest/__init__.py +++ b/cwltest/__init__.py @@ -470,23 +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. " - "It will become an error since 2023/1/1." - ) + _logger.warning("The `label` field is deprecated. Use `id` field instead.") t["short_name"] = t["label"] 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. " - "It will become an error since 2023/1/1." + "The `id` field with integer is deprecated. Use string identifier instead." ) else: - _logger.warning( - "The `id` field is missing. It will become an error since 2023/1/1." - ) + _logger.warning("The `id` field is missing.") if args.show_tags: alltags = set() # type: Set[str] diff --git a/cwltest/tests/test_categories.py b/cwltest/tests/test_categories.py index 5d56ca2..9da4e30 100644 --- a/cwltest/tests/test_categories.py +++ b/cwltest/tests/test_categories.py @@ -31,8 +31,8 @@ def test_unsupported_with_required_tests(): else: q = "" assert ( - "The `id` field is missing. It will become an error since 2023/1/1.{n}" - "The `id` field is missing. It will become an error since 2023/1/1.{n}" + "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}" @@ -59,7 +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. It will become an error since 2023/1/1.{n}" + "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) From 8456ed754ee096b994fd64da5ead5390874f148f Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Mon, 30 May 2022 14:12:41 +0000 Subject: [PATCH 5/5] Add tests --- cwltest/tests/test-data/integer-id.yml | 5 +++++ cwltest/tests/test_integer_id.py | 19 +++++++++++++++++++ cwltest/tests/test_multi_lined_doc.py | 1 + 3 files changed, 25 insertions(+) create mode 100644 cwltest/tests/test-data/integer-id.yml create mode 100644 cwltest/tests/test_integer_id.py 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_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