diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index af91a5c804..7eb822b9be 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -2347,11 +2347,30 @@ def test_checksum_step(self): self.mock_stderr(False) self.disallow_deprecated_behaviour() - # test without checksums, it should work since they are in checksums.json - toy_ec_json = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0-gompi-2018a-testjson.eb') - toy_checksums_json = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'checksums-test.json') + # create test easyconfig from which checksums have been stripped + test_ec = os.path.join(self.test_prefix, 'test.eb') + ectxt = read_file(toy_ec) + regex = re.compile(r"'?checksums'?\s*[=:]\s*\[[^]]+\].*", re.M) + ectxt = regex.sub('', ectxt) + write_file(test_ec, ectxt) + + ec_json = process_easyconfig(test_ec)[0] + + # make sure that test easyconfig file indeed doesn't contain any checksums (either top-level or for extensions) + self.assertEqual(ec_json['ec']['checksums'], []) + for ext in ec_json['ec']['exts_list']: + if isinstance(ext, string_type): + continue + elif isinstance(ext, tuple): + self.assertEqual(ext[2].get('checksums', []), []) + else: + self.assertTrue(False, "Incorrect extension type: %s" % type(ext)) + + # put checksums.json in place next to easyconfig file being used for the tests + toy_checksums_json = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'checksums.json') copy_file(toy_checksums_json, os.path.join(self.test_prefix, 'checksums.json')) - ec_json = process_easyconfig(toy_ec_json)[0] + + # test without checksums, it should work since they are in checksums.json eb_json = get_easyblock_instance(ec_json) eb_json.fetch_sources() eb_json.checksum_step() @@ -2365,7 +2384,7 @@ def test_checksum_step(self): eb.fetch_sources() eb.checksum_step() - # if we look only at checksums in easyconfig, it should fail + # if we look only at (incorrect) checksums in easyconfig, it should fail eb = get_easyblock_instance(ec) build_options = { 'checksum_priority': config.CHECKSUM_PRIORITY_EASYCONFIG diff --git a/test/framework/easyconfig.py b/test/framework/easyconfig.py index 05ace7b7b6..65c85e634e 100644 --- a/test/framework/easyconfig.py +++ b/test/framework/easyconfig.py @@ -2933,8 +2933,7 @@ def test_find_related_easyconfigs(self): ec['toolchain'] = {'name': 'gompi', 'version': '1.5.16'} ec['versionsuffix'] = '-foobar' res = [os.path.basename(x) for x in find_related_easyconfigs(test_easyconfigs, ec)] - self.assertEqual(res, ['toy-0.0-gompi-2018a.eb', 'toy-0.0-gompi-2018a-testjson.eb', - 'toy-0.0-gompi-2018a-test.eb']) + self.assertEqual(res, ['toy-0.0-gompi-2018a.eb', 'toy-0.0-gompi-2018a-test.eb']) # restore original versionsuffix => matching versionsuffix wins over matching toolchain (name) ec['versionsuffix'] = '-deps' diff --git a/test/framework/easyconfigs/test_ecs/t/toy/checksums-test.json b/test/framework/easyconfigs/test_ecs/t/toy/checksums.json similarity index 100% rename from test/framework/easyconfigs/test_ecs/t/toy/checksums-test.json rename to test/framework/easyconfigs/test_ecs/t/toy/checksums.json diff --git a/test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-gompi-2018a-testjson.eb b/test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-gompi-2018a-testjson.eb deleted file mode 100644 index d41012f40e..0000000000 --- a/test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-gompi-2018a-testjson.eb +++ /dev/null @@ -1,50 +0,0 @@ -name = 'toy' -version = '0.0' -versionsuffix = '-test' - -homepage = 'https://easybuilders.github.io/easybuild' -description = "Toy C program, 100% toy." - -toolchain = {'name': 'gompi', 'version': '2018a'} -toolchainopts = {'pic': True, 'opt': True, 'optarch': True} - -sources = [SOURCE_TAR_GZ] -patches = ['toy-0.0_fix-silly-typo-in-printf-statement.patch'] - -exts_default_options = { - 'source_urls': ['http://example.com/%(name)s'], -} - -exts_list = [ - 'ls', # extension that is part of "standard library" - ('bar', '0.0', { - 'buildopts': " && gcc bar.c -o anotherbar", - # custom extension filter to verify use of stdin value being passed to filter command - 'exts_filter': ("cat | grep '^bar$'", '%(name)s'), - 'patches': [ - 'bar-0.0_fix-silly-typo-in-printf-statement.patch', - 'bar-0.0_fix-very-silly-typo-in-printf-statement.patch', - ], - 'toy_ext_param': "mv anotherbar bar_bis", - 'unknowneasyconfigparameterthatshouldbeignored': 'foo', - # set boolean value (different from default value) to trigger (now fixed) bug with --inject-checksums - # cfr. https://github.com/easybuilders/easybuild-framework/pull/3034 - 'keepsymlinks': True, - }), - ('barbar', '0.0', { - 'start_dir': 'src', - }), - (name, version, { - 'sanity_check_paths': {'files': ['lib/libtoy.a'], 'dirs': []}, - 'exts_filter': ("ls -l lib/libtoy.a", ''), - }), -] - -sanity_check_paths = { - 'files': [('bin/yot', 'bin/toy'), 'bin/bar', 'bin/bar_bis', 'lib/libtoy.a', 'lib/libbar.a'], - 'dirs': [], -} - -postinstallcmds = ["echo TOY > %(installdir)s/README"] - -moduleclass = 'tools' diff --git a/test/framework/filetools.py b/test/framework/filetools.py index 0ccf6b4e56..07d64ad015 100644 --- a/test/framework/filetools.py +++ b/test/framework/filetools.py @@ -2384,7 +2384,7 @@ def test_index_functions(self): # test with specified path with and without trailing '/'s for path in [test_ecs, test_ecs + '/', test_ecs + '//']: index = ft.create_index(path) - self.assertEqual(len(index), 91) + self.assertEqual(len(index), 90) expected = [ os.path.join('b', 'bzip2', 'bzip2-1.0.6-GCC-4.9.2.eb'), @@ -2395,7 +2395,7 @@ def test_index_functions(self): self.assertTrue(fn in index) for fp in index: - self.assertTrue(fp.endswith(('.eb', '.json'))) + self.assertTrue(fp.endswith('.eb') or os.path.basename(fp) == 'checksums.json') # set up some files to create actual index file for ft.copy_dir(os.path.join(test_ecs, 'g'), os.path.join(self.test_prefix, 'g')) diff --git a/test/framework/module_generator.py b/test/framework/module_generator.py index a2b4d0af4b..0adcaa5f5c 100644 --- a/test/framework/module_generator.py +++ b/test/framework/module_generator.py @@ -1105,7 +1105,7 @@ def test_module_naming_scheme(self): ecs_dir = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs') ec_files = [os.path.join(subdir, fil) for (subdir, _, files) in os.walk(ecs_dir) for fil in files] - # keep only .eb files + # keep only easyconfig files (there may be additional files like patches, checksums.json, etc.) ec_files = [x for x in ec_files if x.endswith('.eb')] build_options = { diff --git a/test/framework/options.py b/test/framework/options.py index b541c024ae..ac09573942 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -5903,6 +5903,9 @@ def test_enforce_checksums(self): toy_ec = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0-gompi-2018a-test.eb') test_ec = os.path.join(self.test_prefix, 'test.eb') + # wipe $EASYBUILD_ROBOT_PATHS to avoid that checksums.json for toy is found in test_ecs + del os.environ['EASYBUILD_ROBOT_PATHS'] + args = [ test_ec, '--stop=source',