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

Commit 90005cd

Browse files
author
William McLendon
committed
Merge branch 'add_remove_test_for_cmake' into 'master'
TEST: Validate that `opt-remove` works for cmake See merge request trilinos-devops-consolidation/code/SetProgramOptions!15
2 parents 511e423 + 5060f18 commit 90005cd

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
#### Fixed
3434
#### Security
3535
#### Internal
36+
- Add test to verify that `opt-remove` also works to remove variables added
37+
by `opt-set-cmake-var`.
3638
- Changed `VariableFieldData` so that it won't use `dataclasses` to keep our
3739
Python compatibilty to 3.6 (`dataclasses` requires 3.7 and higher).
3840
#### Todo (for Unreleased)

src/setprogramoptions/unittests/files_ini/config_test_setprogramoptions.ini

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ opt-set-cmake-var CMAKE_F90_FLAGS STRING: "${CMAKE_F90_FLAGS|CMAKE} -baz"
156156
use TEST_VAR_EXPANSION_UPDATE_01
157157
opt-set-cmake-var CMAKE_CXX_FLAGS STRING: "${CMAKE_CXX_FLAGS|CMAKE} -bif"
158158

159+
159160
[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"
161+
opt-set-cmake-var FOO STRING: foo::bar::baz<Type>
162+
opt-set-cmake-var BAR STRING: "600"
163+
164+
165+
[TEST_CMAKE_VAR_REMOVE]
166+
# Test whether or not opt-remove works for a cmake var
167+
opt-set-cmake-var FOO_TEST: "FOO"
168+
opt-set-cmake-var BAR_TEST: "BAR"
169+
opt-set-cmake-var FOO : "BAZ"
170+
# this should remove `FOO_TEST` from the option list so we will only
171+
# have `BAR_TEST` and `FOO` left.
172+
opt-remove FOO_TEST

src/setprogramoptions/unittests/test_SetProgramOptionsCMake.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ def test_SetProgramOptionsCMake_test_STRING_value_surrounded_by_double_quotes(se
446446
print("Section : {}".format(section))
447447

448448
option_list_expect = [
449-
'-DPanzer_FADTYPE:STRING="Sacado::Fad::DFad<RealType>"',
450-
'-DDART_TESTING_TIMEOUT:STRING="600"',
449+
'-DFOO:STRING="foo::bar::baz<Type>"',
450+
'-DBAR:STRING="600"'
451451
]
452452
option_list_actual = parser.gen_option_list(section, generator="bash")
453453

@@ -467,6 +467,32 @@ def test_SetProgramOptionsCMake_test_STRING_value_surrounded_by_double_quotes(se
467467
print("OK")
468468
return 0
469469

470+
def test_SetProgramOptionsCMake_opt_remove(self):
471+
"""
472+
This test validates that `opt-remove` will correctly remove a CMake var
473+
that was created using `opt-set-cmake-var`
474+
"""
475+
parser = self._create_standard_parser()
476+
477+
print("-----[ TEST BEGIN ]----------------------------------------")
478+
section = "TEST_CMAKE_VAR_REMOVE"
479+
print("Section : {}".format(section))
480+
option_list_bash_actual = parser.gen_option_list('TEST_CMAKE_VAR_REMOVE', 'bash')
481+
option_list_bash_expect = [ '-DBAR_TEST=BAR', '-DFOO=BAZ' ]
482+
self.assertListEqual(option_list_bash_expect, option_list_bash_actual)
483+
print("-----[ TEST END ]------------------------------------------")
484+
485+
print("-----[ TEST BEGIN ]----------------------------------------")
486+
section = "TEST_CMAKE_VAR_REMOVE"
487+
print("Section : {}".format(section))
488+
option_list_cmake_fragment_actual = parser.gen_option_list('TEST_CMAKE_VAR_REMOVE', 'cmake_fragment')
489+
option_list_cmake_fragment_expect = [ 'set(BAR_TEST BAR)', 'set(FOO BAZ)' ]
490+
self.assertListEqual(option_list_cmake_fragment_expect, option_list_cmake_fragment_actual)
491+
print("-----[ TEST END ]------------------------------------------")
492+
493+
print("OK")
494+
return 0
495+
470496
def _create_standard_parser(
471497
self, filename=DEFAULT_VALUE(), debug_level=5, ece_level=4, ece_compact=False
472498
):

0 commit comments

Comments
 (0)