|
1 | 1 | from pathlib import Path
|
2 | 2 |
|
3 | 3 | import pytest
|
| 4 | +import logging |
4 | 5 |
|
5 | 6 | from cwltool.context import LoadingContext, RuntimeContext
|
6 | 7 | from cwltool.errors import WorkflowException
|
7 | 8 | from cwltool.load_tool import load_tool
|
8 | 9 | from cwltool.process import use_custom_schema, use_standard_schema
|
9 | 10 | from cwltool.update import INTERNAL_VERSION
|
10 | 11 | from cwltool.utils import CWLObjectType
|
| 12 | +from cwltool.loghandler import _logger, configure_logging |
11 | 13 |
|
12 | 14 | from .util import get_data
|
13 | 15 |
|
| 16 | +configure_logging(_logger.handlers[-1], False, True, True, True) |
| 17 | +_logger.setLevel(logging.DEBUG) |
| 18 | + |
14 | 19 |
|
15 | 20 | def test_check_version() -> None:
|
16 | 21 | """
|
@@ -96,5 +101,31 @@ def test_load_graph_fragment_from_packed() -> None:
|
96 | 101 | assert tool.tool["requirements"] == [
|
97 | 102 | {"class": "LoadListingRequirement", "loadListing": "no_listing"}
|
98 | 103 | ]
|
| 104 | + |
| 105 | + # This tests an additional, related bug, in which the updater |
| 106 | + # updates only one fragment of the document, but would update |
| 107 | + # the metadata dict in-place. This had the effect of marking |
| 108 | + # the original document as updated. On a subsequent load, it |
| 109 | + # would get the original un-updated document, which mistakenly |
| 110 | + # had the version modified in place, and validate it with the |
| 111 | + # newer schema instead of the original one. |
| 112 | + # |
| 113 | + # The specific case where this failed was |
| 114 | + # cwltool:LoadListingRequirement which is only recognized for |
| 115 | + # v1.0 documents, newer documents are supposed to be |
| 116 | + # auto-updated to the spec LoadListingRequirement, so it is |
| 117 | + # dropped from the schema. However if we try to validate a |
| 118 | + # v1.0 document with a v1.2 schema, it will throw an error the |
| 119 | + # cwltool:LoadListingRequirement extension. |
| 120 | + # |
| 121 | + # This was solved by making a shallow copy of the metadata |
| 122 | + # dict to ensure that the updater did not modify the original |
| 123 | + # document. |
| 124 | + uri2 = ( |
| 125 | + Path(get_data("tests/wf/packed-with-loadlisting.cwl")).as_uri() |
| 126 | + + "#16169-step.cwl" |
| 127 | + ) |
| 128 | + tool2 = load_tool(uri2, loadingContext) |
| 129 | + |
99 | 130 | finally:
|
100 | 131 | use_standard_schema("v1.0")
|
0 commit comments