Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reporting when skipping extensions #3254

Merged
merged 5 commits into from
Mar 25, 2020
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
24 changes: 12 additions & 12 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ def prepare_for_extensions(self):
def skip_extensions(self):
"""
Called when self.skip is True
- use this to detect existing extensions and to remove them from self.exts
- use this to detect existing extensions and to remove them from self.ext_instances
- based on initial R version
"""
# obtaining untemplated reference value is required here to support legacy string templates like name/version
Expand All @@ -1482,7 +1482,7 @@ def skip_extensions(self):
self.log.debug("exit code: %s, stdout/err: %s", ec, cmdstdouterr)
res.append(ext_inst)
else:
self.log.info("Skipping %s", ext_inst.name)
print_msg("skipping extension %s" % ext_inst.name, silent=self.silent, log=self.log)

self.ext_instances = res

Expand Down Expand Up @@ -2148,19 +2148,19 @@ def extensions_step(self, fetch=False):
if self.skip:
self.skip_extensions()

exts_cnt = len(self.exts)
for idx, (ext, ext_instance) in enumerate(zip(self.exts, self.ext_instances)):
exts_cnt = len(self.ext_instances)
for idx, ext in enumerate(self.ext_instances):

self.log.debug("Starting extension %s" % ext['name'])
self.log.debug("Starting extension %s" % ext.name)

# always go back to original work dir to avoid running stuff from a dir that no longer exists
change_dir(self.orig_workdir)

tup = (ext['name'], ext.get('version', ''), idx+1, exts_cnt)
tup = (ext.name, ext.version or '', idx+1, exts_cnt)
print_msg("installing extension %s %s (%d/%d)..." % tup, silent=self.silent)

if self.dry_run:
tup = (ext['name'], ext.get('version', ''), cls.__name__)
tup = (ext.name, ext.version, cls.__name__)
msg = "\n* installing extension %s %s using '%s' easyblock\n" % tup
self.dry_run_msg(msg)

Expand All @@ -2173,15 +2173,15 @@ def extensions_step(self, fetch=False):
else:
# don't reload modules for toolchain, there is no need since they will be loaded already;
# the (fake) module for the parent software gets loaded before installing extensions
ext_instance.toolchain.prepare(onlymod=self.cfg['onlytcmod'], silent=True, loadmod=False,
rpath_filter_dirs=self.rpath_filter_dirs)
ext.toolchain.prepare(onlymod=self.cfg['onlytcmod'], silent=True, loadmod=False,
rpath_filter_dirs=self.rpath_filter_dirs)

# real work
ext_instance.prerun()
txt = ext_instance.run()
ext.prerun()
txt = ext.run()
if txt:
self.module_extra_extensions += txt
ext_instance.postrun()
ext.postrun()

# cleanup (unload fake module, remove fake module dir)
if fake_mod_data:
Expand Down
17 changes: 16 additions & 1 deletion test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,6 @@ def test_extensions_step(self):

def test_skip_extensions_step(self):
"""Test the skip_extensions_step"""
init_config(build_options={'silent': True})

self.contents = cleandoc("""
easyblock = "ConfigureMake"
Expand All @@ -835,6 +834,7 @@ def test_skip_extensions_step(self):
"ext1",
("EXT-2", "42", {"source_tmpl": "dummy.tgz"}),
("ext3", "1.1", {"source_tmpl": "dummy.tgz", "modulename": "real_ext"}),
"ext4",
]
exts_filter = ("\
if [ %(ext_name)s == 'ext_2' ] && [ %(ext_version)s == '42' ] && [[ %(src)s == *dummy.tgz ]];\
Expand All @@ -849,7 +849,22 @@ def test_skip_extensions_step(self):
eb.builddir = config.build_path()
eb.installdir = config.install_path()
eb.skip = True

self.mock_stdout(True)
eb.extensions_step(fetch=True)
stdout = self.get_stdout()
self.mock_stdout(False)

patterns = [
r"^== skipping extension EXT-2",
r"^== skipping extension ext3",
r"^== installing extension ext1 \(1/2\)\.\.\.",
r"^== installing extension ext4 \(2/2\)\.\.\.",
]
for pattern in patterns:
regex = re.compile(pattern, re.M)
self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout))

# 'ext1' should be in eb.ext_instances
eb_exts = [x.name for x in eb.ext_instances]
self.assertTrue('ext1' in eb_exts)
Expand Down