Skip to content

Commit

Permalink
Ensure that a :suite.rc is added to the template language when crea…
Browse files Browse the repository at this point in the history
…ting defines.
  • Loading branch information
wxtim committed Aug 22, 2023
1 parent 6442245 commit fd2d3b0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
5 changes: 2 additions & 3 deletions cylc/rose/stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ def process(self):
if not self.opts.stem_sources:
self.opts.stem_sources = ['.']
self.opts.project = []

for i, url in enumerate(self.opts.stem_sources):
project, url, base, rev, mirror = self._ascertain_project(url)
self.opts.stem_sources[i] = url
Expand All @@ -453,7 +452,7 @@ def process(self):
# Get the name of the template section to be used:
template_type = get_rose_vars(
Path(url) / "rose-stem")["templating_detected"]
self.template_section = f'[{template_type}]'
self.template_section = f'[{template_type}:suite.rc]'

# Versions of variables with hostname prepended for working copies
url_host = self._prepend_localhost(url)
Expand Down Expand Up @@ -523,7 +522,7 @@ def process(self):

def get_source_opt_from_args(opts, args):
"""Convert sourcedir given as arg or implied by no arg to
opts.workflow_conf_dir.
opts.workflow_conf_dir.k
Possible outcomes:
No args given:
Expand Down
31 changes: 30 additions & 1 deletion tests/unit/test_rose_stem_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
from types import SimpleNamespace

from cylc.rose.stem import (
_get_rose_stem_opts,
ProjectNotFoundException,
RoseStemVersionException,
RoseSuiteConfNotFoundException,
StemRunner,
get_source_opt_from_args
get_source_opt_from_args,
)

from metomi.rose.reporter import Reporter
Expand Down Expand Up @@ -291,3 +292,31 @@ def test__deduce_mirror():
}
project = 'someproject'
StemRunner._deduce_mirror(source_dict, project)


def test_process_template_engine_set_correctly(monkeypatch):
"""Defines are correctly assigned a [<template language>:suite.rc]
section.
https://github.com/cylc/cylc-rose/issues/246
"""
# Mimic expected result from get_rose_vars method:
monkeypatch.setattr(
'cylc.rose.stem.get_rose_vars',
lambda _: {'templating_detected': 'empy'}
)
monkeypatch.setattr(
'sys.argv',
['foo', 'bar']
)

# We are not interested in these checks, just in the defines
# created by the process method.
stemrunner = StemRunner(_get_rose_stem_opts()[1])
stemrunner._ascertain_project = lambda _: ['', '', '', '', '']
stemrunner._this_suite = lambda: '.'
stemrunner._check_suite_version = lambda _: '1'
stemrunner.process()

for define in stemrunner.opts.defines:
assert define.startswith('[empy:suite.rc]')

0 comments on commit fd2d3b0

Please sign in to comment.