Skip to content

Commit 050cdb2

Browse files
committed
Fix check_checksums when checksums are specified in JSON file
This requires correctly resolving the templates in `exts_list` sources/patches to be able to fetch them from the JSON file.
1 parent 78a6392 commit 050cdb2

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

easybuild/framework/easyblock.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,19 +2843,9 @@ def check_checksums(self):
28432843
checksum_issues.extend(self.check_checksums_for(self.cfg))
28442844

28452845
# also check checksums for extensions
2846-
with self.cfg.allow_unresolved_templates():
2847-
exts_list = self.cfg['exts_list']
2848-
for ext in exts_list:
2849-
# just skip extensions for which only a name is specified
2850-
# those are just there to check for things that are in the "standard library"
2851-
if not isinstance(ext, str):
2852-
ext_name = ext[0]
2853-
# take into account that extension may be a 2-tuple with just name/version
2854-
ext_opts = ext[2] if len(ext) == 3 else {}
2855-
# only a single source per extension is supported (see source_tmpl)
2856-
source_cnt = 1 if not ext_opts.get('nosource') else 0
2857-
res = self.check_checksums_for(ext_opts, sub="of extension %s" % ext_name, source_cnt=source_cnt)
2858-
checksum_issues.extend(res)
2846+
for ext in self.collect_exts_file_info(fetch_files=False, verify_checksums=False):
2847+
res = self.check_checksums_for(ext, sub=f"of extension {ext['name']}")
2848+
checksum_issues.extend(res)
28592849

28602850
return checksum_issues
28612851

test/framework/easyblock.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
@author: Kenneth Hoste (Ghent University)
3030
@author: Maxime Boissonneault (Compute Canada)
3131
@author: Jan Andre Reuter (Juelich Supercomputing Centre)
32+
@author: Alexander Grund (TU Dresden)
3233
"""
3334
import copy
3435
import fileinput
36+
import itertools
3537
import os
3638
import re
3739
import shutil
@@ -3346,6 +3348,7 @@ def run_checks():
33463348
run_checks()
33473349

33483350
# full check also catches checksum issues with extensions
3351+
eb.json_checksums = {} # Avoid picking up checksums from JSON file
33493352
res = eb.check_checksums()
33503353
self.assertEqual(len(res), 4)
33513354
run_checks()
@@ -3482,6 +3485,12 @@ def run_checks():
34823485
('ext-ok3', version, {
34833486
'nosource': True
34843487
}),
3488+
('ext-ok1', version, {
3489+
'checksums': ['44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc']
3490+
}),
3491+
('ext-ok2', version, {
3492+
'nosource': True
3493+
}),
34853494
]
34863495
""")
34873496
self.writeEC()
@@ -3492,6 +3501,27 @@ def run_checks():
34923501
for ext, line in zip(extensions, res):
34933502
self.assertIn(ext_error_tmpl % ext, line)
34943503

3504+
# Gradually add checksums to JSON dict and test that the associated extension checksums are now fine
3505+
sha256_cs = '81a3accc894592152f81814fbf133d39afad52885ab52c25018722c7bda92487' # Valid format only
3506+
eb.json_checksums = {'ext1-0.0.tar.gz': sha256_cs}
3507+
for ext, line in itertools.zip_longest(extensions[1:], eb.check_checksums(), fillvalue=''):
3508+
self.assertIn(ext_error_tmpl % ext, line)
3509+
eb.json_checksums['ext2.zip'] = sha256_cs
3510+
for ext, line in itertools.zip_longest(extensions[1:], eb.check_checksums(), fillvalue=''):
3511+
self.assertIn(ext_error_tmpl % ext, line)
3512+
eb.json_checksums['ext2.patch'] = sha256_cs
3513+
for ext, line in itertools.zip_longest(extensions[2:], eb.check_checksums(), fillvalue=''):
3514+
self.assertIn(ext_error_tmpl % ext, line)
3515+
eb.json_checksums['ext3.zip'] = sha256_cs
3516+
for ext, line in itertools.zip_longest(extensions[2:], eb.check_checksums(), fillvalue=''):
3517+
self.assertIn(ext_error_tmpl % ext, line)
3518+
eb.json_checksums['ext3.patch'] = sha256_cs
3519+
for ext, line in itertools.zip_longest(extensions[3:], eb.check_checksums(), fillvalue=''):
3520+
self.assertIn(ext_error_tmpl % ext, line)
3521+
eb.json_checksums['ext-uniq_1-3.14.zip'] = sha256_cs
3522+
eb.json_checksums['ext-uniq_1.patch'] = sha256_cs
3523+
self.assertEqual(eb.check_checksums(), [])
3524+
34953525
# more checks for check_checksums_for method, which also takes regular dict as input
34963526
self.assertEqual(eb.check_checksums_for({}), [])
34973527
expected = f"Checksums missing for one or more sources/patches in {os.path.basename(self.eb_file)}: "

0 commit comments

Comments
 (0)