Skip to content

Commit 6f3ff80

Browse files
committed
make sure that specified easyblock can be used to install extensions (should derive from Extension class)
1 parent e2d70bd commit 6f3ff80

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
from easybuild.framework.easyconfig.style import MAX_LINE_LENGTH
6262
from easybuild.framework.easyconfig.tools import get_paths_for
6363
from easybuild.framework.easyconfig.templates import TEMPLATE_NAMES_EASYBLOCK_RUN_STEP, template_constant_dict
64-
from easybuild.framework.extension import resolve_exts_filter_template
64+
from easybuild.framework.extension import Extension, resolve_exts_filter_template
6565
from easybuild.tools import config, run
6666
from easybuild.tools.build_details import get_build_stats
6767
from easybuild.tools.build_log import EasyBuildError, dry_run_msg, dry_run_warning, dry_run_set_dirs
@@ -2317,8 +2317,13 @@ def init_ext_instances(self):
23172317
# with a similar name (e.g., Perl Extension 'GO' vs 'Go' for which 'EB_Go' is available)
23182318
cls = get_easyblock_class(easyblock, name=ext_name, error_on_failed_import=False,
23192319
error_on_missing_easyblock=False)
2320+
23202321
self.log.debug("Obtained class %s for extension %s", cls, ext_name)
23212322
if cls is not None:
2323+
# make sure that this easyblock can be used to install extensions
2324+
if not issubclass(cls, Extension):
2325+
raise EasyBuildError("%s easyblock can not be used to install extensions!", cls.__name__)
2326+
23222327
inst = cls(self, ext)
23232328
except (ImportError, NameError) as err:
23242329
self.log.debug("Failed to use extension-specific class for extension %s: %s", ext_name, err)

test/framework/easyblock.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,18 @@ def test_init_extensions(self):
10171017
]
10181018
self.assertEqual(ext_inst_class_names, expected)
10191019

1020+
# check what happen if we specify an easyblock that doesn't derive from Extension,
1021+
# and hence can't be used to install extensions...
1022+
test_ec = os.path.join(self.test_prefix, 'test_broken.eb')
1023+
test_ec_txt = test_ec_txt.replace('DummyExtension', 'ConfigureMake')
1024+
write_file(test_ec, test_ec_txt)
1025+
ec = process_easyconfig(test_ec)[0]
1026+
eb = get_easyblock_instance(ec)
1027+
1028+
eb.prepare_for_extensions()
1029+
error_pattern = "ConfigureMake easyblock can not be used to install extensions"
1030+
self.assertErrorRegex(EasyBuildError, error_pattern, eb.init_ext_instances)
1031+
10201032
def test_skip_extensions_step(self):
10211033
"""Test the skip_extensions_step"""
10221034

0 commit comments

Comments
 (0)