5151from easybuild .tools .modules import reset_module_caches
5252from easybuild .tools .utilities import time2str
5353from easybuild .tools .version import get_git_revision , this_is_easybuild
54-
54+ from easybuild . tools . py2vs3 import string_type
5555
5656class EasyBlockTest (EnhancedTestCase ):
5757 """ Baseclass for easyblock testcases """
@@ -318,11 +318,10 @@ def test_make_module_req(self):
318318 os .makedirs (eb .installdir )
319319 open (os .path .join (eb .installdir , 'foo.jar' ), 'w' ).write ('foo.jar' )
320320 open (os .path .join (eb .installdir , 'bla.jar' ), 'w' ).write ('bla.jar' )
321- os .mkdir (os .path .join (eb .installdir , 'bin' ))
322- os .mkdir (os .path .join (eb .installdir , 'bin' , 'testdir' ))
323- os .mkdir (os .path .join (eb .installdir , 'sbin' ))
324- os .mkdir (os .path .join (eb .installdir , 'share' ))
325- os .mkdir (os .path .join (eb .installdir , 'share' , 'man' ))
321+ for path in ('bin' , ('bin' , 'testdir' ), 'sbin' , 'share' , ('share' , 'man' ), 'lib' , 'lib64' ):
322+ if isinstance (path , string_type ):
323+ path = (path , )
324+ os .mkdir (os .path .join (eb .installdir , * path ))
326325 # this is not a path that should be picked up
327326 os .mkdir (os .path .join (eb .installdir , 'CPATH' ))
328327
@@ -332,6 +331,7 @@ def test_make_module_req(self):
332331 self .assertTrue (re .search (r"^prepend-path\s+CLASSPATH\s+\$root/bla.jar$" , guess , re .M ))
333332 self .assertTrue (re .search (r"^prepend-path\s+CLASSPATH\s+\$root/foo.jar$" , guess , re .M ))
334333 self .assertTrue (re .search (r"^prepend-path\s+MANPATH\s+\$root/share/man$" , guess , re .M ))
334+ self .assertTrue (re .search (r"^prepend-path\s+CMAKE_PREFIX_PATH\s+\$root$" , guess , re .M ))
335335 # bin/ is not added to $PATH if it doesn't include files
336336 self .assertFalse (re .search (r"^prepend-path\s+PATH\s+\$root/bin$" , guess , re .M ))
337337 self .assertFalse (re .search (r"^prepend-path\s+PATH\s+\$root/sbin$" , guess , re .M ))
@@ -341,6 +341,7 @@ def test_make_module_req(self):
341341 self .assertTrue (re .search (r'^prepend_path\("CLASSPATH", pathJoin\(root, "bla.jar"\)\)$' , guess , re .M ))
342342 self .assertTrue (re .search (r'^prepend_path\("CLASSPATH", pathJoin\(root, "foo.jar"\)\)$' , guess , re .M ))
343343 self .assertTrue (re .search (r'^prepend_path\("MANPATH", pathJoin\(root, "share/man"\)\)$' , guess , re .M ))
344+ self .assertTrue ('prepend_path("CMAKE_PREFIX_PATH", root)' in guess )
344345 # bin/ is not added to $PATH if it doesn't include files
345346 self .assertFalse (re .search (r'^prepend_path\("PATH", pathJoin\(root, "bin"\)\)$' , guess , re .M ))
346347 self .assertFalse (re .search (r'^prepend_path\("PATH", pathJoin\(root, "sbin"\)\)$' , guess , re .M ))
@@ -361,6 +362,41 @@ def test_make_module_req(self):
361362 else :
362363 self .assertTrue (False , "Unknown module syntax: %s" % get_module_syntax ())
363364
365+ # Check that lib64 is only added to CMAKE_LIBRARY_PATH if there are files in there
366+ # but only if it is not a symlink to lib
367+ # -- No Files
368+ if get_module_syntax () == 'Tcl' :
369+ self .assertFalse (re .search (r"^prepend-path\s+CMAKE_LIBRARY_PATH\s+\$root/lib64$" , guess , re .M ))
370+ elif get_module_syntax () == 'Lua' :
371+ self .assertFalse ('prepend_path("CMAKE_LIBRARY_PATH", pathJoin(root, "lib64"))' in guess )
372+ # -- With files
373+ open (os .path .join (eb .installdir , 'lib64' , 'libfoo.so' ), 'w' ).write ('test' )
374+ guess = eb .make_module_req ()
375+ if get_module_syntax () == 'Tcl' :
376+ self .assertTrue (re .search (r"^prepend-path\s+CMAKE_LIBRARY_PATH\s+\$root/lib64$" , guess , re .M ))
377+ elif get_module_syntax () == 'Lua' :
378+ self .assertTrue ('prepend_path("CMAKE_LIBRARY_PATH", pathJoin(root, "lib64"))' in guess )
379+ # -- With files in lib and lib64 symlinks to lib
380+ open (os .path .join (eb .installdir , 'lib' , 'libfoo.so' ), 'w' ).write ('test' )
381+ shutil .rmtree (os .path .join (eb .installdir , 'lib64' ))
382+ os .symlink ('lib' , os .path .join (eb .installdir , 'lib64' ))
383+ guess = eb .make_module_req ()
384+ if get_module_syntax () == 'Tcl' :
385+ self .assertFalse (re .search (r"^prepend-path\s+CMAKE_LIBRARY_PATH\s+\$root/lib64$" , guess , re .M ))
386+ elif get_module_syntax () == 'Lua' :
387+ self .assertFalse ('prepend_path("CMAKE_LIBRARY_PATH", pathJoin(root, "lib64"))' in guess )
388+
389+ # With files in /lib and /lib64 symlinked to /lib there should be exactly 1 entry for (LD_)LIBRARY_PATH
390+ # pointing to /lib
391+ for var in ('LIBRARY_PATH' , 'LD_LIBRARY_PATH' ):
392+ if get_module_syntax () == 'Tcl' :
393+ self .assertFalse (re .search (r"^prepend-path\s+%s\s+\$root/lib64$" % var , guess , re .M ))
394+ self .assertEqual (len (re .findall (r"^prepend-path\s+%s\s+\$root/lib$" % var , guess , re .M )), 1 )
395+ elif get_module_syntax () == 'Lua' :
396+ self .assertFalse (re .search (r'^prepend_path\("%s", pathJoin\(root, "lib64"\)\)$' % var , guess , re .M ))
397+ self .assertEqual (len (re .findall (r'^prepend_path\("%s", pathJoin\(root, "lib"\)\)$' % var ,
398+ guess , re .M )), 1 )
399+
364400 # check for behavior when a string value is used as dict value by make_module_req_guesses
365401 eb .make_module_req_guess = lambda : {'PATH' : 'bin' }
366402 txt = eb .make_module_req ()
0 commit comments