Skip to content

Commit 1fc53fa

Browse files
author
Vasileios Karakasis
authored
Merge pull request #2401 from teojgo/bugfix/find_modules_duplicates
[bugfix] Fix `find_modules` to return unique module names
2 parents 65e3d8f + 1b4580c commit 1fc53fa

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

reframe/utility/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def _is_valid_for_env(m, e):
678678
for p in current_system.partitions:
679679
for e in p.environs:
680680
rt.loadenv(p.local_env, e)
681-
modules = ms.available_modules(substr)
681+
modules = OrderedSet(ms.available_modules(substr))
682682
snap0.restore()
683683
for m in modules:
684684
if _is_valid_for_env(m, e.name):

unittests/test_utility.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,16 +1450,24 @@ def user_exec_ctx(request, make_exec_ctx_g):
14501450

14511451

14521452
@pytest.fixture
1453-
def modules_system(user_exec_ctx, monkeypatch):
1453+
def modules_system(user_exec_ctx, monkeypatch, tmp_path):
14541454
# Pretend to be on a clean modules environment
14551455
monkeypatch.setenv('MODULEPATH', '')
14561456
monkeypatch.setenv('LOADEDMODULES', '')
14571457
monkeypatch.setenv('_LMFILES_', '')
14581458

1459+
# Create a symlink to testmod_foo to check for unique module names
1460+
# found by `find_modules`
1461+
(tmp_path / 'testmod_foo').symlink_to(
1462+
os.path.join(test_util.TEST_MODULES, 'testmod_foo')
1463+
)
1464+
14591465
ms = rt.runtime().system.modules_system
1466+
ms.searchpath_add(str(tmp_path))
14601467
ms.searchpath_add(test_util.TEST_MODULES)
14611468
yield ms
14621469
ms.searchpath_remove(test_util.TEST_MODULES)
1470+
ms.searchpath_remove(str(tmp_path))
14631471

14641472

14651473
def test_find_modules(modules_system):

0 commit comments

Comments
 (0)