Skip to content

Commit 90e7d24

Browse files
committed
Fix check_checksums when nosource: True is used.
Extension might have `nosource: True` set but the code assumes always exactly one source and ignores that parameter. Set `source_cnt = 0` for this case to make the check pass.
1 parent 6e68abe commit 90e7d24

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

easybuild/framework/easyblock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,8 @@ def check_checksums(self):
25762576
# take into account that extension may be a 2-tuple with just name/version
25772577
ext_opts = ext[2] if len(ext) == 3 else {}
25782578
# only a single source per extension is supported (see source_tmpl)
2579-
res = self.check_checksums_for(ext_opts, sub="of extension %s" % ext_name, source_cnt=1)
2579+
source_cnt = 1 if not ext_opts.get('nosource') else 0
2580+
res = self.check_checksums_for(ext_opts, sub="of extension %s" % ext_name, source_cnt=source_cnt)
25802581
checksum_issues.extend(res)
25812582

25822583
return checksum_issues

test/framework/easyconfig.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,10 +4058,10 @@ def test_check_sha256_checksums(self):
40584058
# re-test with right checksum in place
40594059
toy_sha256 = '44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc'
40604060
test_ec_txt = checksums_regex.sub('checksums = ["%s"]' % toy_sha256, toy_ec_txt)
4061-
test_ec_txt = re.sub(r'patches = \[(.|\n)*\]', '', test_ec_txt)
4061+
passing_test_ec_txt = re.sub(r'patches = \[(.|\n)*\]', '', test_ec_txt)
40624062

40634063
test_ec = os.path.join(self.test_prefix, 'toy-0.0-ok.eb')
4064-
write_file(test_ec, test_ec_txt)
4064+
write_file(test_ec, passing_test_ec_txt)
40654065
ecs, _ = parse_easyconfigs([(test_ec, False)])
40664066
ecs = [ec['ec'] for ec in ecs]
40674067

@@ -4097,6 +4097,15 @@ def test_check_sha256_checksums(self):
40974097
regex = re.compile(r"Non-SHA256 checksum\(s\) found for toy-0.0.tar.gz:.*not_really_a_sha256_checksum")
40984098
self.assertTrue(regex.match(res[0]), "Pattern '%s' found in: %s" % (regex.pattern, res[0]))
40994099

4100+
# Extension with nosource: True
4101+
test_ec_txt = passing_test_ec_txt + "exts_list = [('bar', '0.0', { 'nosource': True })]"
4102+
toy_sha256 = '44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc'
4103+
test_ec = os.path.join(self.test_prefix, 'toy-0.0-nosource.eb')
4104+
write_file(test_ec, test_ec_txt)
4105+
ecs, _ = parse_easyconfigs([(test_ec, False)])
4106+
ecs = [ec['ec'] for ec in ecs]
4107+
self.assertEqual(check_sha256_checksums(ecs), [])
4108+
41004109
def test_deprecated(self):
41014110
"""Test use of 'deprecated' easyconfig parameter."""
41024111
topdir = os.path.dirname(os.path.abspath(__file__))

0 commit comments

Comments
 (0)