Skip to content

Commit

Permalink
update test_make_module_req to be compatible with refactor of make_mo…
Browse files Browse the repository at this point in the history
…dule_req
  • Loading branch information
lexming committed Sep 23, 2024
1 parent 93fc7a9 commit 7e9c7d1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,13 @@ def test_make_module_req(self):

# create fake directories and files that should be guessed
os.makedirs(eb.installdir)
write_file(os.path.join(eb.installdir, 'foo.jar'), 'foo.jar')
write_file(os.path.join(eb.installdir, 'bla.jar'), 'bla.jar')
for path in ('bin', ('bin', 'testdir'), 'sbin', 'share', ('share', 'man'), 'lib', 'lib64'):
if isinstance(path, str):
path = (path, )
os.mkdir(os.path.join(eb.installdir, *path))
write_file(os.path.join(eb.installdir, 'foo.jar'), 'foo.jar')
write_file(os.path.join(eb.installdir, 'bla.jar'), 'bla.jar')
write_file(os.path.join(eb.installdir, 'share', 'man', 'pi'), 'Man page')
# this is not a path that should be picked up
os.mkdir(os.path.join(eb.installdir, 'CPATH'))

Expand Down Expand Up @@ -519,7 +520,7 @@ def test_make_module_req(self):
guess, re.M)), 1)

# check for behavior when a string value is used as dict value by make_module_req_guesses
eb.make_module_req_guess = lambda: {'PATH': 'bin'}
eb.make_module_req_guess = lambda: {'PATH': (['bin'], False)}
with eb.module_generator.start_module_creation():
txt = eb.make_module_req()
if get_module_syntax() == 'Tcl':
Expand All @@ -531,7 +532,7 @@ def test_make_module_req(self):

# check for correct behaviour if empty string is specified as one of the values
# prepend-path statements should be included for both the 'bin' subdir and the install root
eb.make_module_req_guess = lambda: {'PATH': ['bin', '']}
eb.make_module_req_guess = lambda: {'PATH': (['bin', ''], False)}
with eb.module_generator.start_module_creation():
txt = eb.make_module_req()
if get_module_syntax() == 'Tcl':
Expand All @@ -544,7 +545,9 @@ def test_make_module_req(self):
self.fail("Unknown module syntax: %s" % get_module_syntax())

# check for correct order of prepend statements when providing a list (and that no duplicates are allowed)
eb.make_module_req_guess = lambda: {'LD_LIBRARY_PATH': ['lib/pathC', 'lib/pathA', 'lib/pathB', 'lib/pathA']}
eb.make_module_req_guess = lambda: {
'LD_LIBRARY_PATH': (['lib/pathC', 'lib/pathA', 'lib/pathB', 'lib/pathA'], False),
}
for path in ['pathA', 'pathB', 'pathC']:
os.mkdir(os.path.join(eb.installdir, 'lib', path))
write_file(os.path.join(eb.installdir, 'lib', path, 'libfoo.so'), 'test')
Expand Down Expand Up @@ -572,7 +575,7 @@ def test_make_module_req(self):
# If PATH or LD_LIBRARY_PATH contain only folders, do not add an entry
sub_lib_path = os.path.join('lib', 'path_folders')
sub_path_path = os.path.join('bin', 'path_folders')
eb.make_module_req_guess = lambda: {'LD_LIBRARY_PATH': sub_lib_path, 'PATH': sub_path_path}
eb.make_module_req_guess = lambda: {'LD_LIBRARY_PATH': (sub_lib_path, False), 'PATH': (sub_path_path, False)}
for path in (sub_lib_path, sub_path_path):
full_path = os.path.join(eb.installdir, path, 'subpath')
os.makedirs(full_path)
Expand Down

0 comments on commit 7e9c7d1

Please sign in to comment.