Skip to content

Commit def5d3f

Browse files
committed
enhance test for ModulesTool.exist to catch bug fixes in #3379
1 parent 03fbb3a commit def5d3f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/framework/modules.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,34 @@ def test_exist(self):
310310
if self.modtool.__class__ != EnvironmentModulesC:
311311
self.assertEqual(self.modtool.exist(['Java/Alias', 'Java/NonExist']), [True, False])
312312

313+
# set 'module avail' cache entries to empty lists,
314+
# to enforce fallback to 'module show'
315+
import easybuild.tools.modules
316+
for key in easybuild.tools.modules.MODULE_AVAIL_CACHE:
317+
easybuild.tools.modules.MODULE_AVAIL_CACHE[key] = []
318+
319+
# clear 'module show' cache, to keep control below
320+
easybuild.tools.modules.MODULE_SHOW_CACHE.clear()
321+
self.assertEqual(self.modtool.exist(['Java/1.8', 'Java/1.8.0_181']), [True, True])
322+
323+
# mimic more verbose stderr output produced by old Tmod version,
324+
# including a warning produced when multiple .modulerc files are being picked up
325+
# see https://github.com/easybuilders/easybuild-framework/issues/3376
326+
ml_show_java18_stderr = '\n'.join([
327+
"module-version Java/1.8.0_181 1.8",
328+
"WARNING: Duplicate version symbol '1.8' found",
329+
"module-version Java/1.8.0_181 1.8",
330+
"-------------------------------------------------------------------",
331+
"/modulefiles/lang/Java/1.8.0_181:",
332+
"-------------------------------------------------------------------",
333+
])
334+
335+
# overwrite 'module show' cache entries with output that includes extra lines
336+
for key in easybuild.tools.modules.MODULE_SHOW_CACHE:
337+
easybuild.tools.modules.MODULE_SHOW_CACHE[key] = ml_show_java18_stderr
338+
339+
self.assertEqual(self.modtool.exist(['Java/1.8', 'Java/1.8.0_181']), [True, True])
340+
313341
reset_module_caches()
314342

315343
# what if we're in an HMNS setting...

0 commit comments

Comments
 (0)