@@ -594,7 +594,8 @@ def test_make_module_req(self):
594594 full_path = os .path .join (eb .installdir , path , 'subpath' )
595595 os .makedirs (full_path )
596596 write_file (os .path .join (full_path , 'any.file' ), 'test' )
597- txt = eb .make_module_req ()
597+ with eb .module_generator .start_module_creation ():
598+ txt = eb .make_module_req ()
598599 if get_module_syntax () == 'Tcl' :
599600 self .assertFalse (re .search (r"prepend-path\s+LD_LIBRARY_PATH\s+\$%s\n" % sub_lib_path ,
600601 txt , re .M ))
@@ -605,6 +606,27 @@ def test_make_module_req(self):
605606 txt , re .M ))
606607 self .assertFalse (re .search (r'prepend_path\("PATH", pathJoin\(root, "%s"\)\)\n' % sub_path_path , txt , re .M ))
607608
609+ # Module load environement may contain non-path variables
610+ # TODO: remove whenever this is properly supported, in the meantime check warning
611+ eb .module_load_environment .NONPATH = ('non_path' , {'var_type' : "STRING" })
612+ eb .module_load_environment .PATH = ['bin' ]
613+ with self .mocked_stdout_stderr ():
614+ txt = eb .make_module_req ()
615+
616+ self .assertEqual (list (eb .module_load_environment ), ['PATH' , 'LD_LIBRARY_PATH' , 'NONPATH' ])
617+
618+ if get_module_syntax () == 'Tcl' :
619+ self .assertTrue (re .match (r"^\nprepend-path\s+PATH\s+\$root/bin\n$" , txt , re .M ))
620+ self .assertFalse (re .match (r"^\nprepend-path\s+NONPATH\s+\$root/non_path\n$" , txt , re .M ))
621+ elif get_module_syntax () == 'Lua' :
622+ self .assertTrue (re .match (r'^\nprepend_path\("PATH", pathJoin\(root, "bin"\)\)\n$' , txt , re .M ))
623+ self .assertFalse (re .match (r'^\nprepend_path\("NONPATH", pathJoin\(root, "non_path"\)\)\n$' , txt , re .M ))
624+ else :
625+ self .fail ("Unknown module syntax: %s" % get_module_syntax ())
626+
627+ logtxt = read_file (eb .logfile )
628+ self .assertTrue (re .search (r"WARNING Non-path variables found in module load env.*NONPATH" , logtxt , re .M ))
629+
608630 # cleanup
609631 eb .close_log ()
610632 os .remove (eb .logfile )
0 commit comments