Skip to content

Commit 2e51d6f

Browse files
committed
Merge pull request #1776 from boegel/module_cache_bug
break after deleting cache entry to avoid attempt to delete cache entry again
2 parents 834fcbf + a58d741 commit 2e51d6f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

easybuild/tools/modules.py

+1
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ def invalidate_module_caches_for(path):
11491149
_log.debug("Entry '%s' in 'module %s' cache is evicted, marked as invalid via path '%s': %s",
11501150
key, subcmd, path, cache[key])
11511151
del cache[key]
1152+
break
11521153

11531154

11541155
class Modules(EnvironmentModulesC):

test/framework/modules.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,13 @@ def test_module_caches(self):
536536
self.assertTrue(any([os.path.samefile(nonpath, mp) for mp in modulepaths]))
537537
shutil.rmtree(nonpath)
538538

539+
# create symlink to entry in $MODULEPATH we're going to use, and add it to $MODULEPATH
540+
# invalidate_module_caches_for should be able to deal with this
541+
test_mods_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'modules')
542+
mods_symlink = os.path.join(self.test_prefix, 'modules_symlink')
543+
os.symlink(test_mods_path, mods_symlink)
544+
self.modtool.use(mods_symlink)
545+
539546
# no caching for 'avail' commands with an argument
540547
self.assertTrue(self.modtool.available('GCC'))
541548
self.assertEqual(mod.MODULE_AVAIL_CACHE, {})
@@ -565,14 +572,13 @@ def test_module_caches(self):
565572
self.assertTrue(self.modtool.show('FFTW') is show_res_fftw)
566573

567574
# invalidate caches with correct path
568-
modpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'modules')
569575
modulepaths = [p for p in os.environ.get('MODULEPATH', '').split(os.pathsep) if p]
570-
self.assertTrue(any([os.path.exists(mp) and os.path.samefile(modpath, mp) for mp in modulepaths]))
576+
self.assertTrue(any([os.path.exists(mp) and os.path.samefile(test_mods_path, mp) for mp in modulepaths]))
571577
paths_in_key = [p for p in avail_cache_key[0].split('=')[1].split(os.pathsep) if p]
572-
self.assertTrue(any([os.path.exists(p) and os.path.samefile(modpath, p) for p in paths_in_key]))
578+
self.assertTrue(any([os.path.exists(p) and os.path.samefile(test_mods_path, p) for p in paths_in_key]))
573579

574580
# verify cache invalidation, caches should be empty again
575-
invalidate_module_caches_for(modpath)
581+
invalidate_module_caches_for(test_mods_path)
576582
self.assertEqual(mod.MODULE_AVAIL_CACHE, {})
577583
self.assertEqual(mod.MODULE_SHOW_CACHE, {})
578584

0 commit comments

Comments
 (0)