Skip to content

Commit f6dc488

Browse files
authored
Merge pull request #398 from wxtim/397.fix.quote_ROSE_ORIG_HOST
ROSE_ORIG_HOST values are now correctly quoted in rose-suite-cylc-ins…
2 parents 4908f40 + b9c57c7 commit f6dc488

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

changes.d/398.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ROSE_ORIG_HOST values are now correctly quoted in rose-suite-cylc-install

cylc/rose/utilities.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,11 @@ def record_cylc_install_options(
938938
rose_orig_host = get_host()
939939
for section in list(SECTIONS) + ['env']:
940940
if section in cli_config:
941-
cli_config[section].set(['ROSE_ORIG_HOST'], rose_orig_host)
941+
cli_config[section].set(
942+
['ROSE_ORIG_HOST'],
943+
f'"{rose_orig_host}"'
944+
if section in SECTIONS else rose_orig_host
945+
)
942946
cli_config[section]['ROSE_ORIG_HOST'].comments = [
943947
ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING
944948
]

tests/functional/test_post_install.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_rose_fileinstall_uses_rose_template_vars(tmp_path):
112112
'opts=\n[env]\nFOO=1'
113113
f'\n[template variables]\nX=Y\n'
114114
f'#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n'
115-
f'ROSE_ORIG_HOST={HOST}\n'
115+
f'ROSE_ORIG_HOST="{HOST}"\n'
116116
f'\n[env]\n'
117117
f'#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n'
118118
f'ROSE_ORIG_HOST={HOST}\n'
@@ -139,16 +139,16 @@ def test_rose_fileinstall_uses_rose_template_vars(tmp_path):
139139
'test/opt/rose-suite-bar.conf': '',
140140
'test/opt/rose-suite-baz.conf': '',
141141
'test/opt/rose-suite-cylc-install.conf': (
142-
'!opts=bar\n[env]\nBAR=1\nROSE_ORIG_HOST=abc123\n'
143-
'\n[template variables]\nROSE_ORIG_HOST=abc123\n'
142+
'!opts=bar\n[env]\nBAR=1\nROSE_ORIG_HOST="abc123"\n'
143+
'\n[template variables]\nROSE_ORIG_HOST="abc123"\n'
144144
),
145145
'ref/opt/rose-suite-cylc-install.conf':
146146
f'!opts=bar baz\n[env]\nBAR=2\n'
147147
f'#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n'
148148
f'ROSE_ORIG_HOST={HOST}\n'
149149
f'\n[template variables]\n'
150150
f'#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n'
151-
f'ROSE_ORIG_HOST={HOST}\n',
151+
f'ROSE_ORIG_HOST="{HOST}"\n',
152152
'ref/rose-suite.conf': '!opts=foo bar baz (cylc-install)',
153153
'ref/opt/rose-suite-foo.conf': '',
154154
'ref/opt/rose-suite-bar.conf': '',
@@ -177,7 +177,7 @@ def test_rose_fileinstall_uses_rose_template_vars(tmp_path):
177177
f'ROSE_ORIG_HOST={HOST}\n'
178178
f'\n[template variables]\n'
179179
f'#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n'
180-
f'ROSE_ORIG_HOST={HOST}\n'
180+
f'ROSE_ORIG_HOST="{HOST}"\n'
181181
),
182182
'ref/rose-suite.conf': '!opts=a b c (cylc-install)',
183183
'ref/opt/rose-suite-a.conf': '',
@@ -207,7 +207,7 @@ def test_rose_fileinstall_uses_rose_template_vars(tmp_path):
207207
f'ROSE_ORIG_HOST={HOST}\n'
208208
f'[jinja2:suite.rc]\na="b"\n'
209209
f'#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n'
210-
f'ROSE_ORIG_HOST={HOST}\n'
210+
f'ROSE_ORIG_HOST="{HOST}"\n'
211211
),
212212
'ref/rose-suite.conf': (
213213
'!opts=foo bar (cylc-install)\n[jinja2:suite.rc]\ny="base"'

tests/functional/test_reinstall.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def test_cylc_validate(fixture_provide_flow, cylc_validate_cli):
126126
'# This file records CLI Options.{version_info}\n'
127127
'!opts=b c\n'
128128
f'\n[env]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
129-
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
129+
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST="{HOST}"\n'
130130
)
131131
)
132132
]
@@ -152,7 +152,7 @@ def test_cylc_install_files(fixture_install_flow, file_, expect, version_info):
152152
'# This file records CLI Options.{version_info}\n'
153153
'!opts=b c d\n'
154154
f'\n[env]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
155-
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
155+
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST="{HOST}"\n'
156156
)
157157
)
158158
]
@@ -195,7 +195,7 @@ async def test_cylc_reinstall_files(
195195
'# This file records CLI Options.{version_info}\n'
196196
'!opts=b c d\n'
197197
f'\n[env]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
198-
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
198+
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST="{HOST}"\n'
199199
)
200200
)
201201
]

tests/functional/test_reinstall_clean.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ async def fixture_install_flow(
110110
'[env]\n'
111111
f'FOO=1\n#{ROHIOS}\n'
112112
f'ROSE_ORIG_HOST={HOST}\n'
113-
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
113+
f'\n[template variables]\n#{ROHIOS}'
114+
f'\nROSE_ORIG_HOST="{HOST}"\n'
114115
)
115116
),
116117
]
@@ -131,7 +132,8 @@ def test_cylc_install_files(fixture_install_flow, file_, expect, version_info):
131132
'[env]\n'
132133
f'BAR=2\n#{ROHIOS}\n'
133134
f'ROSE_ORIG_HOST={HOST}\n'
134-
f'\n[template variables]\n#{ROHIOS}\nROSE_ORIG_HOST={HOST}\n'
135+
f'\n[template variables]\n#{ROHIOS}'
136+
f'\nROSE_ORIG_HOST="{HOST}"\n'
135137
)
136138
)
137139
]

tests/unit/test_fileinstall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ def test_rose_fileinstall_rose_suite_cylc_install_conf(
109109
"[env]\n"
110110
"FOO=42\n"
111111
f"#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n"
112-
f"ROSE_ORIG_HOST={host}\n\n"
112+
f'ROSE_ORIG_HOST={host}\n\n'
113113
"[jinja2:suite.rc]\n"
114114
"BAR=84\n"
115115
"CORNETTO=120\n"
116116
"FLAKE=99\n"
117117
f"#{ROSE_ORIG_HOST_INSTALLED_OVERRIDE_STRING}\n"
118-
f"ROSE_ORIG_HOST={host}\n"
118+
f'ROSE_ORIG_HOST="{host}"\n'
119119
)

0 commit comments

Comments
 (0)