Skip to content

Commit 01e337f

Browse files
committed
Upgrade prepend failed warning to print_warning
1 parent edef14e commit 01e337f

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

easybuild/tools/modules.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,9 +1523,11 @@ def prepend_module_path(self, path, set_mod_paths=True, priority=None):
15231523
modulepath = curr_module_paths(clean=False)
15241524
path_idx = modulepath.index(path)
15251525
if path_idx != 0:
1526-
self.log.warn("Path '%s' could not be prepended to $MODULEPATH. The following paths have a higher "
1527-
"priority: %s'",
1528-
path, "; ".join(modulepath[:path_idx]))
1526+
print_warning("Path '%s' could not be prepended to $MODULEPATH. "
1527+
"The following paths are still in front of it: %s\n"
1528+
"This can happen if paths were added via `module use` with a priority higher than %s",
1529+
path, "; ".join(modulepath[:path_idx]), self.HIGH_PRIORITY,
1530+
log=self.log)
15291531
if set_mod_paths:
15301532
self.set_mod_paths()
15311533

test/framework/modules.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,19 @@ def test_prepend_module_path(self):
630630
self.assertEqual(test_path_1, modulepath[1])
631631
self.assertEqual(test_path_0, modulepath[2])
632632

633+
# When prepend fails due to a higher priority path, a warning is shown
634+
self.modtool.unuse(test_path_2)
635+
self.modtool.prepend_module_path(test_path_0, priority=999999)
636+
self.mock_stderr(True)
637+
self.modtool.prepend_module_path(test_path_2)
638+
stderr = self.get_stderr()
639+
self.mock_stderr(False)
640+
self.assertTrue('could not be prepended' in stderr)
641+
modulepath = curr_module_paths()
642+
self.assertEqual(test_path_0, modulepath[0])
643+
self.assertEqual(test_path_2, modulepath[1])
644+
self.assertEqual(test_path_1, modulepath[2])
645+
633646
def test_ld_library_path(self):
634647
"""Make sure LD_LIBRARY_PATH is what it should be when loaded multiple modules."""
635648
self.init_testmods()

0 commit comments

Comments
 (0)