|
| 1 | +"""Test for Requirements and Hints in cwltool.""" |
| 2 | +import json |
| 3 | +from io import StringIO |
| 4 | + |
| 5 | +from cwltool.main import main |
| 6 | +from .util import get_data |
| 7 | + |
| 8 | + |
| 9 | +def test_workflow_reqs_are_evaluated_eagerly_default_args() -> None: |
| 10 | + """Test that a Workflow process will evaluate the requirements eagerly. |
| 11 | + Uses the default input values. |
| 12 | +
|
| 13 | + This means that workflow steps, such as Expression and Command Line Tools |
| 14 | + can both use resources without re-evaluating expressions. This is useful |
| 15 | + when you have an expression that, for instance, dynamically decides |
| 16 | + how many threads/cpus to use. |
| 17 | +
|
| 18 | + Issue: https://github.com/common-workflow-language/cwltool/issues/1330 |
| 19 | + """ |
| 20 | + stream = StringIO() |
| 21 | + |
| 22 | + assert ( |
| 23 | + main( |
| 24 | + [get_data("tests/wf/1330.cwl")], |
| 25 | + stdout=stream, |
| 26 | + ) |
| 27 | + == 0 |
| 28 | + ) |
| 29 | + |
| 30 | + out = json.loads(stream.getvalue()) |
| 31 | + assert out["out"] == "4\n" |
| 32 | + |
| 33 | + |
| 34 | +def test_workflow_reqs_are_evaluated_eagerly_provided_inputs() -> None: |
| 35 | + """Test that a Workflow process will evaluate the requirements eagerly. |
| 36 | + Passes inputs via a job file. |
| 37 | +
|
| 38 | + This means that workflow steps, such as Expression and Command Line Tools |
| 39 | + can both use resources without re-evaluating expressions. This is useful |
| 40 | + when you have an expression that, for instance, dynamically decides |
| 41 | + how many threads/cpus to use. |
| 42 | +
|
| 43 | + Issue: https://github.com/common-workflow-language/cwltool/issues/1330 |
| 44 | + """ |
| 45 | + stream = StringIO() |
| 46 | + |
| 47 | + assert ( |
| 48 | + main( |
| 49 | + [get_data("tests/wf/1330.cwl"), get_data("tests/wf/1330.json")], |
| 50 | + stdout=stream, |
| 51 | + ) |
| 52 | + == 0 |
| 53 | + ) |
| 54 | + |
| 55 | + out = json.loads(stream.getvalue()) |
| 56 | + assert out["out"] == "3\n" |
0 commit comments