From e4fbb9bdd4a42491a7fd99442081c322843d97a7 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 23 Oct 2023 12:46:08 +0200 Subject: [PATCH] Factor out setting name of EC in failing Python checks --- test/easyconfigs/easyconfigs.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/test/easyconfigs/easyconfigs.py b/test/easyconfigs/easyconfigs.py index c0df6ab8a3d..dd000c7bb2b 100644 --- a/test/easyconfigs/easyconfigs.py +++ b/test/easyconfigs/easyconfigs.py @@ -1167,6 +1167,7 @@ def test_pr_python_packages(self): python_default_urls = PythonPackage.extra_options()['source_urls'][0] for ec in self.changed_ecs: + failing_checks_ec = [] with ec.disable_templating(): ec_fn = os.path.basename(ec.path) @@ -1186,23 +1187,22 @@ def test_pr_python_packages(self): # download_dep_fail should be set when using PythonPackage if easyblock == 'PythonPackage': if download_dep_fail is None: - failing_checks.append("'download_dep_fail' should be set in %s" % ec_fn) + failing_checks_ec.append("'download_dep_fail' should be set") if pure_ec.get('source_urls') == python_default_urls: - failing_checks.append("'source_urls' should not be defined when using the default value " - "in %s" % ec_fn) + failing_checks_ec.append("'source_urls' should not be defined when using the default value") # use_pip should be set when using PythonPackage or PythonBundle, # or an easyblock that derives from it (except for whitelisted easyconfigs) if easyblock in ['CargoPythonBundle', 'CargoPythonPackage', 'PythonBundle', 'PythonPackage']: if use_pip is None and not any(re.match(regex, ec_fn) for regex in whitelist_pip): - failing_checks.append("'use_pip' should be set in %s" % ec_fn) + failing_checks_ec.append("'use_pip' should be set") if exts_defaultclass == 'PythonPackage': # bundle of Python packages should use PythonBundle if easyblock == 'Bundle': - fail = "'PythonBundle' easyblock should be used for bundle of Python packages in %s" % ec_fn - failing_checks.append(fail) + fail = "'PythonBundle' easyblock should be used for bundle of Python packages" + failing_checks_ec.append(fail) # if Python is a dependency, that should be reflected in the versionsuffix since v3.8.6 has_recent_python3_dep = any(LooseVersion(dep['version']) >= LooseVersion('3.8.6') @@ -1224,30 +1224,30 @@ def test_pr_python_packages(self): if ec.name in exception_python_suffix or whitelisted: pass elif has_old_python_dep and not re.search(r'-Python-[23]\.[0-9]+\.[0-9]+', ec['versionsuffix']): - msg = "'-Python-%%(pyver)s' should be included in versionsuffix in %s" % ec_fn + msg = "'-Python-%(pyver)s' should be included in versionsuffix" # This is only a failure for newly added ECs, not for existing ECS # As that would probably break many ECs if ec_fn in self.added_ecs_filenames: - failing_checks.append(msg) + failing_checks_ec.append(msg) else: - print('\nNote: Failed non-critical check: ' + msg) + print('\nNote: Failed non-critical check for %s: %s' % (ec_fn, msg)) elif has_recent_python3_dep and re.search(r'-Python-3\.[0-9]+\.[0-9]+', ec['versionsuffix']): - msg = "'-Python-%%(pyver)s' should no longer be included in versionsuffix in %s" % ec_fn - failing_checks.append(msg) + msg = "'-Python-%(pyver)s' should no longer be included in versionsuffix" + failing_checks_ec.append(msg) # require that running of "pip check" during sanity check is enabled via sanity_pip_check if easyblock in ['CargoPythonBundle', 'CargoPythonPackage', 'PythonBundle', 'PythonPackage']: sanity_pip_check = ec.get('sanity_pip_check') or exts_default_options.get('sanity_pip_check') if not sanity_pip_check and not any(re.match(regex, ec_fn) for regex in whitelist_pip_check): - failing_checks.append("sanity_pip_check should be enabled in %s" % ec_fn) + failing_checks_ec.append("sanity_pip_check should be enabled") # Avoid duplicated PYTHONPATH entries and checks (set by the easyblock) if easyblock == 'PythonBundle' or easyblock.endswith('PythonPackage'): extra_python_path = ec.get('modextrapaths', dict()).get('PYTHONPATH') regex = r'lib/python(%\(pyshortver\)s|\d\.\d+)/site-packages' if re.match(regex, extra_python_path): - failing_checks.append("modextrapaths contains superflous '%s' " - "(automatically added by easyblock)" % extra_python_path) + failing_checks_ec.append("modextrapaths contains superflous '%s' " + "(automatically added by easyblock)" % extra_python_path) sanity_check_dirs = ec.get('sanity_check_paths', dict()).get('dirs') or [] default_dirs = ( r'lib(64)?/python(%\(pyshortver\)s|\d\.\d+)/site-packages', @@ -1255,8 +1255,9 @@ def test_pr_python_packages(self): ) entries = [d for d in sanity_check_dirs if any(re.match(dir_regex, d) for dir_regex in default_dirs)] if entries: - failing_checks.append("sanity_check_paths['dirs'] contains superflous %s " - "(automatically added by easyblock)" % entries) + failing_checks_ec.append("sanity_check_paths['dirs'] contains superflous %s " + "(automatically added by easyblock)" % entries) + failing_checks.extend(ec_fn + ': ' + fail for fail in failing_checks_ec) if failing_checks: self.fail('\n'.join(failing_checks))