From f41ef2864c3bdc59fd2154a353ee47517cbd3eba Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 4 Dec 2024 15:09:16 +0100 Subject: [PATCH] trivial code style changes in EasyConfig.validate + tweaks in tests for skipsteps and --stop --- easybuild/framework/easyconfig/easyconfig.py | 11 ++++++----- test/framework/options.py | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/easybuild/framework/easyconfig/easyconfig.py b/easybuild/framework/easyconfig/easyconfig.py index 85a7d5d9ae..ff6b307a6e 100644 --- a/easybuild/framework/easyconfig/easyconfig.py +++ b/easybuild/framework/easyconfig/easyconfig.py @@ -72,7 +72,7 @@ from easybuild.tools.filetools import convert_name, copy_file, create_index, decode_class_name, encode_class_name from easybuild.tools.filetools import find_backup_name_candidate, find_easyconfigs, load_index from easybuild.tools.filetools import read_file, write_file -from easybuild.tools.hooks import STEP_NAMES, PARSE, load_hooks, run_hook +from easybuild.tools.hooks import PARSE, STEP_NAMES, load_hooks, run_hook from easybuild.tools.module_naming_scheme.mns import DEVEL_MODULE_SUFFIX from easybuild.tools.module_naming_scheme.utilities import avail_module_naming_schemes, det_full_ec_version from easybuild.tools.module_naming_scheme.utilities import det_hidden_modname, is_valid_module_name @@ -866,13 +866,14 @@ def validate(self, check_osdeps=True): type(skipsteps), skipsteps) unknown_step_names = [step for step in skipsteps if step not in STEP_NAMES] if unknown_step_names: - error_lines = ["Found one or more unknown step names in skipsteps:"] + error_lines = ["Found one or more unknown step names in 'skipsteps' easyconfig parameter:"] for step in unknown_step_names: - error_lines.append("* %s" % step) - # try to find close match, may be just a typo in the hook name + error_line = "* %s" % step + # try to find close match, may be just a typo in the step name close_matches = difflib.get_close_matches(step, STEP_NAMES, 2, 0.8) if close_matches: - error_lines[-1] += " (did you mean %s?)" % ', or '.join("'%s'" % s for s in close_matches) + error_line += " (did you mean %s?)" % ', or '.join("'%s'" % s for s in close_matches) + error_lines.append(error_line) raise EasyBuildError('\n'.join(error_lines)) self.log.info("Checking build option lists") diff --git a/test/framework/options.py b/test/framework/options.py index 756dc774ec..4671cbb809 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -404,16 +404,24 @@ def test_skipsteps(self): # Verify a wrong step name is caught test_ec_txt += "\nskipsteps = ['wrong-step-name']\n" write_file(test_ec, test_ec_txt) - self.assertErrorRegex(EasyBuildError, 'wrong-step-name', self.eb_main, args, do_build=True, raise_error=True) - test_ec_txt += "\nskipsteps = ['source']\n" # Especially the old name -> Replaced by extract + error_pattern = "Found one or more unknown step names in 'skipsteps' easyconfig parameter:\n" + error_pattern += r"\* wrong-step-name" + self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True) + # 'source' step was renamed to 'extract' in EasyBuild 5.0, + # see https://github.com/easybuilders/easybuild-framework/pull/4629 + test_ec_txt += "\nskipsteps = ['source']\n" write_file(test_ec, test_ec_txt) - self.assertErrorRegex(EasyBuildError, 'source', self.eb_main, args, do_build=True, raise_error=True) + error_pattern = error_pattern.replace('wrong-step-name', 'source') + self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True) # check use of skipsteps to skip sanity check test_ec_txt += "\nskipsteps = ['sanitycheck']\n" write_file(test_ec, test_ec_txt) self.mocked_main(args, do_build=True, raise_error=True) + toy_mod_glob = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '*') + self.assertEqual(len(glob.glob(toy_mod_glob)), 1) + def test_skip_test_step(self): """Test skipping testing the build (--skip-test-step).""" @@ -5509,9 +5517,11 @@ def test_stop(self): regex = re.compile(r"COMPLETED: Installation STOPPED successfully \(took .* secs?\)", re.M) self.assertTrue(regex.search(txt), "Pattern '%s' found in: %s" % (regex.pattern, txt)) + # 'source' step was renamed to 'extract' in EasyBuild 5.0, + # see https://github.com/easybuilders/easybuild-framework/pull/4629 args = ['toy-0.0.eb', '--force', '--stop=source'] _, stderr = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False, strip=True) - self.assertIn("option --stop: invalid choice", stderr) + self.assertIn("option --stop: invalid choice: 'source' (choose from", stderr) def test_fetch(self): options = EasyBuildOptions(go_args=['--fetch'])