From 6c5b8bff57ee7c09544889194c545bb1482e32dd Mon Sep 17 00:00:00 2001 From: Simon Branford Date: Sat, 12 Aug 2023 10:32:59 +0100 Subject: [PATCH 1/2] add build_info_msg easyconfig parameter --- easybuild/framework/easyblock.py | 4 ++++ easybuild/framework/easyconfig/default.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index c85104d687..55d73d3ba5 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -4174,6 +4174,10 @@ def build_and_install_one(ecdict, init_env): dry_run_msg('', silent=silent) print_msg("processing EasyBuild easyconfig %s" % spec, log=_log, silent=silent) + if ecdict['ec']['build_info_msg']: + msg = "This easyconfig provides the following build information:\n\n%s\n" + print_msg(msg % ecdict['ec']['build_info_msg'], log=_log, silent=silent) + if dry_run: # print note on interpreting dry run output (argument is reference to location of dry run messages) print_dry_run_note('below', silent=silent) diff --git a/easybuild/framework/easyconfig/default.py b/easybuild/framework/easyconfig/default.py index b37c3660f0..dd91229d1e 100644 --- a/easybuild/framework/easyconfig/default.py +++ b/easybuild/framework/easyconfig/default.py @@ -228,6 +228,8 @@ 'buildstats': [None, "A list of dicts with build statistics", OTHER], 'deprecated': [False, "String specifying reason why this easyconfig file is deprecated " "and will be archived in the next major release of EasyBuild", OTHER], + 'build_info_msg': [None, "String with information to be printed to stdout and logged during the building " + "of the easyconfig", OTHER], } From c48615e5a05662e018216266d91f04c4b0df074c Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 12 Aug 2023 19:26:45 +0200 Subject: [PATCH 2/2] add test to check whether build_info_msg works as expected --- test/framework/toy_build.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index 52aa18aae9..40e967fcf0 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -3900,6 +3900,30 @@ def test_toy_post_install_messages(self): regex = re.compile(pattern, re.M) self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout)) + def test_toy_build_info_msg(self): + """ + Test use of build info message + """ + test_ecs = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs') + toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb') + + test_ec_txt = read_file(toy_ec) + test_ec_txt += '\nbuild_info_msg = "Are you sure you want to install this toy software?"' + test_ec = os.path.join(self.test_prefix, 'test.eb') + write_file(test_ec, test_ec_txt) + + with self.mocked_stdout_stderr(): + self.test_toy_build(ec_file=test_ec, testing=False, verify=False, raise_error=True) + stdout = self.get_stdout() + + pattern = '\n'.join([ + r"== This easyconfig provides the following build information:", + r'', + r"Are you sure you want to install this toy software\?", + ]) + regex = re.compile(pattern, re.M) + self.assertTrue(regex.search(stdout), "Pattern '%s' should be found in: %s" % (regex.pattern, stdout)) + def suite(): """ return all the tests in this file """