Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions easybuild/tools/include.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def include_easyblocks(tmpdir, paths):
else:
target_path = os.path.join(easyblocks_dir, filename)

symlink(easyblock_module, target_path)
if not os.path.exists(target_path):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if it exists and points to something else? Can that happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is in a dedicated tmpdir

symlink(easyblock_module, target_path)

included_ebs = [x for x in os.listdir(easyblocks_dir) if x not in ['__init__.py', 'generic']]
included_generic_ebs = [x for x in os.listdir(os.path.join(easyblocks_dir, 'generic')) if x != '__init__.py']
Expand Down Expand Up @@ -204,7 +205,8 @@ def include_module_naming_schemes(tmpdir, paths):
for mns_module in allpaths:
filename = os.path.basename(mns_module)
target_path = os.path.join(mns_dir, filename)
symlink(mns_module, target_path)
if not os.path.exists(target_path):
symlink(mns_module, target_path)

included_mns = [x for x in os.listdir(mns_dir) if x not in ['__init__.py']]
_log.debug("Included module naming schemes: %s", included_mns)
Expand Down Expand Up @@ -244,7 +246,8 @@ def include_toolchains(tmpdir, paths):
else:
target_path = os.path.join(tcs_dir, filename)

symlink(toolchain_module, target_path)
if not os.path.exists(target_path):
symlink(toolchain_module, target_path)

included_toolchains = [x for x in os.listdir(tcs_dir) if x not in ['__init__.py'] + toolchain_subpkgs]
_log.debug("Included toolchains: %s", included_toolchains)
Expand Down
23 changes: 17 additions & 6 deletions test/framework/include.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ def test_include_easyblocks(self):
])
write_file(os.path.join(myeasyblocks, 'generic', 'mybar.py'), mybar_easyblock_txt)

# second myfoo easyblock, should get ignored...
myfoo_bis = os.path.join(self.test_prefix, 'myfoo.py')
write_file(myfoo_bis, '')

# hijack $HOME to test expanding ~ in locations passed to include_easyblocks
os.environ['HOME'] = myeasyblocks

# expand set of known easyblocks with our custom ones
glob_paths = [os.path.join('~', '*'), os.path.join(myeasyblocks, '*/*.py')]
# expand set of known easyblocks with our custom ones;
# myfoo easyblock is included twice, first path should have preference
glob_paths = [os.path.join('~', '*'), os.path.join(myeasyblocks, '*/*.py'), myfoo_bis]
included_easyblocks_path = include_easyblocks(self.test_prefix, glob_paths)

expected_paths = ['__init__.py', 'easyblocks/__init__.py', 'easyblocks/myfoo.py',
Expand Down Expand Up @@ -110,7 +115,7 @@ def test_include_easyblocks_priority(self):
"""Test whether easyblocks included via include_easyblocks() get prioroity over others."""
test_easyblocks = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sandbox', 'easybuild', 'easyblocks')

# make sure that test 'foo' easyblocks is there
# make sure that test 'foo' easyblock is there
import easybuild.easyblocks.foo
foo_path = os.path.dirname(os.path.dirname(easybuild.easyblocks.foo.__file__))
self.assertTrue(os.path.samefile(foo_path, test_easyblocks))
Expand Down Expand Up @@ -159,8 +164,11 @@ def test_include_mns(self):
])
write_file(os.path.join(my_mns, 'my_mns.py'), my_mns_txt)

my_mns_bis = os.path.join(self.test_prefix, 'my_mns.py')
write_file(my_mns_bis, '')

# include custom MNS
included_mns_path = include_module_naming_schemes(self.test_prefix, [os.path.join(my_mns, '*.py')])
included_mns_path = include_module_naming_schemes(self.test_prefix, [os.path.join(my_mns, '*.py'), my_mns_bis])

expected_paths = ['__init__.py', 'tools/__init__.py', 'tools/module_naming_scheme/__init__.py',
'tools/module_naming_scheme/my_mns.py']
Expand Down Expand Up @@ -202,8 +210,11 @@ def test_include_toolchains(self):
])
write_file(os.path.join(my_toolchains, 'compiler', 'my_compiler.py'), my_compiler_txt)

# include custom MNS
glob_paths = [os.path.join(my_toolchains, '*.py'), os.path.join(my_toolchains, '*', '*.py')]
my_tc_bis = os.path.join(self.test_prefix, 'my_tc.py')
write_file(my_tc_bis, '')

# include custom toolchains
glob_paths = [os.path.join(my_toolchains, '*.py'), os.path.join(my_toolchains, '*', '*.py'), my_tc_bis]
included_tcs_path = include_toolchains(self.test_prefix, glob_paths)

expected_paths = ['__init__.py', 'toolchains/__init__.py', 'toolchains/compiler/__init__.py',
Expand Down