15
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
17
import os
18
- import sys
19
18
from optparse import Values
20
19
from typing import (
21
20
TYPE_CHECKING , Any , Callable , Dict , List , Optional , Tuple , Type )
22
21
import pytest
23
22
import logging
23
+ from textwrap import dedent
24
24
from types import SimpleNamespace
25
25
from contextlib import suppress
26
26
47
47
48
48
from cylc .flow .cycling .iso8601 import ISO8601Point
49
49
50
+
51
+ param = pytest .param
52
+
53
+
50
54
if TYPE_CHECKING :
51
55
from pathlib import Path
52
56
Fixture = Any
@@ -1175,13 +1179,16 @@ def WorkflowConfig__assert_err_raised():
1175
1179
WorkflowConfig__assert_err_raised ()
1176
1180
1177
1181
1178
- def test_undefined_custom_output (tmp_flow_config : Callable ):
1182
+ @pytest .mark .parametrize (
1183
+ 'graph' , (('foo:x => bar' ), ('foo:x' ))
1184
+ )
1185
+ def test_undefined_custom_output (graph : str , tmp_flow_config : Callable ):
1179
1186
"""Test error on undefined custom output referenced in graph."""
1180
1187
id_ = 'custom_out1'
1181
- flow_file = tmp_flow_config (id_ , """
1188
+ flow_file = tmp_flow_config (id_ , f """
1182
1189
[scheduling]
1183
1190
[[graph]]
1184
- R1 = "foo:x => bar "
1191
+ R1 = "{ graph } "
1185
1192
[runtime]
1186
1193
[[foo, bar]]
1187
1194
""" )
@@ -1700,7 +1707,6 @@ def test_cylc_env_at_parsing(
1700
1707
1701
1708
def test_force_workflow_compat_mode (tmp_path ):
1702
1709
fpath = (tmp_path / 'flow.cylc' )
1703
- from textwrap import dedent
1704
1710
fpath .write_text (dedent ("""
1705
1711
[scheduler]
1706
1712
allow implicit tasks = true
@@ -1713,3 +1719,33 @@ def test_force_workflow_compat_mode(tmp_path):
1713
1719
WorkflowConfig ('foo' , str (fpath ), {})
1714
1720
# It succeeds with compat mode:
1715
1721
WorkflowConfig ('foo' , str (fpath ), {}, force_compat_mode = True )
1722
+
1723
+
1724
+ @pytest .mark .parametrize (
1725
+ 'registered_outputs, tasks_and_outputs, fails' ,
1726
+ (
1727
+ param ([], ['foo:x' ], True , id = 'output-unregistered' ),
1728
+ param ([], ['foo:x?' ], True , id = 'optional-output-unregistered' ),
1729
+ param ([], ['foo' ], False , id = 'no-modifier-unregistered' ),
1730
+ param (['x' ], ['foo:x' ], False , id = 'output-registered' ),
1731
+ param ([], ['foo:succeed' ], False , id = 'alt-default-ok' ),
1732
+ param ([], ['foo:failed' ], False , id = 'default-ok' ),
1733
+ )
1734
+ )
1735
+ def test_check_outputs (tmp_path , registered_outputs , tasks_and_outputs , fails ):
1736
+ (tmp_path / 'flow.cylc' ).write_text (dedent ("""
1737
+ [scheduler]
1738
+ allow implicit tasks = true
1739
+ [scheduling]
1740
+ [[graph]]
1741
+ R1 = foo
1742
+ """ ))
1743
+ cfg = WorkflowConfig ('' , tmp_path / 'flow.cylc' , '' )
1744
+ cfg .cfg ['runtime' ]['foo' ]['outputs' ] = registered_outputs
1745
+ if fails :
1746
+ with pytest .raises (
1747
+ WorkflowConfigError , match = 'Undefined custom output'
1748
+ ):
1749
+ cfg .check_terminal_outputs (tasks_and_outputs )
1750
+ else :
1751
+ assert cfg .check_terminal_outputs (tasks_and_outputs ) is None
0 commit comments