Skip to content

Commit

Permalink
Add tests for post_processing_step
Browse files Browse the repository at this point in the history
(includes deprecated post_install_step)
  • Loading branch information
bartoldeman committed Dec 4, 2024
1 parent bbc0862 commit 4770fc5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,32 @@ def test_handle_iterate_opts(self):
self.assertEqual(eb.cfg.iterating, False)
self.assertEqual(eb.cfg['configopts'], ["--opt1 --anotheropt", "--opt2", "--opt3 --optbis"])

def test_post_processing_step(self):
"""Test post_processing_step and deprecated post_install_step."""
init_config(build_options={'silent': True})

test_ecs_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')
toy_ec_fn = os.path.join(test_ecs_dir, 't', 'toy', 'toy-0.0-gompi-2018a-test.eb')

# this import only works here, since EB_toy is a test easyblock
from easybuild.easyblocks.toy import EB_toy, EB_toy_deprecated

cwd = os.getcwd()
toy_ec = EasyConfig(toy_ec_fn)
eb = EB_toy_deprecated(toy_ec)
eb.silent = True
expected_error = r"DEPRECATED \(since v6.0\).*use EasyBlock.post_processing_step\(\) instead.*"
with self.mocked_stdout_stderr():
self.assertErrorRegex(EasyBuildError, expected_error, eb.run_all_steps, True)

change_dir(cwd)
toy_ec = EasyConfig(toy_ec_fn)
eb = EB_toy(toy_ec)
eb.silent = True
with self.mocked_stdout_stderr():
eb.run_all_steps(True)
assert os.path.exists(os.path.join(eb.installdir, 'lib', 'libtoy_post.a'))

def test_extensions_step(self):
"""Test the extensions_step"""
init_config(build_options={'silent': True})
Expand Down
14 changes: 14 additions & 0 deletions test/framework/sandbox/easybuild/easyblocks/t/toy.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def install_step(self, name=None):
mkdir(libdir, parents=True)
write_file(os.path.join(libdir, 'lib%s.a' % name), name.upper())

def post_processing_step(self):
"""Any postprocessing for toy"""
libdir = os.path.join(self.installdir, 'lib')
write_file(os.path.join(libdir, 'lib%s_post.a' % self.name), self.name.upper())
super(EB_toy, self).post_processing_step()

@property
def required_deps(self):
"""Return list of required dependencies for this extension."""
Expand Down Expand Up @@ -192,3 +198,11 @@ def make_module_extra(self):
txt = super(EB_toy, self).make_module_extra()
txt += self.module_generator.set_environment('TOY', os.getenv('TOY', '<TOY_env_var_not_defined>'))
return txt


class EB_toy_deprecated(EB_toy):
"""Support for building/installing toy with deprecated post_install step."""

def post_install_step(self):
"""Any postprocessing for toy (deprecated)"""
super(EB_toy, self).post_install_step(*arg)

0 comments on commit 4770fc5

Please sign in to comment.