diff --git a/easybuild/framework/easyconfig/tools.py b/easybuild/framework/easyconfig/tools.py index e3a93d652a..0deea2453b 100644 --- a/easybuild/framework/easyconfig/tools.py +++ b/easybuild/framework/easyconfig/tools.py @@ -404,9 +404,15 @@ def parse_easyconfigs(paths, validate=True): """ easyconfigs = [] generated_ecs = False + parsed_paths = [] for (path, generated) in paths: + # Avoid processing the same file multiple times path = os.path.abspath(path) + if any(os.path.samefile(path, p) for p in parsed_paths): + continue + parsed_paths.append(path) + # keep track of whether any files were generated generated_ecs |= generated if not os.path.exists(path): diff --git a/test/framework/easyconfig.py b/test/framework/easyconfig.py index 09801bde50..2b165a10ba 100644 --- a/test/framework/easyconfig.py +++ b/test/framework/easyconfig.py @@ -737,6 +737,32 @@ def test_tweaking(self): # cleanup os.remove(tweaked_fn) + def test_parse_easyconfig(self): + """Test parse_easyconfig function""" + self.contents = textwrap.dedent(""" + easyblock = "ConfigureMake" + name = "PI" + version = "3.14" + homepage = "http://example.com" + description = "test easyconfig" + toolchain = SYSTEM + """) + self.prep() + ecs, gen_ecs = parse_easyconfigs([(self.eb_file, False)]) + self.assertEqual(len(ecs), 1) + self.assertEqual(ecs[0]['spec'], self.eb_file) + self.assertIsInstance(ecs[0]['ec'], EasyConfig) + self.assertFalse(gen_ecs) + # Passing the same EC multiple times is ignored + ecs, gen_ecs = parse_easyconfigs([(self.eb_file, False), (self.eb_file, False)]) + self.assertEqual(len(ecs), 1) + # Similar for symlinks + linked_ec = os.path.join(self.test_prefix, 'linked.eb') + os.symlink(self.eb_file, linked_ec) + ecs, gen_ecs = parse_easyconfigs([(self.eb_file, False), (linked_ec, False)]) + self.assertEqual(len(ecs), 1) + self.assertEqual(ecs[0]['spec'], self.eb_file) + def test_alt_easyconfig_paths(self): """Test alt_easyconfig_paths function that collects list of additional paths for easyconfig files."""