Skip to content

Commit dc619c3

Browse files
authored
Merge pull request #172 from vkarak/bugfix/crash-init-modules-systems
Fix crash when init_modules_system throws
2 parents 6cdb6af + 953b8e0 commit dc619c3

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

reframe/core/modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def init_modules_system(modules_kind=None):
543543
elif modules_kind == 'lmod':
544544
_modules_system = ModulesSystem(LModImpl())
545545
else:
546-
raise ConfigError('unknown module system')
546+
raise ConfigError('unknown module system: %s' % modules_kind)
547547

548548

549549
def get_modules_system():

reframe/frontend/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,12 @@ def main():
233233
list_supported_systems(site_config.systems.values(), printer)
234234
sys.exit(1)
235235

236-
# Init modules system
237-
init_modules_system(system.modules_system)
236+
try:
237+
# Init modules system
238+
init_modules_system(system.modules_system)
239+
except ReframeError as e:
240+
printer.error('could not initialize the modules system: %s' % e)
241+
sys.exit(1)
238242

239243
try:
240244
if options.module_map_file:

unittests/test_cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
import itertools
23
import os
34
import re
@@ -293,5 +294,16 @@ def test_execution_modes(self):
293294
self.assertIn('PASSED', stdout)
294295
self.assertIn('Ran 1 test case', stdout)
295296

297+
def test_unknown_modules_system(self):
298+
# Monkey patch site configuration to trigger a module systems error
299+
site_config_save = copy.deepcopy(settings._site_configuration)
300+
systems = list(settings._site_configuration['systems'].keys())
301+
for s in systems:
302+
settings._site_configuration['systems'][s]['modules_system'] = 'foo'
303+
304+
returncode, stdout, stderr = self._run_reframe()
305+
self.assertNotEqual(0, returncode)
306+
settings._site_configuration = site_config_save
307+
296308
def tearDown(self):
297309
shutil.rmtree(self.prefix)

0 commit comments

Comments
 (0)