aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-08-16 15:08:38 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2008-08-16 21:43:32 +0100
commit6054ceaa64a6d5ec81f1558c0e90b77ae6907bb0 (patch)
treea6b2e5bb101773c1ea0b60978e81a9c67f34cd91
parent767fb3805f9629ebc36888a35023eda943089819 (diff)
downloadpaludis-6054ceaa64a6d5ec81f1558c0e90b77ae6907bb0.tar.gz
paludis-6054ceaa64a6d5ec81f1558c0e90b77ae6907bb0.tar.xz
Test cases for new cache handling.
-rw-r--r--paludis/repositories/e/Makefile.am20
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc87
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh97
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc1091
-rwxr-xr-xpaludis/repositories/e/ebuild_flat_metadata_cache_TEST_cleanup.sh10
-rwxr-xr-xpaludis/repositories/e/ebuild_flat_metadata_cache_TEST_setup.sh1045
6 files changed, 2166 insertions, 184 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 16d2a4b..e7b8d92 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -297,6 +297,20 @@ fix_locked_dependencies_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
+ebuild_flat_metadata_cache_TEST_SOURCES = ebuild_flat_metadata_cache_TEST.cc
+
+ebuild_flat_metadata_cache_TEST_LDADD = \
+ libpaludiserepository_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/test/libtest.a \
+ $(DYNAMIC_LD_LIBS)
+
+ebuild_flat_metadata_cache_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)
+
EXTRA_DIST = \
aa_visitor_TEST.cc \
dep_parser.se \
@@ -322,6 +336,9 @@ EXTRA_DIST = \
e_repository_sets_TEST.cc \
e_repository_sets_TEST_setup.sh \
e_repository_sets_TEST_cleanup.sh \
+ ebuild_flat_metadata_cache_TEST.cc \
+ ebuild_flat_metadata_cache_TEST_setup.sh \
+ ebuild_flat_metadata_cache_TEST_cleanup.sh \
exndbam_repository_TEST.cc \
exndbam_repository_TEST_setup.sh \
exndbam_repository_TEST_cleanup.sh \
@@ -492,7 +509,8 @@ TESTS = \
source_uri_finder_TEST \
exndbam_repository_TEST \
vdb_repository_TEST \
- fix_locked_dependencies_TEST
+ fix_locked_dependencies_TEST \
+ ebuild_flat_metadata_cache_TEST
check_PROGRAMS = $(TESTS)
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 7aff2c0..a26cf96 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -429,36 +429,6 @@ namespace test_cases
}
} test_e_repository_duff_versions;
- struct ERepositoryMetadataCachedTest : TestCase
- {
- ERepositoryMetadataCachedTest() : TestCase("metadata cached") { }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
- keys->insert("format", "ebuild");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", "e_repository_TEST_dir/repo6");
- keys->insert("profiles", "e_repository_TEST_dir/repo6/profiles/profile");
- std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
- env.package_database()->add_repository(1, repo);
-
- for (int pass = 1 ; pass <= 2 ; ++pass)
- {
- TestMessageSuffix pass_suffix(stringify(pass), true);
- std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1",
- &env, UserPackageDepSpecOptions()))))]->begin());
-
- TEST_CHECK(id->short_description_key());
- TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description");
- }
- }
- } test_e_repository_metadata_cached;
-
struct ERepositoryMetadataUncachedTest : TestCase
{
ERepositoryMetadataUncachedTest() : TestCase("metadata uncached") { }
@@ -540,63 +510,6 @@ namespace test_cases
}
} test_e_repository_metadata_uncached;
- struct ERepositoryMetadataStaleTest : TestCase
- {
- ERepositoryMetadataStaleTest() : TestCase("metadata stale") { }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- void run()
- {
- for (int opass = 1 ; opass <= 3 ; ++opass)
- {
- TestMessageSuffix opass_suffix("opass=" + stringify(opass), true);
-
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- std::tr1::shared_ptr<Map<std::string, std::string> > keys(
- new Map<std::string, std::string>);
- keys->insert("format", "ebuild");
- keys->insert("names_cache", "/var/empty");
- keys->insert("write_cache", "e_repository_TEST_dir/repo7/metadata/cache");
- keys->insert("location", "e_repository_TEST_dir/repo7");
- keys->insert("profiles", "e_repository_TEST_dir/repo7/profiles/profile");
- std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
- env.package_database()->add_repository(1, repo);
-
- for (int pass = 1 ; pass <= 3 ; ++pass)
- {
- TestMessageSuffix pass_suffix("pass=" + stringify(pass), true);
-
- const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat-one/stale-pkg-1",
- &env, UserPackageDepSpecOptions()))))]->begin());
-
- TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
- TEST_CHECK(id1->short_description_key());
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description");
- }
-
- for (int pass = 1 ; pass <= 3 ; ++pass)
- {
- TestMessageSuffix pass_suffix("pass=" + stringify(pass), true);
-
- const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat-one/stale-pkg-1",
- &env, UserPackageDepSpecOptions()))))]->begin());
-
- TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
- TEST_CHECK(id1->short_description_key());
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description");
- }
- }
- }
- } test_e_repository_metadata_stale;
-
struct ERepositoryMetadataUnparsableTest : TestCase
{
ERepositoryMetadataUnparsableTest() : TestCase("metadata unparsable") { }
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index 37cb37c..9ae3d95 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -104,41 +104,8 @@ END
cd ..
-mkdir -p repo6/{eclass,distfiles,profiles/profile} || exit 1
-mkdir -p repo6/cat-one/pkg-one || exit 1
-mkdir -p repo6/metadata/cache/cat-one
-cd repo6 || exit 1
-echo "test-repo-6" > profiles/repo_name || exit 1
-cat <<END > profiles/categories || exit 1
-cat-one
-END
-cat <<END > profiles/profile/make.defaults
-ARCH=test
-END
-cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
-END
-cat <<END > metadata/cache/cat-one/pkg-one-1
-the/depend
-the/rdepend
-the-slot
-the-src-uri
-the-restrict
-the-homepage
-the-license
-the-description
-the-keywords
-
-the-iuse
-unused
-the/pdepend
-the/provide
-0
-END
-cd ..
-
-
mkdir -p repo7/{eclass,distfiles,profiles/profile} || exit 1
-mkdir -p repo7/cat-one/{stale-pkg,pkg-{one,two}} || exit 1
+mkdir -p repo7/cat-one/pkg-{one,two} || exit 1
mkdir -p repo7/metadata/cache/cat-{one,two}
cd repo7 || exit 1
echo "test-repo-7" > profiles/repo_name || exit 1
@@ -188,71 +155,9 @@ END
cat <<END > eclass/mine.eclass
DEPEND="bar/baz"
END
-cat <<END > eclass/stale.eclass
-END
cat <<END > cat-one/pkg-two/pkg-two-1.ebuild || exit 1
i am a fish
END
-
-cat <<END > cat-one/stale-pkg/stale-pkg-1.ebuild || exit 1
-DESCRIPTION="The Generated Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND=""
-END
-cat <<END > metadata/cache/cat-one/stale-pkg-1
-the/depend
-the/rdepend
-the-slot
-the-src-uri
-the-restrict
-the-homepage
-the-license
-The Stale Description
-the-keywords
-
-the-iuse
-unused
-the/pdepend
-the/provide
-0
-END
-touch -t 199901010101 metadata/cache/cat-one/stale-pkg-1 || exit 2
-
-cat <<END > cat-one/stale-pkg/stale-pkg-2.ebuild || exit 1
-inherit stale
-
-DESCRIPTION="The Generated Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND=""
-END
-cat <<END > metadata/cache/cat-one/stale-pkg-2
-the/depend
-the/rdepend
-the-slot
-the-src-uri
-the-restrict
-the-homepage
-the-license
-The Stale Description
-the-keywords
-stale
-the-iuse
-unused
-the/pdepend
-the/provide
-0
-END
-touch -t 199901010101 metadata/cache/cat-one/stale-pkg-2 || exit 2
cd ..
mkdir -p repo8/{eclass,distfiles,profiles/profile} || exit 1
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
new file mode 100644
index 0000000..8b38328
--- /dev/null
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
@@ -0,0 +1,1091 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2008 David Leverton
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/generator.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/package_id.hh>
+#include <paludis/selection.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include <fstream>
+
+using namespace test;
+using namespace paludis;
+
+namespace
+{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+}
+
+namespace test_cases
+{
+ struct MetadataFlatListCachedTest : TestCase
+ {
+ MetadataFlatListCachedTest() : TestCase("metadata flat_list cached") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_list");
+ }
+ } test_metadata_flat_list_cached;
+
+ struct MetadataFlatListStaleTest : TestCase
+ {
+ MetadataFlatListStaleTest() : TestCase("metadata flat_list stale") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-stale-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_list-stale");
+ }
+ } test_metadata_flat_list_stale;
+
+ struct MetadataFlatListEclassCachedTest : TestCase
+ {
+ MetadataFlatListEclassCachedTest() : TestCase("metadata flat_list eclass cached") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_list-eclass");
+ TEST_CHECK_EQUAL(join(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->begin(),
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->end(), " "), "foo");
+ }
+ } test_metadata_flat_list_eclass_cached;
+
+ struct MetadataFlatListEclassStaleTest : TestCase
+ {
+ MetadataFlatListEclassStaleTest() : TestCase("metadata flat_list eclass stale") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-stale-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_list-eclass-stale");
+ }
+ } test_metadata_flat_list_eclass_stale;
+
+ struct MetadataFlatListEclassWrongTest : TestCase
+ {
+ MetadataFlatListEclassWrongTest() : TestCase("metadata flat_list eclass wrong") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-wrong-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_list-eclass-wrong");
+ }
+ } test_metadata_flat_list_eclass_wrong;
+
+ struct MetadataFlatListEclassGoneTest : TestCase
+ {
+ MetadataFlatListEclassGoneTest() : TestCase("metadata flat_list eclass gone") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-gone-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_list-eclass-gone");
+ }
+ } test_metadata_flat_list_eclass_gone;
+
+ struct MetadataFlatListDetectionTest : TestCase
+ {
+ MetadataFlatListDetectionTest() : TestCase("metadata flat_list detection") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-detection-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_list-detection");
+ }
+ } test_metadata_flat_list_detection;
+
+ struct MetadataFlatHashCachedTest : TestCase
+ {
+ MetadataFlatHashCachedTest() : TestCase("metadata flat_hash cached") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash");
+ }
+ } test_metadata_flat_hash_cached;
+
+ struct MetadataFlatHashEmptyValueTest : TestCase
+ {
+ MetadataFlatHashEmptyValueTest() : TestCase("metadata flat_hash empty value") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-empty-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "");
+ TEST_CHECK_STRINGIFY_EQUAL(id->slot(), "the-slot");
+ }
+ } test_metadata_flat_hash_empty_value;
+
+ struct MetadataFlatHashStaleTest : TestCase
+ {
+ MetadataFlatHashStaleTest() : TestCase("metadata flat_hash stale") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-stale-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-stale");
+ }
+ } test_metadata_flat_hash_stale;
+
+ struct MetadataFlatHashNoMtimeTest : TestCase
+ {
+ MetadataFlatHashNoMtimeTest() : TestCase("metadata flat_hash no mtime") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-mtime-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-no-mtime");
+ }
+ } test_metadata_flat_hash_no_mtime;
+
+ struct MetadataFlatHashNoEAPITest : TestCase
+ {
+ MetadataFlatHashNoEAPITest() : TestCase("metadata flat_hash no EAPI") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-eapi-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-no-eapi");
+ }
+ } test_metadata_flat_hash_no_eapi;
+
+ struct MetadataFlatHashDuplicateKeyTest : TestCase
+ {
+ MetadataFlatHashDuplicateKeyTest() : TestCase("metadata flat_hash duplicate key") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ const std::tr1::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-duplicate-key-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id1->short_description_key());
+ TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-duplicate-key");
+ }
+ } test_metadata_flat_hash_duplicate_key;
+
+ struct MetadataFlatHashEclassTest : TestCase
+ {
+ MetadataFlatHashEclassTest() : TestCase("metadata flat_hash eclass") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash-eclass");
+ TEST_CHECK_EQUAL(join(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->begin(),
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->end(), " "), "foo");
+ }
+ } test_metadata_flat_hash_eclass;
+
+ struct MetadataFlatHashEclassStaleTest : TestCase
+ {
+ MetadataFlatHashEclassStaleTest() : TestCase("metadata flat_hash eclass stale") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-stale-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclass-stale");
+ }
+ } test_metadata_flat_hash_eclass_stale;
+
+ struct MetadataFlatHashEclassWrongTest : TestCase
+ {
+ MetadataFlatHashEclassWrongTest() : TestCase("metadata flat_hash eclass wrong") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-wrong-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclass-wrong");
+ }
+ } test_metadata_flat_hash_eclass_wrong;
+
+ struct MetadataFlatHashEclassGoneTest : TestCase
+ {
+ MetadataFlatHashEclassGoneTest() : TestCase("metadata flat_hash eclass gone") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-gone-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclass-gone");
+ }
+ } test_metadata_flat_hash_eclass_gone;
+
+ struct MetadataFlatHashFullEclassTest : TestCase
+ {
+ MetadataFlatHashFullEclassTest() : TestCase("metadata flat_hash full eclass") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash-full-eclass");
+ TEST_CHECK_EQUAL(join(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->begin(),
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->end(), " "), "foo");
+ }
+ } test_metadata_flat_hash_full_eclass;
+
+ struct MetadataFlatHashFullEclassNonstandardTest : TestCase
+ {
+ MetadataFlatHashFullEclassNonstandardTest() : TestCase("metadata flat_hash full eclass nonstandard") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-nonstandard-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash-full-eclass-nonstandard");
+ TEST_CHECK_EQUAL(join(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->begin(),
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->end(), " "), "bar foo");
+ }
+ } test_metadata_flat_hash_full_eclass_nonstandard;
+
+ struct MetadataFlatHashFullEclassStaleTest : TestCase
+ {
+ MetadataFlatHashFullEclassStaleTest() : TestCase("metadata flat_hash full eclass stale") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-stale-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-full-eclass-stale");
+ }
+ } test_metadata_flat_hash_full_eclass_stale;
+
+ struct MetadataFlatHashFullEclassWrongTest : TestCase
+ {
+ MetadataFlatHashFullEclassWrongTest() : TestCase("metadata flat_hash full eclass wrong") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-wrong-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-full-eclass-wrong");
+ }
+ } test_metadata_flat_hash_full_eclass_wrong;
+
+ struct MetadataFlatHashFullEclassGoneTest : TestCase
+ {
+ MetadataFlatHashFullEclassGoneTest() : TestCase("metadata flat_hash full eclass gone") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-gone-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-full-eclass-gone");
+ }
+ } test_metadata_flat_hash_full_eclass_gone;
+
+ struct MetadataFlatHashEclassesTruncatedTest : TestCase
+ {
+ MetadataFlatHashEclassesTruncatedTest() : TestCase("metadata flat_hash eclasses truncated") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-truncated-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclasses-truncated");
+
+ std::tr1::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-truncated-2",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id2->short_description_key());
+ TEST_CHECK_EQUAL(id2->short_description_key()->value(), "The Generated Description flat_hash-eclasses-truncated-2");
+ }
+ } test_metadata_flat_hash_eclasses_truncated;
+
+ struct MetadataFlatHashEclassesBadMtimeTest : TestCase
+ {
+ MetadataFlatHashEclassesBadMtimeTest() : TestCase("metadata flat_hash eclasses bad mtime") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-bad-mtime-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclasses-bad-mtime");
+ }
+ } test_metadata_flat_hash_eclasses_bad_mtime;
+
+ struct MetadataFlatHashEclassesSpacesTest : TestCase
+ {
+ MetadataFlatHashEclassesSpacesTest() : TestCase("metadata flat_hash eclasses spaces") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-spaces-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclasses-spaces");
+ }
+ } test_metadata_flat_hash_eclasses_spaces;
+
+ struct MetadataFlatHashExlibTest : TestCase
+ {
+ MetadataFlatHashExlibTest() : TestCase("metadata flat_hash exlib") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash-exlib");
+ TEST_CHECK_EQUAL(join(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->begin(),
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->end(), " "), "foo");
+ }
+ } test_metadata_flat_hash_exlib;
+
+ struct MetadataFlatHashExlibPerCategoryTest : TestCase
+ {
+ MetadataFlatHashExlibPerCategoryTest() : TestCase("metadata flat_hash exlib per-category") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-percat-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash-exlib-percat");
+ TEST_CHECK_EQUAL(join(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->begin(),
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**id->find_metadata("INHERITED"))->value()->end(), " "), "bar foo");
+ }
+ } test_metadata_flat_hash_exlib_per_category;
+
+ struct MetadataFlatHashExlibStaleTest : TestCase
+ {
+ MetadataFlatHashExlibStaleTest() : TestCase("metadata flat_hash exlib stale") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-stale-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlib-stale");
+ }
+ } test_metadata_flat_hash_exlib_stale;
+
+ struct MetadataFlatHashExlibWrongTest : TestCase
+ {
+ MetadataFlatHashExlibWrongTest() : TestCase("metadata flat_hash exlib wrong") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-wrong-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlib-wrong");
+ }
+ } test_metadata_flat_hash_exlib_wrong;
+
+ struct MetadataFlatHashExlibGoneTest : TestCase
+ {
+ MetadataFlatHashExlibGoneTest() : TestCase("metadata flat_hash exlib gone") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-gone-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlib-gone");
+ }
+ } test_metadata_flat_hash_exlib_gone;
+
+ struct MetadataFlatHashExlibsTruncatedTest : TestCase
+ {
+ MetadataFlatHashExlibsTruncatedTest() : TestCase("metadata flat_hash exlibs truncated") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-truncated-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlibs-truncated");
+
+ std::tr1::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-truncated-2",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id2->short_description_key());
+ TEST_CHECK_EQUAL(id2->short_description_key()->value(), "The Generated Description flat_hash-exlibs-truncated-2");
+ }
+ } test_metadata_flat_hash_exlibs_truncated;
+
+ struct MetadataFlatHashExlibsBadMtimeTest : TestCase
+ {
+ MetadataFlatHashExlibsBadMtimeTest() : TestCase("metadata flat_hash exlibs bad mtime") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-bad-mtime-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlibs-bad-mtime");
+ }
+ } test_metadata_flat_hash_exlibs_bad_mtime;
+
+ struct MetadataFlatHashExlibsSpacesTest : TestCase
+ {
+ MetadataFlatHashExlibsSpacesTest() : TestCase("metadata flat_hash exlibs spaces") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-spaces-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlibs-spaces");
+ }
+ } test_metadata_flat_hash_exlibs_spaces;
+
+ struct MetadataWriteTest : TestCase
+ {
+ MetadataWriteTest() : TestCase("metadata write") { }
+
+ std::string contents(const std::string & filename)
+ {
+ std::ifstream s(filename.c_str());
+ return std::string(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>());
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ keys->insert("write_cache", "ebuild_flat_metadata_cache_TEST_dir/cache");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-1"));
+ }
+ } test_metadata_write;
+
+ struct MetadataWriteEclassesTest : TestCase
+ {
+ MetadataWriteEclassesTest() : TestCase("metadata write eclasses") { }
+
+ std::string contents(const std::string & filename)
+ {
+ std::ifstream s(filename.c_str());
+ return std::string(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>());
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eclassdirs", "ebuild_flat_metadata_cache_TEST_dir/repo/eclass ebuild_flat_metadata_cache_TEST_dir/extra_eclasses");
+ keys->insert("write_cache", "ebuild_flat_metadata_cache_TEST_dir/cache");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-eclasses-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eclasses-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-eclasses-1"));
+ }
+ } test_metadata_write_eclasses;
+
+ struct MetadataWriteExlibsTest : TestCase
+ {
+ MetadataWriteExlibsTest() : TestCase("metadata write exlibs") { }
+
+ std::string contents(const std::string & filename)
+ {
+ std::ifstream s(filename.c_str());
+ return std::string(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>());
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "ebuild_flat_metadata_cache_TEST_dir/repo");
+ keys->insert("profiles", "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ keys->insert("write_cache", "ebuild_flat_metadata_cache_TEST_dir/cache");
+ std::tr1::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-exlibs-1",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+
+ TEST_CHECK(id->short_description_key());
+ TEST_CHECK_EQUAL(contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-exlibs-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-exlibs-1"));
+ }
+ } test_metadata_write_exlibs;
+}
+
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST_cleanup.sh b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST_cleanup.sh
new file mode 100755
index 0000000..4cf4c82
--- /dev/null
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST_cleanup.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d ebuild_flat_metadata_cache_TEST_dir ] ; then
+ rm -fr ebuild_flat_metadata_cache_TEST_dir
+else
+ true
+fi
+
+
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST_setup.sh b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST_setup.sh
new file mode 100755
index 0000000..39408c6
--- /dev/null
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST_setup.sh
@@ -0,0 +1,1045 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir ebuild_flat_metadata_cache_TEST_dir || exit 1
+cd ebuild_flat_metadata_cache_TEST_dir || exit 1
+
+mkdir extra_eclasses || exit 1
+touch extra_eclasses/bar.eclass || exit 1
+TZ=UTC touch -t 197001010003 extra_eclasses/bar.eclass || exit 1
+
+mkdir -p repo/{eclass,exlibs,distfiles,profiles/profile} || exit 1
+mkdir -p repo/cat/exlibs || exit 1
+mkdir -p repo/metadata/cache/cat
+cd repo || exit 1
+echo "test-repo" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cat <<END > eclass/foo.eclass
+DEPEND="cat/baz"
+IUSE="quux"
+END
+cat <<END > exlibs/foo.exlib
+DEPENDENCIES="cat/baz"
+MYOPTIONS="quux"
+END
+TZ=UTC touch -t 197001010003 eclass/foo.eclass eclass/bar.eclass || exit 1
+TZ=UTC touch -t 197001010003 exlibs/foo.exlib exlibs/bar.exlib || exit 1
+TZ=UTC touch -t 197001010003 cat/exlibs/bar.exlib || exit 1
+
+mkdir cat/flat_list
+cat <<END > cat/flat_list/flat_list-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_list-1 || exit 1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+the-description-flat_list
+the-keywords
+
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+
+mkdir cat/flat_list-stale
+cat <<END > cat/flat_list-stale/flat_list-stale-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_list-stale"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_list-stale-1 || exit 1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+The Stale Description
+the-keywords
+
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+touch -t 199901010101 metadata/cache/cat/flat_list-stale-1 || exit 2
+
+mkdir cat/flat_list-eclass
+cat <<END > cat/flat_list-eclass/flat_list-eclass-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_list-eclass-1 || exit 1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+the-description-flat_list-eclass
+the-keywords
+foo
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+
+mkdir cat/flat_list-eclass-stale
+cat <<END > cat/flat_list-eclass-stale/flat_list-eclass-stale-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_list-eclass-stale"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_list-eclass-stale-1 || exit 1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+The Stale Description
+the-keywords
+foo
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+touch -t 197001010001 cat/flat_list-eclass-stale/flat_list-eclass-stale-1.ebuild || exit 2
+touch -t 197001010002 metadata/cache/cat/flat_list-eclass-stale-1 || exit 2
+
+mkdir cat/flat_list-eclass-wrong
+cat <<END > cat/flat_list-eclass-wrong/flat_list-eclass-wrong-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_list-eclass-wrong"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_list-eclass-wrong-1 || exit 1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+The Stale Description
+the-keywords
+bar
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+
+mkdir cat/flat_list-eclass-gone
+cat <<END > cat/flat_list-eclass-gone/flat_list-eclass-gone-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_list-eclass-gone"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_list-eclass-gone-1 || exit 1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+The Stale Description
+the-keywords
+baz
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+
+mkdir cat/flat_list-detection
+cat <<END > cat/flat_list-detection/flat_list-detection-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_list-detection-1 || exit 1
+the/package =the/depend-1
+the/package =the/rdepend-1
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+the-description-flat_list-detection
+the-keywords
+
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+
+mkdir cat/flat_hash
+cat <<END > cat/flat_hash/flat_hash-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_hash-1 || exit 1
+_mtime_=60
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=the-description-flat_hash
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash/flat_hash-1.ebuild || exit 2
+
+mkdir cat/flat_hash-empty
+cat <<END > cat/flat_hash-empty/flat_hash-empty-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-empty"
+END
+cat <<END > metadata/cache/cat/flat_hash-empty-1 || exit 1
+_mtime_=60
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-empty/flat_hash-empty-1.ebuild || exit 2
+
+mkdir cat/flat_hash-stale
+cat <<END > cat/flat_hash-stale/flat_hash-stale-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-stale"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-stale-1 || exit 1
+_mtime_=915152460
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+
+mkdir cat/flat_hash-no-mtime
+cat <<END > cat/flat_hash-no-mtime/flat_hash-no-mtime-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-no-mtime"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-no-mtime-1 || exit 1
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+
+mkdir cat/flat_hash-no-eapi
+cat <<END > cat/flat_hash-no-eapi/flat_hash-no-eapi-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-no-eapi"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-no-eapi-1 || exit 1
+_mtime_=60
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-no-eapi/flat_hash-no-eapi-1.ebuild || exit 2
+
+mkdir cat/flat_hash-duplicate-key
+cat <<END > cat/flat_hash-duplicate-key/flat_hash-duplicate-key-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-duplicate-key"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-duplicate-key-1 || exit 1
+_mtime_=60
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+FOO=bar
+FOO=bar
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-duplicate-key/flat_hash-duplicate-key-1.ebuild || exit 2
+
+mkdir cat/flat_hash-eclass
+cat <<END > cat/flat_hash-eclass/flat_hash-eclass-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_hash-eclass-1 || exit 1
+_mtime_=60
+_eclasses_=foo 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=the-description-flat_hash-eclass
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclass/flat_hash-eclass-1.ebuild || exit 2
+
+mkdir cat/flat_hash-eclass-stale
+cat <<END > cat/flat_hash-eclass-stale/flat_hash-eclass-stale-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclass-stale"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclass-stale-1 || exit 1
+_mtime_=60
+_eclasses_=foo 120
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclass-stale/flat_hash-eclass-stale-1.ebuild || exit 2
+
+mkdir cat/flat_hash-eclass-wrong
+cat <<END > cat/flat_hash-eclass-wrong/flat_hash-eclass-wrong-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclass-wrong"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclass-wrong-1 || exit 1
+_mtime_=60
+_eclasses_=bar 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclass-wrong/flat_hash-eclass-wrong-1.ebuild || exit 2
+
+mkdir cat/flat_hash-eclass-gone
+cat <<END > cat/flat_hash-eclass-gone/flat_hash-eclass-gone-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclass-gone"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclass-gone-1 || exit 1
+_mtime_=60
+_eclasses_=baz 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclass-gone/flat_hash-eclass-gone-1.ebuild || exit 2
+
+mkdir cat/flat_hash-full-eclass
+cat <<END > cat/flat_hash-full-eclass/flat_hash-full-eclass-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_hash-full-eclass-1 || exit 1
+_mtime_=60
+_eclasses_=foo ebuild_flat_metadata_cache_TEST_dir/repo/eclass 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=the-description-flat_hash-full-eclass
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-full-eclass/flat_hash-full-eclass-1.ebuild || exit 2
+
+mkdir cat/flat_hash-full-eclass-nonstandard
+cat <<END > cat/flat_hash-full-eclass-nonstandard/flat_hash-full-eclass-nonstandard-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_hash-full-eclass-nonstandard-1 || exit 1
+_mtime_=60
+_eclasses_=foo ebuild_flat_metadata_cache_TEST_dir/repo/eclass 180 bar ebuild_flat_metadata_cache_TEST_dir/extra_eclasses 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=the-description-flat_hash-full-eclass-nonstandard
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-full-eclass-nonstandard/flat_hash-full-eclass-nonstandard-1.ebuild || exit 2
+
+mkdir cat/flat_hash-full-eclass-stale
+cat <<END > cat/flat_hash-full-eclass-stale/flat_hash-full-eclass-stale-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-full-eclass-stale"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-full-eclass-stale-1 || exit 1
+_mtime_=60
+_eclasses_=foo ebuild_flat_metadata_cache_TEST_dir/repo/eclass 120
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-full-eclass-stale/flat_hash-full-eclass-stale-1.ebuild || exit 2
+
+mkdir cat/flat_hash-full-eclass-wrong
+cat <<END > cat/flat_hash-full-eclass-wrong/flat_hash-full-eclass-wrong-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-full-eclass-wrong"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-full-eclass-wrong-1 || exit 1
+_mtime_=60
+_eclasses_=foo ebuild_flat_metadata_cache_TEST_dir/repo/eclass 180 bar ebuild_flat_metadata_cache_TEST_dir/repo/eclass 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-full-eclass-wrong/flat_hash-full-eclass-wrong-1.ebuild || exit 2
+
+mkdir cat/flat_hash-full-eclass-gone
+cat <<END > cat/flat_hash-full-eclass-gone/flat_hash-full-eclass-gone-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-full-eclass-gone"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-full-eclass-gone-1 || exit 1
+_mtime_=60
+_eclasses_=baz ebuild_flat_metadata_cache_TEST_dir/repo/eclass 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-full-eclass-gone/flat_hash-full-eclass-gone-1.ebuild || exit 2
+
+mkdir cat/flat_hash-eclasses-truncated
+cat <<END > cat/flat_hash-eclasses-truncated/flat_hash-eclasses-truncated-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclasses-truncated"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclasses-truncated-1 || exit 1
+_mtime_=60
+_eclasses_=foo ebuild_flat_metadata_cache_TEST_dir/repo/eclass
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclasses-truncated/flat_hash-eclasses-truncated-1.ebuild || exit 2
+cat <<END > cat/flat_hash-eclasses-truncated/flat_hash-eclasses-truncated-2.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclasses-truncated-2"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclasses-truncated-2 || exit 1
+_mtime_=60
+_eclasses_=foo
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclasses-truncated/flat_hash-eclasses-truncated-2.ebuild || exit 2
+
+mkdir cat/flat_hash-eclasses-bad-mtime
+cat <<END > cat/flat_hash-eclasses-bad-mtime/flat_hash-eclasses-bad-mtime-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclasses-bad-mtime"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclasses-bad-mtime-1 || exit 1
+_mtime_=60
+_eclasses_=foo bar
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclasses-bad-mtime/flat_hash-eclasses-bad-mtime-1.ebuild || exit 2
+
+mkdir cat/flat_hash-eclasses-spaces
+cat <<END > cat/flat_hash-eclasses-spaces/flat_hash-eclasses-spaces-1.ebuild || exit 1
+DESCRIPTION="The Generated Description flat_hash-eclasses-spaces"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND=""
+END
+cat <<END > metadata/cache/cat/flat_hash-eclasses-spaces-1 || exit 1
+_mtime_=60
+_eclasses_=foo 180
+DEPEND=the/depend
+RDEPEND=the/rdepend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+DESCRIPTION=The Stale Description
+KEYWORDS=the-keywords
+IUSE=the-iuse
+PDEPEND=the/pdepend
+PROVIDE=the/provide
+EAPI=0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-eclasses-spaces/flat_hash-eclasses-spaces-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlib
+cat <<END > cat/flat_hash-exlib/flat_hash-exlib-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_hash-exlib-1 || exit 1
+_mtime_=60
+_exlibs_=foo ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 180
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=the-description-flat_hash-exlib
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlib/flat_hash-exlib-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlib-percat
+cat <<END > cat/flat_hash-exlib-percat/flat_hash-exlib-percat-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat/flat_hash-exlib-percat-1 || exit 1
+_mtime_=60
+_exlibs_=foo ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 180 bar ebuild_flat_metadata_cache_TEST_dir/repo/cat/exlibs 180
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=the-description-flat_hash-exlib-percat
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlib-percat/flat_hash-exlib-percat-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlib-stale
+cat <<END > cat/flat_hash-exlib-stale/flat_hash-exlib-stale-1.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlib-stale"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlib-stale-1 || exit 1
+_mtime_=60
+_exlibs_=foo ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 120
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlib-stale/flat_hash-exlib-stale-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlib-wrong
+cat <<END > cat/flat_hash-exlib-wrong/flat_hash-exlib-wrong-1.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlib-wrong"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlib-wrong-1 || exit 1
+_mtime_=60
+_exlibs_=foo ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 180 bar ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 180
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlib-wrong/flat_hash-exlib-wrong-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlib-gone
+cat <<END > cat/flat_hash-exlib-gone/flat_hash-exlib-gone-1.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlib-gone"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlib-gone-1 || exit 1
+_mtime_=60
+_exlibs_=baz ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 180
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlib-gone/flat_hash-exlib-gone-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlibs-truncated
+cat <<END > cat/flat_hash-exlibs-truncated/flat_hash-exlibs-truncated-1.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlibs-truncated"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlibs-truncated-1 || exit 1
+_mtime_=60
+_exlibs_=foo ebuild_flat_metadata_cache_TEST_dir/repo/exlibs
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlibs-truncated/flat_hash-exlibs-truncated-1.ebuild || exit 2
+cat <<END > cat/flat_hash-exlibs-truncated/flat_hash-exlibs-truncated-2.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlibs-truncated-2"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlibs-truncated-2 || exit 1
+_mtime_=60
+_exlibs_=foo
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlibs-truncated/flat_hash-exlibs-truncated-2.ebuild || exit 2
+
+mkdir cat/flat_hash-exlibs-bad-mtime
+cat <<END > cat/flat_hash-exlibs-bad-mtime/flat_hash-exlibs-bad-mtime-1.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlibs-bad-mtime"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlibs-bad-mtime-1 || exit 1
+_mtime_=60
+_exlibs_=foo bar
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlibs-bad-mtime/flat_hash-exlibs-bad-mtime-1.ebuild || exit 2
+
+mkdir cat/flat_hash-exlibs-spaces
+cat <<END > cat/flat_hash-exlibs-spaces/flat_hash-exlibs-spaces-1.ebuild || exit 1
+SUMMARY="The Generated Description flat_hash-exlibs-spaces"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+MYOPTIONS=""
+LICENSE="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES=""
+END
+cat <<END > metadata/cache/cat/flat_hash-exlibs-spaces-1 || exit 1
+_mtime_=60
+_exlibs_=foo 180
+DEPENDENCIES=the/depend
+SLOT=the-slot
+SRC_URI=the-src-uri
+RESTRICT=the-restrict
+HOMEPAGE=the-homepage
+LICENSE=the-license
+SUMMARY=The Stale Description
+PLATFORMS=the-keywords
+MYOPTIONS=the-iuse
+EAPI=exheres-0
+END
+TZ=UTC touch -t 197001010001 cat/flat_hash-exlibs-spaces/flat_hash-exlibs-spaces-1.ebuild || exit 2
+
+mkdir cat/write
+cat <<END > cat/write/write-1.ebuild || exit 1
+DESCRIPTION="A nice package"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="test"
+IUSE="bar"
+DEPEND="cat/foo bar? ( cat/bar )"
+END
+TZ=UTC touch -t 197001010001 cat/write/write-1.ebuild || exit 2
+
+mkdir cat/write-eclasses
+cat <<END > cat/write-eclasses/write-eclasses-1.ebuild || exit 1
+inherit foo bar
+DESCRIPTION="A nice package"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="test"
+IUSE="bar"
+DEPEND="cat/foo bar? ( cat/bar )"
+END
+TZ=UTC touch -t 197001010001 cat/write-eclasses/write-eclasses-1.ebuild || exit 2
+
+mkdir cat/write-exlibs
+cat <<END > cat/write-exlibs/write-exlibs-1.ebuild || exit 1
+require foo bar
+SUMMARY="A nice package"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+LICENSE="GPL-2"
+SLOT="0"
+PLATFORMS="test"
+MYOPTIONS="bar"
+DEPENDENCIES="build: cat/foo bar? ( cat/bar )"
+END
+TZ=UTC touch -t 197001010001 cat/write-exlibs/write-exlibs-1.ebuild || exit 2
+
+cd ..
+
+mkdir -p cache/{test-repo,expected}/cat
+
+cat <<END > cache/expected/cat/write-1
+_mtime_=60
+DEPEND=cat/foo bar? ( cat/bar )
+RDEPEND=cat/foo bar? ( cat/bar )
+SLOT=0
+HOMEPAGE=http://example.com/
+LICENSE=GPL-2
+DESCRIPTION=A nice package
+KEYWORDS=test
+IUSE=bar
+EAPI=0
+END
+
+cat <<END > cache/expected/cat/write-eclasses-1
+_mtime_=60
+_eclasses_=bar ebuild_flat_metadata_cache_TEST_dir/extra_eclasses 180 foo ebuild_flat_metadata_cache_TEST_dir/repo/eclass 180
+DEPEND=cat/foo bar? ( cat/bar ) cat/baz
+RDEPEND=cat/foo bar? ( cat/bar )
+SLOT=0
+HOMEPAGE=http://example.com/
+LICENSE=GPL-2
+DESCRIPTION=A nice package
+KEYWORDS=test
+IUSE=bar quux
+EAPI=0
+END
+
+cat <<END > cache/expected/cat/write-exlibs-1
+_mtime_=60
+_exlibs_=bar ebuild_flat_metadata_cache_TEST_dir/repo/cat/exlibs 180 foo ebuild_flat_metadata_cache_TEST_dir/repo/exlibs 180
+DEPENDENCIES=build: cat/foo bar? ( cat/bar ) cat/baz build: bar? ( ) cat/baz build: bar? ( )
+SLOT=0
+HOMEPAGE=http://example.com/
+LICENSE=GPL-2
+SUMMARY=A nice package
+PLATFORMS=test
+MYOPTIONS=bar quux
+EAPI=exheres-0
+END
+