Skip to content

Commit cde21cb

Browse files
authored
Merge pull request #4739 from xdelaruelle/modules-5.5
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+)
2 parents 7927622 + d257b87 commit cde21cb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

easybuild/tools/modules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ def show(self, mod_name):
898898
ans = MODULE_SHOW_CACHE[key]
899899
self.log.debug("Found cached result for 'module show %s' with key '%s': %s", mod_name, key, ans)
900900
else:
901-
ans = self.run_module('show', mod_name, check_output=False, return_stderr=True)
901+
ans = self.run_module('show', mod_name, check_output=False, return_stderr=True,
902+
check_exit_code=False)
902903
MODULE_SHOW_CACHE[key] = ans
903904
self.log.debug("Cached result for 'module show %s' with key '%s': %s", mod_name, key, ans)
904905

test/framework/modules.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ def test_run_module(self):
122122
error_pattern = "Module command '.*thisdoesnotmakesense' failed with exit code [1-9]"
123123
self.assertErrorRegex(EasyBuildError, error_pattern, self.modtool.run_module, 'thisdoesnotmakesense')
124124

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

0 commit comments

Comments
 (0)