tests/emerge: add minimal herds.xml
authorZac Medico <zmedico@gentoo.org>
Sat, 3 Sep 2011 18:05:57 +0000 (11:05 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 3 Sep 2011 18:05:57 +0000 (11:05 -0700)
This will allow src_test to trigger issues like bug #381657.

pym/portage/tests/emerge/test_simple.py
pym/portage/tests/repoman/test_simple.py
pym/portage/tests/resolver/ResolverPlayground.py

index acd97eb36111d0e71ec2abbb0f882b74bb3e54f6..038192e0170dc593a08660eab8d8ac86721cbfb0 100644 (file)
@@ -79,6 +79,23 @@ src_install() {
                        },
                }
 
+               metadata_xml_files = (
+                       (
+                               "dev-libs/A",
+                               {
+                                       "herd" : "base-system",
+                                       "flags" : "<flag name='flag'>Description of how USE='flag' affects this package</flag>",
+                               },
+                       ),
+                       (
+                               "dev-libs/B",
+                               {
+                                       "herd" : "no-herd",
+                                       "flags" : "<flag name='flag'>Description of how USE='flag' affects this package</flag>",
+                               },
+                       ),
+               )
+
                portage_python = portage._python_interpreter
                emerge_cmd = (portage_python, "-Wd",
                        os.path.join(PORTAGE_BIN_PATH, "emerge"))
@@ -176,6 +193,9 @@ src_install() {
                        # non-empty system set keeps --depclean quiet
                        with open(os.path.join(profile_path, "packages"), 'w') as f:
                                f.write("*dev-libs/token-system-pkg")
+                       for cp, xml_data in metadata_xml_files:
+                               with open(os.path.join(portdir, cp, "metadata.xml"), 'w') as f:
+                                       f.write(playground.metadata_xml_template % xml_data)
                        for args in test_commands:
                                proc = subprocess.Popen(args,
                                        env=env, stdout=subprocess.PIPE)
index 35290f6f38caebf42d02154e1ad65a0da172a1ea..27e7d0e6d4f0c0e81f541cb0e46d63eeba02947b 100644 (file)
@@ -69,26 +69,11 @@ class SimpleRepomanTestCase(TestCase):
                licenses = ["GPL-2"]
                arch_list = ["x86"]
                metadata_dtd = os.path.join(PORTAGE_BASE_PATH, "cnf/metadata.dtd")
-               metadata_xml_template = """<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
-<pkgmetadata>
-<herd>%(herd)s</herd>
-<maintainer>
-<email>maintainer-needed@gentoo.org</email>
-<description>Description of the maintainership</description>
-</maintainer>
-<longdescription>Long description of the package</longdescription>
-<use>
-%(flags)s
-</use>
-</pkgmetadata>
-"""
-
                metadata_xml_files = (
                        (
                                "dev-libs/A",
                                {
-                                       "herd" : "no-herd",
+                                       "herd" : "base-system",
                                        "flags" : "<flag name='flag'>Description of how USE='flag' affects this package</flag>",
                                },
                        ),
@@ -153,7 +138,7 @@ class SimpleRepomanTestCase(TestCase):
                                        f.write("%s - %s\n" % (k, v))
                        for cp, xml_data in metadata_xml_files:
                                with open(os.path.join(portdir, cp, "metadata.xml"), 'w') as f:
-                                       f.write(metadata_xml_template % xml_data)
+                                       f.write(playground.metadata_xml_template % xml_data)
                        # repoman checks metadata.dtd for recent CTIME, so copy the file in
                        # order to ensure that the CTIME is current
                        shutil.copyfile(metadata_dtd, os.path.join(distdir, "metadata.dtd"))
index 28567b3d776ef0c4e700c27ab2c955b59761d0c8..67c4e5c53f33912f7be833473e6b05c83c5c7c5c 100644 (file)
@@ -39,6 +39,21 @@ class ResolverPlayground(object):
        config_files = frozenset(("package.use", "package.mask", "package.keywords", \
                "package.unmask", "package.properties", "package.license", "use.mask", "use.force"))
 
+       metadata_xml_template = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>%(herd)s</herd>
+<maintainer>
+<email>maintainer-needed@gentoo.org</email>
+<description>Description of the maintainership</description>
+</maintainer>
+<longdescription>Long description of the package</longdescription>
+<use>
+%(flags)s
+</use>
+</pkgmetadata>
+"""
+
        def __init__(self, ebuilds={}, installed={}, profile={}, repo_configs={}, \
                user_config={}, sets={}, world=[], debug=False):
                """
@@ -311,6 +326,29 @@ class ResolverPlayground(object):
                                os.makedirs(os.path.join(self.eroot, "etc"))
                                os.symlink(sub_profile_dir, os.path.join(self.eroot, "etc", "make.profile"))
 
+                               #Create minimal herds.xml
+                               metadata_dir = os.path.join(repo_dir, "metadata")
+                               os.makedirs(metadata_dir)
+                               herds_xml = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE herds SYSTEM "http://www.gentoo.org/dtd/herds.dtd">
+<?xml-stylesheet href="/xsl/herds.xsl" type="text/xsl" ?>
+<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl" ?>
+<herds>
+<herd>
+  <name>base-system</name>
+  <email>base-system@gentoo.org</email>
+  <description>Core system utilities and libraries.</description>
+  <maintainer>
+    <email>base-system@gentoo.orgg</email>
+    <name>Base System</name>
+    <role>Base System Maintainer</role>
+  </maintainer>
+</herd>
+</herds>
+"""
+                               with open(os.path.join(metadata_dir, "metadata.xml"), 'w') as f:
+                                       f.write(herds_xml)
+
                user_config_dir = os.path.join(self.eroot, "etc", "portage")
 
                try: