Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 3ea678b

Browse files
committed
Merge branch '10-setprogramoptions-bash-string-output-should-be-surrounded-by-double-quotes' into 'master'
Resolve "SetProgramOptions bash STRING output should be surrounded by double quotes" Closes #10 See merge request trilinos-devops-consolidation/code/SetProgramOptions!11
2 parents 0d28c21 + 147bb1c commit 3ea678b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/setprogramoptions/SetProgramOptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ def _generic_program_option_handler_bash(self, params: list, value: str) -> str:
553553
"""
554554
output = "".join(params)
555555
if value is not None:
556+
# Make sure STRING flag values are surrounded by double quotes
557+
if "STRING" in output and not value.startswith('"') and not value.endswith('"'):
558+
value = f'"{value}"'
556559
output += "=" + value
557560
return output
558561

src/setprogramoptions/unittests/files_ini/config_test_setprogramoptions.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,7 @@ opt-set-cmake-var CMAKE_F90_FLAGS STRING: "${CMAKE_F90_FLAGS|CMAKE} -baz"
155155
[TEST_VAR_EXPANSION_UPDATE_03]
156156
use TEST_VAR_EXPANSION_UPDATE_01
157157
opt-set-cmake-var CMAKE_CXX_FLAGS STRING: "${CMAKE_CXX_FLAGS|CMAKE} -bif"
158+
159+
[TEST_STRING_DOUBLE_QUOTES]
160+
opt-set-cmake-var Panzer_FADTYPE STRING: Sacado::Fad::DFad<RealType>
161+
opt-set-cmake-var DART_TESTING_TIMEOUT STRING: "600"

src/setprogramoptions/unittests/test_SetProgramOptionsCMake.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,40 @@ def test_SetProgramOptionsCMake_param_order_02(self):
394394
print("OK")
395395
return
396396

397+
def test_SetProgramOptionsCMake_test_STRING_value_surrounded_by_double_quotes(self):
398+
"""
399+
Test STRING values are surrounded by double quotes.
400+
"""
401+
print("\n")
402+
print("Load file: {}".format(self._filename))
403+
parser = self._create_standard_parser()
404+
405+
print("-----[ TEST BEGIN ]----------------------------------------")
406+
section = "TEST_STRING_DOUBLE_QUOTES"
407+
print("Section : {}".format(section))
408+
409+
option_list_expect = [
410+
'-DPanzer_FADTYPE:STRING="Sacado::Fad::DFad<RealType>"',
411+
'-DDART_TESTING_TIMEOUT:STRING="600"',
412+
]
413+
option_list_actual = parser.gen_option_list(section, generator="bash")
414+
415+
print("-" * 40)
416+
print("Options List Expect")
417+
print("-" * 40)
418+
pprint(option_list_expect, width=120)
419+
print("")
420+
print("Options List Actual")
421+
print("-" * 40)
422+
pprint(option_list_actual, width=120)
423+
424+
self.assertEqual(option_list_expect, option_list_actual)
425+
426+
print("-----[ TEST END ]------------------------------------------")
427+
428+
print("OK")
429+
return 0
430+
397431
def _create_standard_parser(
398432
self, filename=DEFAULT_VALUE(), debug_level=5, ece_level=4, ece_compact=False
399433
):

0 commit comments

Comments
 (0)