@@ -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" )
@@ -315,8 +336,40 @@ def test_SetProgramOptionsCMake_gen_option_list_cmake_fragment_expandvars(self):
315336 self .assertListEqual (option_list_expect , option_list_actual )
316337
317338 print ("-----[ TEST END ]------------------------------------------" )
339+ print ("OK" )
318340
341+ # The following TEST_VAR_EXPANSION_UPDATE_04 does not increase coverage
342+ # but is here to illustrate the correctness issue reported in
343+ # TRILFRAME-120. To compare the option_list_expect below to that
344+ # of the option_list_expect for the bash generator, see the
345+ # TEST_VAR_EXPANSION_UPDATE_04 test above in
346+ # test_SetProgramOptionsCMake_gen_option_list_bash_expandvars.
347+ print ("-----[ TEST BEGIN ]----------------------------------------" )
348+ section = "TEST_VAR_EXPANSION_UPDATE_04"
349+ print ("Section : {}" .format (section ))
350+
351+ # parse a section
352+ self ._execute_parser (parser , section )
353+
354+ parser .gen_option_list (section , generator = "cmake_fragment" )
355+
356+ option_list_expect = [
357+ # Only the first set with "-foo" sticks in the cmake cache.
358+ # If the second set with "-foobar" used FORCE, it would stick.
359+ 'set(CMAKE_CXX_FLAGS "$ENV{LDFLAGS} -foo" CACHE STRING "from .ini configuration")' ,
360+ 'set(CMAKE_CXX_FLAGS "$ENV{LDFLAGS} -foobar" CACHE STRING "from .ini configuration")' ,
361+ ]
362+
363+ option_list_actual = parser .gen_option_list (section , generator = "cmake_fragment" )
364+
365+ print ("Expected Output:\n {}\n " .format ("\n " .join (option_list_expect )))
366+ print ("Actual Output:\n {}\n " .format ("\n " .join (option_list_actual )))
367+
368+ self .assertListEqual (option_list_expect , option_list_actual )
369+
370+ print ("-----[ TEST END ]------------------------------------------" )
319371 print ("OK" )
372+
320373 return 0
321374
322375 def test_SetProgramOptionsCMake_param_order_01 (self ):
0 commit comments