@@ -1346,6 +1346,34 @@ def test_start_dir_template(self):
13461346 self .assertIn ('start_dir in extension configure is %s &&' % ext_start_dir , logtxt )
13471347 self .assertIn ('start_dir in extension build is %s &&' % ext_start_dir , logtxt )
13481348
1349+ def test_sysroot_template (self ):
1350+ """Test the %(sysroot)s template"""
1351+
1352+ test_easyconfigs = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'easyconfigs' , 'test_ecs' )
1353+ toy_ec = os .path .join (test_easyconfigs , 't' , 'toy' , 'toy-0.0.eb' )
1354+
1355+ test_ec = os .path .join (self .test_prefix , 'test.eb' )
1356+ test_ec_txt = read_file (toy_ec )
1357+ test_ec_txt += '\n configopts = "--some-opt=%(sysroot)s/"'
1358+ test_ec_txt += '\n buildopts = "--some-opt=%(sysroot)s/"'
1359+ test_ec_txt += '\n installopts = "--some-opt=%(sysroot)s/"'
1360+ write_file (test_ec , test_ec_txt )
1361+
1362+ # Validate the value of the sysroot template if sysroot is unset (i.e. the build option is None)
1363+ ec = EasyConfig (test_ec )
1364+ self .assertEqual (ec ['configopts' ], "--some-opt=/" )
1365+ self .assertEqual (ec ['buildopts' ], "--some-opt=/" )
1366+ self .assertEqual (ec ['installopts' ], "--some-opt=/" )
1367+
1368+ # Validate the value of the sysroot template if sysroot is unset (i.e. the build option is None)
1369+ # As a test, we'll set the sysroot to self.test_prefix, as it has to be a directory that is guaranteed to exist
1370+ update_build_option ('sysroot' , self .test_prefix )
1371+
1372+ ec = EasyConfig (test_ec )
1373+ self .assertEqual (ec ['configopts' ], "--some-opt=%s/" % self .test_prefix )
1374+ self .assertEqual (ec ['buildopts' ], "--some-opt=%s/" % self .test_prefix )
1375+ self .assertEqual (ec ['installopts' ], "--some-opt=%s/" % self .test_prefix )
1376+
13491377 def test_constant_doc (self ):
13501378 """test constant documentation"""
13511379 doc = avail_easyconfig_constants ()
@@ -3234,6 +3262,7 @@ def test_template_constant_dict(self):
32343262 'nameletter' : 'g' ,
32353263 'nameletterlower' : 'g' ,
32363264 'parallel' : None ,
3265+ 'sysroot' : '' ,
32373266 'toolchain_name' : 'foss' ,
32383267 'toolchain_version' : '2018a' ,
32393268 'version' : '1.5' ,
@@ -3315,6 +3344,7 @@ def test_template_constant_dict(self):
33153344 'pyminver' : '7' ,
33163345 'pyshortver' : '3.7' ,
33173346 'pyver' : '3.7.2' ,
3347+ 'sysroot' : '' ,
33183348 'version' : '0.01' ,
33193349 'version_major' : '0' ,
33203350 'version_major_minor' : '0.01' ,
@@ -3379,6 +3409,7 @@ def test_template_constant_dict(self):
33793409 'namelower' : 'foo' ,
33803410 'nameletter' : 'f' ,
33813411 'nameletterlower' : 'f' ,
3412+ 'sysroot' : '' ,
33823413 'version' : '1.2.3' ,
33833414 'version_major' : '1' ,
33843415 'version_major_minor' : '1.2' ,
0 commit comments