Skip to content

Commit

Permalink
Merge pull request #4615 from xdelaruelle/cache_build
Browse files Browse the repository at this point in the history
Add module cache build support on EnvironmentModules
  • Loading branch information
boegel authored Aug 27, 2024
2 parents 131d408 + 78d8d9d commit 23db9d2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,16 @@ def get_setenv_value_from_modulefile(self, mod_name, var_name):

return value

def update(self):
"""Update after new modules were added."""

version = LooseVersion(self.version)
if build_option('update_modules_tool_cache') and version >= LooseVersion('5.3.0'):
out = self.run_module('cachebuild', return_stderr=True, check_output=False)

if self.testing:
return out


class Lmod(ModulesTool):
"""Interface to Lmod."""
Expand Down
23 changes: 23 additions & 0 deletions test/framework/modulestool.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,29 @@ def test_environment_modules_specific(self):
mt = EnvironmentModules(testing=True)
self.assertIsInstance(mt.loaded_modules(), list) # dummy usage

# test updating module cache
test_modulepath = os.path.join(self.test_installpath, 'modules', 'all')
os.environ['MODULEPATH'] = test_modulepath
test_module_dir = os.path.join(test_modulepath, 'test')
test_module_file = os.path.join(test_module_dir, '1.2.3')
write_file(test_module_file, '#%Module')
build_options = {
'update_modules_tool_cache': True,
}
init_config(build_options=build_options)
mt = EnvironmentModules(testing=True)
out = mt.update()
os.remove(test_module_file)
os.rmdir(test_module_dir)

# test cache file has been created if module tool supports it
if LooseVersion(mt.version) >= LooseVersion('5.3.0'):
cache_fp = os.path.join(test_modulepath, '.modulecache')
expected = "Creating %s\n" % cache_fp
self.assertEqual(expected, out, "Module cache created")
self.assertTrue(os.path.exists(cache_fp))
os.remove(cache_fp)

# initialize Environment Modules tool with non-official version number
# pass (fake) full path to 'modulecmd.tcl' via $MODULES_CMD
fake_path = os.path.join(self.test_installpath, 'libexec', 'modulecmd.tcl')
Expand Down

0 comments on commit 23db9d2

Please sign in to comment.