@@ -421,6 +421,31 @@ def test_make_module_req(self):
421421 else :
422422 self .assertTrue (False , "Unknown module syntax: %s" % get_module_syntax ())
423423
424+ # check for correct order of prepend statements when providing a list (and that no duplicates are allowed)
425+ eb .make_module_req_guess = lambda : {'LD_LIBRARY_PATH' : ['lib/pathC' , 'lib/pathA' , 'lib/pathB' , 'lib/pathA' ]}
426+ for path in ['pathA' , 'pathB' , 'pathC' ]:
427+ os .mkdir (os .path .join (eb .installdir , 'lib' , path ))
428+ open (os .path .join (eb .installdir , 'lib' , path , 'libfoo.so' ), 'w' ).write ('test' )
429+ txt = eb .make_module_req ()
430+ if get_module_syntax () == 'Tcl' :
431+ self .assertTrue (re .search (r"\nprepend-path\s+LD_LIBRARY_PATH\s+\$root/lib/pathC\n" +
432+ r"prepend-path\s+LD_LIBRARY_PATH\s+\$root/lib/pathA\n" +
433+ r"prepend-path\s+LD_LIBRARY_PATH\s+\$root/lib/pathB\n" ,
434+ txt , re .M ))
435+ self .assertFalse (re .search (r"\nprepend-path\s+LD_LIBRARY_PATH\s+\$root/lib/pathB\n" +
436+ r"prepend-path\s+LD_LIBRARY_PATH\s+\$root/lib/pathA\n" ,
437+ txt , re .M ))
438+ elif get_module_syntax () == 'Lua' :
439+ self .assertTrue (re .search (r'\nprepend_path\("LD_LIBRARY_PATH", pathJoin\(root, "lib/pathC"\)\)\n' +
440+ r'prepend_path\("LD_LIBRARY_PATH", pathJoin\(root, "lib/pathA"\)\)\n' +
441+ r'prepend_path\("LD_LIBRARY_PATH", pathJoin\(root, "lib/pathB"\)\)\n' ,
442+ txt , re .M ))
443+ self .assertFalse (re .search (r'\nprepend_path\("LD_LIBRARY_PATH", pathJoin\(root, "lib/pathB"\)\)\n' +
444+ r'prepend_path\("LD_LIBRARY_PATH", pathJoin\(root, "lib/pathA"\)\)\n' ,
445+ txt , re .M ))
446+ else :
447+ self .assertTrue (False , "Unknown module syntax: %s" % get_module_syntax ())
448+
424449 # cleanup
425450 eb .close_log ()
426451 os .remove (eb .logfile )
0 commit comments