@@ -219,6 +219,27 @@ def test_SetProgramOptionsCMake_gen_option_list_bash_expandvars(self):
219219 option_list_actual = parser .gen_option_list (section , generator = "bash" )
220220 pprint (option_list_actual , width = 200 )
221221
222+ self .assertListEqual (option_list_expect , option_list_actual )
223+ print ("-----[ TEST END ]------------------------------------------" )
224+ print ("OK" )
225+
226+ print ("-----[ TEST BEGIN ]----------------------------------------" )
227+ section = "TEST_VAR_EXPANSION_UPDATE_04"
228+ print ("Section : {}" .format (section ))
229+
230+ self ._execute_parser (parser , section )
231+
232+ print ("-" * 40 )
233+ print ("Option List" )
234+ print ("-" * 40 )
235+ option_list_expect = [
236+ 'cmake' ,
237+ '-DCMAKE_CXX_FLAGS:STRING="${LDFLAGS} -foo"' ,
238+ ]
239+
240+ option_list_actual = parser .gen_option_list (section , generator = "bash" )
241+ pprint (option_list_actual , width = 200 )
242+
222243 self .assertListEqual (option_list_expect , option_list_actual )
223244 print ("-----[ TEST END ]------------------------------------------" )
224245 print ("OK" )
@@ -338,7 +359,7 @@ def test_SetProgramOptionsCMake_gen_option_list_cmake_fragment_expandvars(self):
338359
339360 option_list_expect = [
340361 'set(CMAKE_CXX_FLAGS "$ENV{LDFLAGS} -foo" CACHE STRING "from .ini configuration")' ,
341- 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -bar" CACHE STRING "from .ini configuration")' ,
362+ 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -bar" CACHE STRING "from .ini configuration" FORCE )' ,
342363 'set(CMAKE_F90_FLAGS "${CMAKE_F90_FLAGS} -baz" CACHE STRING "from .ini configuration")'
343364 ]
344365
@@ -350,8 +371,40 @@ def test_SetProgramOptionsCMake_gen_option_list_cmake_fragment_expandvars(self):
350371 self .assertListEqual (option_list_expect , option_list_actual )
351372
352373 print ("-----[ TEST END ]------------------------------------------" )
374+ print ("OK" )
353375
376+ # The following TEST_VAR_EXPANSION_UPDATE_04 does not increase coverage
377+ # but is here to illustrate the correctness issue reported in
378+ # TRILFRAME-120. To compare the option_list_expect below to that
379+ # of the option_list_expect for the bash generator, see the
380+ # TEST_VAR_EXPANSION_UPDATE_04 test above in
381+ # test_SetProgramOptionsCMake_gen_option_list_bash_expandvars.
382+ print ("-----[ TEST BEGIN ]----------------------------------------" )
383+ section = "TEST_VAR_EXPANSION_UPDATE_04"
384+ print ("Section : {}" .format (section ))
385+
386+ # parse a section
387+ self ._execute_parser (parser , section )
388+
389+ parser .gen_option_list (section , generator = "cmake_fragment" )
390+
391+ option_list_expect = [
392+ # Only the first set with "-foo" sticks in the cmake cache.
393+ # If the second set with "-foobar" used FORCE, it would stick.
394+ 'set(CMAKE_CXX_FLAGS "$ENV{LDFLAGS} -foo" CACHE STRING "from .ini configuration")' ,
395+ 'set(CMAKE_CXX_FLAGS "$ENV{LDFLAGS} -foobar" CACHE STRING "from .ini configuration")' ,
396+ ]
397+
398+ option_list_actual = parser .gen_option_list (section , generator = "cmake_fragment" )
399+
400+ print ("Expected Output:\n {}\n " .format ("\n " .join (option_list_expect )))
401+ print ("Actual Output:\n {}\n " .format ("\n " .join (option_list_actual )))
402+
403+ self .assertListEqual (option_list_expect , option_list_actual )
404+
405+ print ("-----[ TEST END ]------------------------------------------" )
354406 print ("OK" )
407+
355408 return 0
356409
357410 def test_SetProgramOptionsCMake_param_order_01 (self ):
0 commit comments