Skip to content

Commit d257b87

Browse files
committed
EnvironmentModules now correctly set a non-zero exit code
Starting Environment Modules v5.5, a non-zero exit code is set by modulecmd.tcl when trying to load a non-existing module.
1 parent 25a367e commit d257b87

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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)