@@ -536,6 +536,13 @@ def test_module_caches(self):
536
536
self .assertTrue (any ([os .path .samefile (nonpath , mp ) for mp in modulepaths ]))
537
537
shutil .rmtree (nonpath )
538
538
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
+
539
546
# no caching for 'avail' commands with an argument
540
547
self .assertTrue (self .modtool .available ('GCC' ))
541
548
self .assertEqual (mod .MODULE_AVAIL_CACHE , {})
@@ -565,14 +572,13 @@ def test_module_caches(self):
565
572
self .assertTrue (self .modtool .show ('FFTW' ) is show_res_fftw )
566
573
567
574
# invalidate caches with correct path
568
- modpath = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'modules' )
569
575
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 ]))
571
577
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 ]))
573
579
574
580
# verify cache invalidation, caches should be empty again
575
- invalidate_module_caches_for (modpath )
581
+ invalidate_module_caches_for (test_mods_path )
576
582
self .assertEqual (mod .MODULE_AVAIL_CACHE , {})
577
583
self .assertEqual (mod .MODULE_SHOW_CACHE , {})
578
584
0 commit comments