From ce1cf5760e16488f6454c7d3d7cb26ef7ba993e9 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 9 Feb 2023 16:35:21 +0100 Subject: [PATCH] Combine errors of extension patch check into a single failure Avoids repeated test runs by showing all errors at once. --- test/easyconfigs/easyconfigs.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/easyconfigs/easyconfigs.py b/test/easyconfigs/easyconfigs.py index 42a55a77d00..276613742dc 100644 --- a/test/easyconfigs/easyconfigs.py +++ b/test/easyconfigs/easyconfigs.py @@ -1389,6 +1389,7 @@ def template_easyconfig_test(self, spec): self.assertTrue(isinstance(ext[2], dict), "3rd element of extension spec for %s must be a dictionary" % ext_name) + ext_patch_issues = [] # After the sanity check above, use collect_exts_file_info to resolve templates etc. correctly for ext in app.collect_exts_file_info(fetch_files=False, verify_checksums=False): try: @@ -1407,16 +1408,18 @@ def template_easyconfig_test(self, spec): # only check actual patch files, not other files being copied via the patch functionality ext_patch_full = os.path.join(specdir, ext_patch['name']) - if ext_patch_full.endswith('.patch'): - msg = "Patch file %s is available for %s" % (ext_patch_full, specfn) - self.assertTrue(os.path.isfile(ext_patch_full), msg) + if ext_patch_full.endswith('.patch') and not os.path.isfile(ext_patch_full): + ext_patch_issues.append("Patch file %s for extension %s is missing." % (ext_patch['name'], ext_name)) + continue # verify checksum for each patch file - if idx < len(patch_checksums) and (os.path.exists(ext_patch_full) or ext_patch.endswith('.patch')): + if idx < len(patch_checksums) and os.path.exists(ext_patch_full): checksum = patch_checksums[idx] - error_msg = "Invalid checksum for patch %s for %s extension in %s: %s" - res = verify_checksum(ext_patch_full, checksum) - self.assertTrue(res, error_msg % (ext_patch, ext_name, ec_fn, checksum)) + if not verify_checksum(ext_patch_full, checksum): + ext_patch_issues.append("Invalid checksum for patch %s for extension %s: %s." + % (ext_patch['name'], ext_name, checksum)) + if ext_patch_issues: + self.fail("Verification of patches for %s failed:\n%s" % (ec_fn, '\n'.join(ext_patch_issues))) # check whether all extra_options defined for used easyblock are defined extra_opts = app.extra_options()