Skip to content

Commit 097f394

Browse files
author
Caspar van Leeuwen
committed
Updated tests for syroot template
1 parent d52c779 commit 097f394

File tree

1 file changed

+23
-65
lines changed

1 file changed

+23
-65
lines changed

test/framework/easyconfig.py

Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,75 +1346,33 @@ 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)"""
1349+
def test_sysroot_template(self):
1350+
"""Test the %(sysroot)s template"""
13511351

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
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 += '\nconfigopts = "--some-opt=%(sysroot)s/"'
1358+
test_ec_txt += '\nbuildopts = "--some-opt=%(sysroot)s/"'
1359+
test_ec_txt += '\ninstallopts = "--some-opt=%(sysroot)s/"'
1360+
write_file(test_ec, test_ec_txt)
13951361

1396-
sources = [SOURCE_TAR_GZ]
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=/")
13971367

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 && '
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)
14011371

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)
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)
14181376

14191377
def test_constant_doc(self):
14201378
"""test constant documentation"""

0 commit comments

Comments
 (0)