2828@author: Kenneth Hoste (Ghent University)
2929@author: Damian Alvarez (Forschungszentrum Juelich GmbH)
3030"""
31+ import copy
3132import glob
3233import grp
3334import os
@@ -1287,6 +1288,7 @@ def test_toy_module_fulltxt(self):
12871288
12881289 def test_external_dependencies (self ):
12891290 """Test specifying external (build) dependencies."""
1291+
12901292 topdir = os .path .dirname (os .path .abspath (__file__ ))
12911293 ectxt = read_file (os .path .join (topdir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' , 'toy-0.0-deps.eb' ))
12921294 toy_ec = os .path .join (self .test_prefix , 'toy-0.0-external-deps.eb' )
@@ -1303,26 +1305,43 @@ def test_external_dependencies(self):
13031305 mkdir (os .path .join (modulepath , os .path .dirname (mod )), parents = True )
13041306 write_file (os .path .join (modulepath , mod ), "#%Module" )
13051307
1306- self .reset_modulepath ([modulepath , os .path .join (self .test_installpath , 'modules' , 'all' )])
1308+ installed_test_modules = os .path .join (self .test_installpath , 'modules' , 'all' )
1309+ self .reset_modulepath ([modulepath , installed_test_modules ])
1310+
1311+ start_env = copy .deepcopy (os .environ )
1312+
13071313 self .test_toy_build (ec_file = toy_ec , versionsuffix = '-external-deps' , verbose = True , raise_error = True )
13081314
13091315 self .modtool .load (['toy/0.0-external-deps' ])
13101316 # note build dependency is not loaded
13111317 mods = ['intel/2018a' , 'GCC/6.4.0-2.28' , 'foobar/1.2.3' , 'toy/0.0-external-deps' ]
13121318 self .assertEqual ([x ['mod_name' ] for x in self .modtool .list ()], mods )
13131319
1314- # check behaviour when a non-existing external (build) dependency is included
1315- err_msg = "Missing modules for dependencies marked as external modules:"
1320+ # restore original environment (to undo 'module load' done above)
1321+ modify_env ( os . environ , start_env , verbose = False )
13161322
1323+ # check behaviour when a non-existing external (build) dependency is included
13171324 extraectxt = "\n builddependencies = [('nosuchbuilddep/0.0.0', EXTERNAL_MODULE)]"
13181325 extraectxt += "\n versionsuffix = '-external-deps-broken1'"
13191326 write_file (toy_ec , ectxt + extraectxt )
1327+
1328+ if isinstance (self .modtool , Lmod ):
1329+ err_msg = r"Module command \\'module load nosuchbuilddep/0.0.0\\' failed"
1330+ else :
1331+ err_msg = r"Unable to locate a modulefile for 'nosuchbuilddep/0.0.0'"
1332+
13201333 self .assertErrorRegex (EasyBuildError , err_msg , self .test_toy_build , ec_file = toy_ec ,
13211334 raise_error = True , verbose = False )
13221335
13231336 extraectxt = "\n dependencies += [('nosuchmodule/1.2.3', EXTERNAL_MODULE)]"
13241337 extraectxt += "\n versionsuffix = '-external-deps-broken2'"
13251338 write_file (toy_ec , ectxt + extraectxt )
1339+
1340+ if isinstance (self .modtool , Lmod ):
1341+ err_msg = r"Module command \\'module load nosuchmodule/1.2.3\\' failed"
1342+ else :
1343+ err_msg = r"Unable to locate a modulefile for 'nosuchmodule/1.2.3'"
1344+
13261345 self .assertErrorRegex (EasyBuildError , err_msg , self .test_toy_build , ec_file = toy_ec ,
13271346 raise_error = True , verbose = False )
13281347
0 commit comments