@@ -1346,6 +1346,76 @@ 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_empty (self ):
1350+ """Test the %(sysroot)s template whenever --sysroot is unset (i.e. None)"""
1351+
1352+ self .contents = textwrap .dedent ("""
1353+ name = 'toy'
1354+ version = '0.0'
1355+
1356+ homepage = 'https://easybuilders.github.io/easybuild'
1357+ description = 'Toy C program, 100% toy.'
1358+
1359+ toolchain = SYSTEM
1360+
1361+ sources = [SOURCE_TAR_GZ]
1362+
1363+ preconfigopts = 'echo sysroot in configure is %(sysroot)s && '
1364+ prebuildopts = 'echo sysroot in build is %(sysroot)s && '
1365+ preinstallopts = 'echo sysroot in install is %(sysroot)s && '
1366+
1367+ moduleclass = 'tools'
1368+ """ )
1369+ self .prep ()
1370+ ec = EasyConfig (self .eb_file )
1371+ from easybuild .easyblocks .toy import EB_toy
1372+ eb = EB_toy (ec )
1373+ # Check behaviour when sysroot is not set (i.e. None)
1374+ eb .cfg ['sysroot' ] = None # Should we define this explicitely? Or rely on this to be the default?
1375+ eb .cfg ['stop' ] = 'extensions'
1376+ with self .mocked_stdout_stderr ():
1377+ eb .run_all_steps (False )
1378+ logtxt = read_file (eb .logfile )
1379+ sysroot = ""
1380+ self .assertIn ('sysroot in configure is %s/ &&' % sysroot , logtxt )
1381+ self .assertIn ('sysroot in build is %s/ &&' % sysroot , logtxt )
1382+ self .assertIn ('sysroot in install is %s/ &&' % sysroot , logtxt )
1383+
1384+ def test_sysroot_template_non_empty (self ):
1385+ """Test the %(sysroot)s template whenever --sysroot is unset (i.e. None)"""
1386+
1387+ self .contents = textwrap .dedent ("""
1388+ name = 'toy'
1389+ version = '0.0'
1390+
1391+ homepage = 'https://easybuilders.github.io/easybuild'
1392+ description = 'Toy C program, 100% toy.'
1393+
1394+ toolchain = SYSTEM
1395+
1396+ sources = [SOURCE_TAR_GZ]
1397+
1398+ preconfigopts = 'echo sysroot in configure is %(sysroot)s && '
1399+ prebuildopts = 'echo sysroot in build is %(sysroot)s && '
1400+ preinstallopts = 'echo sysroot in install is %(sysroot)s && '
1401+
1402+ moduleclass = 'tools'
1403+ """ )
1404+ self .prep ()
1405+ ec = EasyConfig (self .eb_file )
1406+ from easybuild .easyblocks .toy import EB_toy
1407+ eb = EB_toy (ec )
1408+ # Check behaviour when sysroot is not set (i.e. None)
1409+ eb .cfg ['sysroot' ] = '/tmp' # This should be a path that exists, otherwise EasyBuild complains
1410+ eb .cfg ['stop' ] = 'extensions'
1411+ with self .mocked_stdout_stderr ():
1412+ eb .run_all_steps (False )
1413+ logtxt = read_file (eb .logfile )
1414+ sysroot = ""
1415+ self .assertIn ('sysroot in configure is %s/ &&' % sysroot , logtxt )
1416+ self .assertIn ('sysroot in build is %s/ &&' % sysroot , logtxt )
1417+ self .assertIn ('sysroot in install is %s/ &&' % sysroot , logtxt )
1418+
13491419 def test_constant_doc (self ):
13501420 """test constant documentation"""
13511421 doc = avail_easyconfig_constants ()
0 commit comments