Skip to content

Commit

Permalink
Merge pull request #4739 from xdelaruelle/modules-5.5
Browse files Browse the repository at this point in the history
Adapt `module show` command run to cope with non-zero exit code for non-existing module (required for Environment Modules v5.5+ and Lmod 8.7.56+)
  • Loading branch information
boegel authored Feb 9, 2025
2 parents 7927622 + d257b87 commit cde21cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ def show(self, mod_name):
ans = MODULE_SHOW_CACHE[key]
self.log.debug("Found cached result for 'module show %s' with key '%s': %s", mod_name, key, ans)
else:
ans = self.run_module('show', mod_name, check_output=False, return_stderr=True)
ans = self.run_module('show', mod_name, check_output=False, return_stderr=True,
check_exit_code=False)
MODULE_SHOW_CACHE[key] = ans
self.log.debug("Cached result for 'module show %s' with key '%s': %s", mod_name, key, ans)

Expand Down
10 changes: 6 additions & 4 deletions test/framework/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ def test_run_module(self):
error_pattern = "Module command '.*thisdoesnotmakesense' failed with exit code [1-9]"
self.assertErrorRegex(EasyBuildError, error_pattern, self.modtool.run_module, 'thisdoesnotmakesense')

# we need to use a different error pattern here with Environment Modules,
# because a load of a non-existing module doesnt' trigger a non-zero exit code...
# it will still fail though, just differently
if isinstance(self.modtool, EnvironmentModulesC) or isinstance(self.modtool, EnvironmentModules):
# we need to use a different error pattern here with EnvironmentModulesC and
# EnvironmentModules <5.5, because a load of a non-existing module doesnt' trigger a
# non-zero exit code. it will still fail though, just differently
version = LooseVersion(self.modtool.version)
if (isinstance(self.modtool, EnvironmentModulesC)
or (isinstance(self.modtool, EnvironmentModules) and version < '5.5')):
error_pattern = "Unable to locate a modulefile for 'nosuchmodule/1.2.3'"
else:
error_pattern = "Module command '.*load nosuchmodule/1.2.3' failed with exit code [1-9]"
Expand Down

0 comments on commit cde21cb

Please sign in to comment.