diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index 2e4953b8bc..5b6807ef1e 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -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}) diff --git a/test/framework/sandbox/easybuild/easyblocks/t/toy.py b/test/framework/sandbox/easybuild/easyblocks/t/toy.py index 5727dcd0e0..6d6c23caf0 100644 --- a/test/framework/sandbox/easybuild/easyblocks/t/toy.py +++ b/test/framework/sandbox/easybuild/easyblocks/t/toy.py @@ -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.""" @@ -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', '')) 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)