Skip to content

Commit 7b7a39f

Browse files
authored
Merge pull request #1 from boegel/checksum_comment
extend enhanced `--inject-checksums` to extensions + enhance test
2 parents 7fc2741 + 0249dbb commit 7b7a39f

16 files changed

Lines changed: 77 additions & 44 deletions

easybuild/framework/easyblock.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
from easybuild.framework.easyconfig.easyconfig import get_module_path, letter_dir_for, resolve_template
5959
from easybuild.framework.easyconfig.format.format import INDENT_4SPACES
6060
from easybuild.framework.easyconfig.parser import fetch_parameters_from_easyconfig
61+
from easybuild.framework.easyconfig.style import MAX_LINE_LENGTH
6162
from easybuild.framework.easyconfig.tools import get_paths_for
6263
from easybuild.framework.easyconfig.templates import TEMPLATE_NAMES_EASYBLOCK_RUN_STEP
6364
from easybuild.tools.build_details import get_build_stats
@@ -2955,9 +2956,11 @@ def inject_checksums(ecs, checksum_type):
29552956
checksum_lines = ['checksums = [']
29562957
for fn, checksum in checksums:
29572958
check_line = "%s'%s', # %s" % (INDENT_4SPACES, checksum, fn)
2958-
if len(check_line) > 120:
2959-
checksum_lines.append("%s# %s" % (INDENT_4SPACES, fn))
2960-
checksum_lines.append("%s'%s'," % (INDENT_4SPACES, checksum))
2959+
if len(check_line) > MAX_LINE_LENGTH:
2960+
checksum_lines.extend([
2961+
"%s# %s" % (INDENT_4SPACES, fn),
2962+
"%s'%s'," % (INDENT_4SPACES, checksum),
2963+
])
29612964
else:
29622965
checksum_lines.append(check_line)
29632966
checksum_lines.append(']\n')
@@ -3050,7 +3053,15 @@ def inject_checksums(ecs, checksum_type):
30503053
else:
30513054
exts_list_lines.append("%s'checksums': [" % (INDENT_4SPACES * 2))
30523055
for fn, checksum in ext_checksums:
3053-
exts_list_lines.append("%s'%s', # %s" % (INDENT_4SPACES * 3, checksum, fn))
3056+
line_indent = INDENT_4SPACES * 3
3057+
ext_checksum_line = "%s'%s', # %s" % (line_indent, checksum, fn)
3058+
if len(ext_checksum_line) > MAX_LINE_LENGTH:
3059+
exts_list_lines.extend([
3060+
"%s# %s" % (line_indent, fn),
3061+
"%s'%s'," % (line_indent, checksum),
3062+
])
3063+
else:
3064+
exts_list_lines.append(ext_checksum_line)
30543065
exts_list_lines.append("%s]," % (INDENT_4SPACES * 2))
30553066

30563067
if ext_options or ext_checksums:

easybuild/framework/easyconfig/style.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
COMMENT_REGEX = re.compile(r'^\s*#')
5454
PARAM_DEF_REGEX = re.compile(r"^(?P<key>[a-z_]+)\s*=\s*")
5555

56+
MAX_LINE_LENGTH = 120
57+
5658

