Skip to content

Commit d50bd3b

Browse files
authored
Merge pull request #26 from boegel/checksums_external
generate test easyconfig without checksums to check whether checksums.json is picked up in test_checksum_step
2 parents 711a21a + bb675e2 commit d50bd3b

File tree

7 files changed

+31
-60
lines changed

7 files changed

+31
-60
lines changed

test/framework/easyblock.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,11 +2347,30 @@ def test_checksum_step(self):
23472347
self.mock_stderr(False)
23482348
self.disallow_deprecated_behaviour()
23492349

2350-
# test without checksums, it should work since they are in checksums.json
2351-
toy_ec_json = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0-gompi-2018a-testjson.eb')
2352-
toy_checksums_json = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'checksums-test.json')
2350+
# create test easyconfig from which checksums have been stripped
2351+
test_ec = os.path.join(self.test_prefix, 'test.eb')
2352+
ectxt = read_file(toy_ec)
2353+
regex = re.compile(r"'?checksums'?\s*[=:]\s*\[[^]]+\].*", re.M)
2354+
ectxt = regex.sub('', ectxt)
2355+
write_file(test_ec, ectxt)
2356+
2357+
ec_json = process_easyconfig(test_ec)[0]
2358+
2359+
# make sure that test easyconfig file indeed doesn't contain any checksums (either top-level or for extensions)
2360+
self.assertEqual(ec_json['ec']['checksums'], [])
2361+
for ext in ec_json['ec']['exts_list']:
2362+
if isinstance(ext, string_type):
2363+
continue
2364+
elif isinstance(ext, tuple):
2365+
self.assertEqual(ext[2].get('checksums', []), [])
2366+
else:
2367+
self.assertTrue(False, "Incorrect extension type: %s" % type(ext))
2368+
2369+
# put checksums.json in place next to easyconfig file being used for the tests
2370+
toy_checksums_json = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'checksums.json')
23532371
copy_file(toy_checksums_json, os.path.join(self.test_prefix, 'checksums.json'))
2354-
ec_json = process_easyconfig(toy_ec_json)[0]
2372+
2373+
# test without checksums, it should work since they are in checksums.json
23552374
eb_json = get_easyblock_instance(ec_json)
23562375
eb_json.fetch_sources()
23572376
eb_json.checksum_step()
@@ -2365,7 +2384,7 @@ def test_checksum_step(self):
23652384
eb.fetch_sources()
23662385
eb.checksum_step()
23672386

2368-
# if we look only at checksums in easyconfig, it should fail
2387+
# if we look only at (incorrect) checksums in easyconfig, it should fail
23692388
eb = get_easyblock_instance(ec)
23702389
build_options = {
23712390
'checksum_priority': config.CHECKSUM_PRIORITY_EASYCONFIG

test/framework/easyconfig.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,8 +2933,7 @@ def test_find_related_easyconfigs(self):
29332933
ec['toolchain'] = {'name': 'gompi', 'version': '1.5.16'}
29342934
ec['versionsuffix'] = '-foobar'
29352935
res = [os.path.basename(x) for x in find_related_easyconfigs(test_easyconfigs, ec)]
2936-
self.assertEqual(res, ['toy-0.0-gompi-2018a.eb', 'toy-0.0-gompi-2018a-testjson.eb',
2937-
'toy-0.0-gompi-2018a-test.eb'])
2936+
self.assertEqual(res, ['toy-0.0-gompi-2018a.eb', 'toy-0.0-gompi-2018a-test.eb'])
29382937

29392938
# restore original versionsuffix => matching versionsuffix wins over matching toolchain (name)
29402939
ec['versionsuffix'] = '-deps'

test/framework/easyconfigs/test_ecs/t/toy/checksums-test.json renamed to test/framework/easyconfigs/test_ecs/t/toy/checksums.json

File renamed without changes.

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-gompi-2018a-testjson.eb

Lines changed: 0 additions & 50 deletions
This file was deleted.

test/framework/filetools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ def test_index_functions(self):
23842384
# test with specified path with and without trailing '/'s
23852385
for path in [test_ecs, test_ecs + '/', test_ecs + '//']:
23862386
index = ft.create_index(path)
2387-
self.assertEqual(len(index), 91)
2387+
self.assertEqual(len(index), 90)
23882388

23892389
expected = [
23902390
os.path.join('b', 'bzip2', 'bzip2-1.0.6-GCC-4.9.2.eb'),
@@ -2395,7 +2395,7 @@ def test_index_functions(self):
23952395
self.assertTrue(fn in index)
23962396

23972397
for fp in index:
2398-
self.assertTrue(fp.endswith(('.eb', '.json')))
2398+
self.assertTrue(fp.endswith('.eb') or os.path.basename(fp) == 'checksums.json')
23992399

24002400
# set up some files to create actual index file for
24012401
ft.copy_dir(os.path.join(test_ecs, 'g'), os.path.join(self.test_prefix, 'g'))

test/framework/module_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ def test_module_naming_scheme(self):
11051105

11061106
ecs_dir = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs')
11071107
ec_files = [os.path.join(subdir, fil) for (subdir, _, files) in os.walk(ecs_dir) for fil in files]
1108-
# keep only .eb files
1108+
# keep only easyconfig files (there may be additional files like patches, checksums.json, etc.)
11091109
ec_files = [x for x in ec_files if x.endswith('.eb')]
11101110

11111111
build_options = {

test/framework/options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5903,6 +5903,9 @@ def test_enforce_checksums(self):
59035903
toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0-gompi-2018a-test.eb')
59045904
test_ec = os.path.join(self.test_prefix, 'test.eb')
59055905

5906+
# wipe $EASYBUILD_ROBOT_PATHS to avoid that checksums.json for toy is found in test_ecs
5907+
del os.environ['EASYBUILD_ROBOT_PATHS']
5908+
59065909
args = [
59075910
test_ec,
59085911
'--stop=source',

0 commit comments

Comments
 (0)