Skip to content

Commit 87b9659

Browse files
authored
Merge pull request #4405 from Flamefire/fix_inject-checksum-for-ext-tuples
fix `--inject-checksums` when extension specifies patch file in tuple format
2 parents 5ee24a7 + 7f73abf commit 87b9659

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4656,8 +4656,14 @@ def inject_checksums(ecs, checksum_type):
46564656
"""
46574657
def make_list_lines(values, indent_level):
46584658
"""Make lines for list of values."""
4659+
def to_str(s):
4660+
if isinstance(s, string_type):
4661+
return "'%s'" % s
4662+
else:
4663+
return str(s)
4664+
46594665
line_indent = INDENT_4SPACES * indent_level
4660-
return [line_indent + "'%s'," % x for x in values]
4666+
return [line_indent + to_str(x) + ',' for x in values]
46614667

46624668
def make_checksum_lines(checksums, indent_level):
46634669
"""Make lines for list of checksums."""

test/framework/options.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,6 +5948,42 @@ def test_inject_checksums(self):
59485948
]
59495949
self.assertEqual(ec['checksums'], expected_checksums)
59505950

5951+
# Also works for extensions (all 3 patch formats)
5952+
write_file(test_ec, textwrap.dedent("""
5953+
exts_list = [
5954+
("bar", "0.0", {
5955+
'sources': ['bar-0.0-local.tar.gz'],
5956+
'patches': [
5957+
'bar-0.0_fix-silly-typo-in-printf-statement.patch', # normal patch
5958+
('bar-0.0_fix-very-silly-typo-in-printf-statement.patch', 0), # patch with patch level
5959+
('toy-0.0_fix-silly-typo-in-printf-statement.patch', 'toy_subdir'),
5960+
],
5961+
}),
5962+
]
5963+
"""), append=True)
5964+
self._run_mock_eb(args, raise_error=True, strip=True)
5965+
ec = EasyConfigParser(test_ec).get_config_dict()
5966+
ext = ec['exts_list'][0]
5967+
self.assertEqual((ext[0], ext[1]), ("bar", "0.0"))
5968+
ext_opts = ext[2]
5969+
expected_patches = [
5970+
'bar-0.0_fix-silly-typo-in-printf-statement.patch',
5971+
('bar-0.0_fix-very-silly-typo-in-printf-statement.patch', 0),
5972+
('toy-0.0_fix-silly-typo-in-printf-statement.patch', 'toy_subdir')
5973+
]
5974+
self.assertEqual(ext_opts['patches'], expected_patches)
5975+
expected_checksums = [
5976+
{'bar-0.0-local.tar.gz':
5977+
'f3676716b610545a4e8035087f5be0a0248adee0abb3930d3edb76d498ae91e7'},
5978+
{'bar-0.0_fix-silly-typo-in-printf-statement.patch':
5979+
'84db53592e882b5af077976257f9c7537ed971cb2059003fd4faa05d02cae0ab'},
5980+
{'bar-0.0_fix-very-silly-typo-in-printf-statement.patch':
5981+
'd0bf102f9c5878445178c5f49b7cd7546e704c33fe2060c7354b7e473cfeb52b'},
5982+
{'toy-0.0_fix-silly-typo-in-printf-statement.patch':
5983+
'81a3accc894592152f81814fbf133d39afad52885ab52c25018722c7bda92487'}
5984+
]
5985+
self.assertEqual(ext_opts['checksums'], expected_checksums)
5986+
59515987
# passing easyconfig filename as argument to --inject-checksums results in error being reported,
59525988
# because it's not a valid type of checksum
59535989
args = ['--inject-checksums', test_ec]

0 commit comments

Comments
 (0)