From 44f2b8f9603964abe230cfe8ef75831a82855da5 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 24 Nov 2012 13:28:44 +0100 Subject: EAPI="5-progress": Add automatic unpack dependencies. --- pym/portage/tests/resolver/ResolverPlayground.py | 7 ++- .../tests/resolver/test_unpack_dependencies.py | 65 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 pym/portage/tests/resolver/test_unpack_dependencies.py (limited to 'pym/portage/tests') diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index 9b30edbee..f81e046c1 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -2,6 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 from itertools import permutations +import fnmatch import sys import tempfile import portage @@ -37,7 +38,7 @@ class ResolverPlayground(object): config_files = frozenset(("eapi", "layout.conf", "make.conf", "package.accept_keywords", "package.keywords", "package.license", "package.mask", "package.properties", "package.unmask", "package.use", "package.use.aliases", "package.use.stable.mask", - "use.aliases", "use.force", "use.mask", "layout.conf")) + "unpack_dependencies", "use.aliases", "use.force", "use.mask", "layout.conf")) metadata_xml_template = """ @@ -282,13 +283,15 @@ class ResolverPlayground(object): repo_config = repo_configs.get(repo) if repo_config: for config_file, lines in repo_config.items(): - if config_file not in self.config_files: + if config_file not in self.config_files and not any(fnmatch.fnmatch(config_file, os.path.join(x, "*")) for x in self.config_files): raise ValueError("Unknown config file: '%s'" % config_file) if config_file in ("layout.conf",): file_name = os.path.join(repo_dir, "metadata", config_file) else: file_name = os.path.join(profile_dir, config_file) + if "/" in config_file and not os.path.isdir(os.path.dirname(file_name)): + os.makedirs(os.path.dirname(file_name)) f = open(file_name, "w") for line in lines: f.write("%s\n" % line) diff --git a/pym/portage/tests/resolver/test_unpack_dependencies.py b/pym/portage/tests/resolver/test_unpack_dependencies.py new file mode 100644 index 000000000..cfceff4b1 --- /dev/null +++ b/pym/portage/tests/resolver/test_unpack_dependencies.py @@ -0,0 +1,65 @@ +# Copyright 2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage.tests import TestCase +from portage.tests.resolver.ResolverPlayground import ResolverPlayground, ResolverPlaygroundTestCase + +class UnpackDependenciesTestCase(TestCase): + def testUnpackDependencies(self): + distfiles = { + "A-1.tar.gz": b"binary\0content", + "B-1.TAR.XZ": b"binary\0content", + "B-docs-1.tar.bz2": b"binary\0content", + "C-1.TAR.XZ": b"binary\0content", + "C-docs-1.tar.bz2": b"binary\0content", + } + + ebuilds = { + "dev-libs/A-1": {"SRC_URI": "A-1.tar.gz", "EAPI": "5-progress"}, + "dev-libs/B-1": {"IUSE": "doc", "SRC_URI": "B-1.TAR.XZ doc? ( B-docs-1.tar.bz2 )", "EAPI": "5-progress"}, + "dev-libs/C-1": {"IUSE": "doc", "SRC_URI": "C-1.TAR.XZ doc? ( C-docs-1.tar.bz2 )", "EAPI": "5-progress"}, + "app-arch/bzip2-1": {}, + "app-arch/gzip-1": {}, + "app-arch/tar-1": {}, + "app-arch/xz-utils-1": {}, + } + + repo_configs = { + "test_repo": { + "unpack_dependencies/5-progress": ( + "tar.bz2 app-arch/tar app-arch/bzip2", + "tar.gz app-arch/tar app-arch/gzip", + "tar.xz app-arch/tar app-arch/xz-utils", + ), + }, + } + + test_cases = ( + ResolverPlaygroundTestCase( + ["dev-libs/A"], + success = True, + ignore_mergelist_order = True, + mergelist = ["app-arch/tar-1", "app-arch/gzip-1", "dev-libs/A-1"]), + ResolverPlaygroundTestCase( + ["dev-libs/B"], + success = True, + ignore_mergelist_order = True, + mergelist = ["app-arch/tar-1", "app-arch/xz-utils-1", "dev-libs/B-1"]), + ResolverPlaygroundTestCase( + ["dev-libs/C"], + success = True, + ignore_mergelist_order = True, + mergelist = ["app-arch/tar-1", "app-arch/xz-utils-1", "app-arch/bzip2-1", "dev-libs/C-1"]), + ) + + user_config = { + "package.use": ("dev-libs/C doc",) + } + + playground = ResolverPlayground(distfiles=distfiles, ebuilds=ebuilds, repo_configs=repo_configs, user_config=user_config) + try: + for test_case in test_cases: + playground.run_TestCase(test_case) + self.assertEqual(test_case.test_success, True, test_case.fail_msg) + finally: + playground.cleanup() -- cgit v1.2.3-1-g7c22