5759
# Any function starting with _eb_check_ (see EB_CHECK variable) will be
5860
# added to the tests if the test number is added to the select list.
@@ -126,7 +128,7 @@ def check_easyconfigs_style(easyconfigs, verbose=False):
126128
options = styleguide.options
127129
# we deviate from standard pep8 and allow 120 chars
128130
# on a line: the default of 79 is too narrow.
129-
options.max_line_length = 120
131+
options.max_line_length = MAX_LINE_LENGTH
130132
# we ignore some tests
131133
# note that W291 has been replaced by our custom W299
132134
options.ignore = (

test/framework/easyblock.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -847,27 +847,28 @@ def test_fetch_patches(self):
847847

848848
eb.fetch_patches()
849849
self.assertEqual(len(eb.patches), 2)
850-
self.assertEqual(eb.patches[0]['name'], 'toy-0.0_typo.patch')
850+
self.assertEqual(eb.patches[0]['name'], 'toy-0.0_fix-silly-typo-in-printf-statement.patch')
851851
self.assertFalse('level' in eb.patches[0])
852852

853853
# reset
854854
eb.patches = []
855855

856+
toy_patch = 'toy-0.0_fix-silly-typo-in-printf-statement.patch'
856857
patches = [
857-
('toy-0.0_typo.patch', 0), # should also be level 0 (not None or something else)
858-
('toy-0.0_typo.patch', 4), # should be level 4
859-
('toy-0.0_typo.patch', 'foobar'), # sourcepath should be set to 'foobar'
858+
(toy_patch, 0), # should also be level 0 (not None or something else)
859+
(toy_patch, 4), # should be level 4
860+
(toy_patch, 'foobar'), # sourcepath should be set to 'foobar'
860861
('toy-0.0.tar.gz', 'some/path'), # copy mode (not a .patch file)
861862
]
862863
# check if patch levels are parsed correctly
863864
eb.fetch_patches(patch_specs=patches)
864865

865866
self.assertEqual(len(eb.patches), 4)
866-
self.assertEqual(eb.patches[0]['name'], 'toy-0.0_typo.patch')
867+
self.assertEqual(eb.patches[0]['name'], toy_patch)
867868
self.assertEqual(eb.patches[0]['level'], 0)
868-
self.assertEqual(eb.patches[1]['name'], 'toy-0.0_typo.patch')
869+
self.assertEqual(eb.patches[1]['name'], toy_patch)
869870
self.assertEqual(eb.patches[1]['level'], 4)
870-
self.assertEqual(eb.patches[2]['name'], 'toy-0.0_typo.patch')
871+
self.assertEqual(eb.patches[2]['name'], toy_patch)
871872
self.assertEqual(eb.patches[2]['sourcepath'], 'foobar')
872873
self.assertEqual(eb.patches[3]['name'], 'toy-0.0.tar.gz'),
873874
self.assertEqual(eb.patches[3]['copy'], 'some/path')
@@ -1061,7 +1062,7 @@ def test_patch_step(self):
10611062
orig_sources = ec['ec']['sources'][:]
10621063

10631064
toy_patches = [
1064-
'toy-0.0_typo.patch', # test for applying patch
1065+
'toy-0.0_fix-silly-typo-in-printf-statement.patch', # test for applying patch
10651066
('toy-extra.txt', 'toy-0.0'), # test for patch-by-copy
10661067
]
10671068
self.assertEqual(ec['ec']['patches'], toy_patches)

test/framework/easyconfig.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def test_exts_list(self):
323323
# SHA256 checksum for source (gzip-1.4.eb)
324324
' "6f281b6d7a3965476324a23b9d80232bd4ffe3967da85e4b7c01d9d81d649a09",',
325325
# SHA256 checksum for 'patch' (toy-0.0.eb)
326-
' "044e300a051120defb01c14c7c06e9aa4bca40c5d589828df360e2684dcc9074",',
326+
' "a79ba0ef5dceb5b8829268247feae8932bed2034c6628ff1d92c84bf45e9a546",',
327327
' ],',
328328
' }),',
329329
']',
@@ -344,7 +344,7 @@ def test_exts_list(self):
344344
self.assertEqual(exts_sources[1]['version'], '2.0')
345345
self.assertEqual(exts_sources[1]['options'], {
346346
'checksums': ['6f281b6d7a3965476324a23b9d80232bd4ffe3967da85e4b7c01d9d81d649a09',
347-
'044e300a051120defb01c14c7c06e9aa4bca40c5d589828df360e2684dcc9074'],
347+
'a79ba0ef5dceb5b8829268247feae8932bed2034c6628ff1d92c84bf45e9a546'],
348348
'patches': ['toy-0.0.eb'],
349349
'source_tmpl': 'gzip-1.4.eb',
350350
'source_urls': [('http://example.com', 'suffix')],
@@ -1349,7 +1349,8 @@ def test_update(self):
13491349

13501350
# for list values: extend
13511351
ec.update('patches', ['foo.patch', 'bar.patch'])
1352-
self.assertEqual(ec['patches'], ['toy-0.0_typo.patch', ('toy-extra.txt', 'toy-0.0'), 'foo.patch', 'bar.patch'])
1352+
toy_patch_fn = 'toy-0.0_fix-silly-typo-in-printf-statement.patch'
1353+
self.assertEqual(ec['patches'], [toy_patch_fn, ('toy-extra.txt', 'toy-0.0'), 'foo.patch', 'bar.patch'])
13531354

13541355
def test_hide_hidden_deps(self):
13551356
"""Test use of --hide-deps on hiddendependencies."""
@@ -2009,7 +2010,8 @@ def test_categorize_files_by_type(self):
20092010
self.assertEqual({'easyconfigs': [], 'files_to_delete': [], 'patch_files': []}, categorize_files_by_type([]))
20102011

20112012
test_ecs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs',)
2012-
toy_patch = os.path.join(os.path.dirname(test_ecs_dir), 'sandbox', 'sources', 'toy', 'toy-0.0_typo.patch')
2013+
toy_patch_fn = 'toy-0.0_fix-silly-typo-in-printf-statement.patch'
2014+
toy_patch = os.path.join(os.path.dirname(test_ecs_dir), 'sandbox', 'sources', 'toy', toy_patch_fn)
20132015
paths = [
20142016
'bzip2-1.0.6.eb',
20152017
os.path.join(test_ecs_dir, 'test_ecs', 'g', 'gzip', 'gzip-1.4.eb'),

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-deps.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ checksums = [[
1717
('sha1', 'f618096c52244539d0e89867405f573fdb0b55b0'),
1818
('size', 273),
1919
]]
20-
patches = ['toy-0.0_typo.patch']
20+
patches = ['toy-0.0_fix-silly-typo-in-printf-statement.patch']
2121

2222
dependencies = [
2323
('ictce', '4.1.13', '', True),

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-gompi-1.3.12-test.eb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ checksums = [[
1818
('sha1', 'f618096c52244539d0e89867405f573fdb0b55b0'),
1919
('size', 273),
2020
]]
21-
patches = ['toy-0.0_typo.patch']
21+
patches = ['toy-0.0_fix-silly-typo-in-printf-statement.patch']
2222

2323
exts_default_options = {
2424
'source_urls': ['http://example.com/%(name)s'],
@@ -30,7 +30,7 @@ exts_list = [
3030
'checksums': ['f3676716b610545a4e8035087f5be0a0248adee0abb3930d3edb76d498ae91e7'], # checksum for
3131
# custom extension filter to verify use of stdin value being passed to filter command
3232
'exts_filter': ("cat | grep '^bar$'", '%(name)s'),
33-
'patches': ['bar-0.0_typo.patch'],
33+
'patches': ['bar-0.0_fix-silly-typo-in-printf-statement.patch'],
3434
'toy_ext_param': "mv anotherbar bar_bis",
3535
'unknowneasyconfigparameterthatshouldbeignored': 'foo',
3636
}),

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-iter.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Toy C program, 100% toy."
88
toolchain = {'name': 'dummy', 'version': 'dummy'}
99

1010
sources = [SOURCE_TAR_GZ]
11-
patches = ['toy-0.0_typo.patch']
11+
patches = ['toy-0.0_fix-silly-typo-in-printf-statement.patch']
1212

1313
buildopts = [
1414
'',

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-multiple.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Toy C program, 100% toy."
99
toolchain = {'name': 'dummy', 'version': 'dummy'}
1010

1111
sources = [SOURCE_TAR_GZ]
12-
patches = ['toy-0.0_typo.patch']
12+
patches = ['toy-0.0_fix-silly-typo-in-printf-statement.patch']
1313
checksums = [
1414
('adler32', '0x998410035'),
1515
'e6785e1a721fc8bf79892e3ef41557c0',

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ checksums = [[
1717
('size', 273),
1818
]]
1919
patches = [
20-
'toy-0.0_typo.patch',
20+
'toy-0.0_fix-silly-typo-in-printf-statement.patch',
2121
('toy-extra.txt', 'toy-0.0'),
2222
]
2323

test/framework/easyconfigs/yeb/toy-0.0.yeb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ checksums: [[
2323
]]
2424

2525
patches: [
26-
'toy-0.0_typo.patch',
26+
'toy-0.0_fix-silly-typo-in-printf-statement.patch',
2727
['toy-extra.txt', 'toy-0.0'],
2828
]
2929

0 commit comments

Comments
 (0)