@@ -3980,6 +3980,60 @@ def test_set_default_module(self):
39803980 else :
39813981 self .assertTrue (False , "Uknown module syntax: %s" % get_module_syntax ())
39823982
3983+ def test_set_default_module_robot (self ):
3984+ """Test use of --set-default-module --robot."""
3985+ # create two test easyconfigs, one depending on the other
3986+ # (using dummy Toolchain easyblock included in the tests)
3987+ test_ec = os .path .join (self .test_prefix , 'test.eb' )
3988+ write_file (test_ec , '\n ' .join ([
3989+ "easyblock = 'Toolchain'" ,
3990+ "name = 'test'" ,
3991+ "version = '1.0'" ,
3992+ "homepage = 'https://example.com'" ,
3993+ "description = 'this is just a test'" ,
3994+ "toolchain = SYSTEM" ,
3995+ "dependencies = [('thisisjustatestdep', '3.14')]" ,
3996+ ]))
3997+ testdep_ec = os .path .join (self .test_prefix , 'thisisjustatestdep-3.14.eb' )
3998+ write_file (testdep_ec , '\n ' .join ([
3999+ "easyblock = 'Toolchain'" ,
4000+ "name = 'thisisjustatestdep'" ,
4001+ "version = '3.14'" ,
4002+ "homepage = 'https://example.com'" ,
4003+ "description = 'this is just a test'" ,
4004+ "toolchain = SYSTEM" ,
4005+ ]))
4006+
4007+ args = [
4008+ test_ec ,
4009+ '--force' ,
4010+ '--set-default-module' ,
4011+ '--robot' ,
4012+ self .test_prefix ,
4013+ ]
4014+ self .eb_main (args , do_build = True , raise_error = True )
4015+
4016+ # default module is set for specified easyconfig, but *not* for its dependency
4017+ modfiles_dir = os .path .join (self .test_installpath , 'modules' , 'all' )
4018+ self .assertEqual (sorted (os .listdir (modfiles_dir )), ['test' , 'thisisjustatestdep' ])
4019+ test_mod_dir = os .path .join (modfiles_dir , 'test' )
4020+ testdep_mod_dir = os .path .join (modfiles_dir , 'thisisjustatestdep' )
4021+
4022+ if get_module_syntax () == 'Lua' :
4023+ # only 'default' symlink for test/1.0, not for thisisjustadep/3.14
4024+ self .assertEqual (sorted (os .listdir (test_mod_dir )), ['1.0.lua' , 'default' ])
4025+ self .assertEqual (sorted (os .listdir (testdep_mod_dir )), ['3.14.lua' ])
4026+ default_symlink = os .path .join (test_mod_dir , 'default' )
4027+ self .assertTrue (os .path .islink (default_symlink ))
4028+ self .assertEqual (os .readlink (default_symlink ), '1.0.lua' )
4029+ elif get_module_syntax () == 'Tcl' :
4030+ self .assertEqual (sorted (os .listdir (test_mod_dir )), ['.version' , '1.0' ])
4031+ self .assertEqual (sorted (os .listdir (testdep_mod_dir )), ['3.14' ])
4032+ dot_version_file = os .path .join (test_mod_dir , '.version' )
4033+ self .assertTrue ("set ModulesVersion 1.0" in read_file (dot_version_file ))
4034+ else :
4035+ self .assertTrue (False , "Uknown module syntax: %s" % get_module_syntax ())
4036+
39834037 def test_inject_checksums (self ):
39844038 """Test for --inject-checksums"""
39854039 topdir = os .path .dirname (os .path .abspath (__file__ ))
0 commit comments