Skip to content

Commit 36d4f92

Browse files
committed
add test to verify that environment variables don't leak into module file of subsequent installations
1 parent 0b81a21 commit 36d4f92

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/framework/sandbox/easybuild/easyblocks/t/toy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,10 @@ def make_module_extra(self):
192192
txt = super(EB_toy, self).make_module_extra()
193193
txt += self.module_generator.set_environment('TOY', os.getenv('TOY', '<TOY_env_var_not_defined>'))
194194
return txt
195+
196+
def make_module_req_guess(self):
197+
"""Extra paths for environment variables to consider"""
198+
guesses = super(EB_toy, self).make_module_req_guess()
199+
if self.name == 'toy':
200+
guesses['CPATH'].append('toy-headers')
201+
return guesses

test/framework/toy_build.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,6 +4302,42 @@ def test_toy_python(self):
43024302
self.assertTrue(ebpythonprefixes_regex.search(toy_mod_txt),
43034303
f"Pattern '{ebpythonprefixes_regex.pattern}' found in: {toy_mod_txt}")
43044304

4305+
def test_toy_multiple_ecs_module(self):
4306+
"""
4307+
Verify whether module file is correct when multiple easyconfigs are being installed.
4308+
"""
4309+
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
4310+
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
4311+
4312+
# modify 'toy' easyconfig so toy-headers subdirectory is created,
4313+
# which is taken into account by EB_toy easyblock for $CPATH
4314+
test_toy_ec = os.path.join(self.test_prefix, 'test-toy.eb')
4315+
toy_ec_txt = read_file(toy_ec)
4316+
toy_ec_txt += "\npostinstallcmds += ['mkdir %(installdir)s/toy-headers']"
4317+
toy_ec_txt += "\npostinstallcmds += ['touch %(installdir)s/toy-headers/toy.h']"
4318+
write_file(test_toy_ec, toy_ec_txt)
4319+
4320+
# modify 'toy-app' easyconfig so toy-headers subdirectory is created,
4321+
# which is consider by EB_toy easyblock for $CPATH,
4322+
# but should *not* be actually used because software name is not 'toy'
4323+
toy_app_ec = os.path.join(test_ecs, 't', 'toy-app', 'toy-app-0.0.eb')
4324+
test_toy_app_ec = os.path.join(self.test_prefix, 'test-toy-app.eb')
4325+
toy_ec_txt = read_file(toy_app_ec)
4326+
toy_ec_txt += "\npostinstallcmds += ['mkdir %(installdir)s/toy-headers']"
4327+
toy_ec_txt += "\npostinstallcmds += ['touch %(installdir)s/toy-headers/toy.h']"
4328+
write_file(test_toy_app_ec, toy_ec_txt)
4329+
4330+
self.run_test_toy_build_with_output(ec_file=test_toy_ec, extra_args=[test_toy_app_ec])
4331+
4332+
toy_modtxt = read_file(os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0.lua'))
4333+
regex = re.compile('prepend[-_]path.*CPATH.*toy-headers', re.M)
4334+
self.assertTrue(regex.search(toy_modtxt),
4335+
f"Pattern '{regex.pattern}' should be found in: {toy_modtxt}")
4336+
4337+
toy_app_modtxt = read_file(os.path.join(self.test_installpath, 'modules', 'all', 'toy-app', '0.0.lua'))
4338+
self.assertFalse(regex.search(toy_app_modtxt),
4339+
f"Pattern '{regex.pattern}' should *not* be found in: {toy_app_modtxt}")
4340+
43054341

43064342
def suite():
43074343
""" return all the tests in this file """

0 commit comments

Comments
 (0)