aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 23:25:16 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 23:25:16 +0000
commitaf81c486651c7feb0dbadf7091a1a435ba1d8018 (patch)
tree3abb76ffbced3711d275b52c93a347e6711af11e
parent52deabd1187061e1218492422675b9cdedba68e5 (diff)
downloadpaludis-af81c486651c7feb0dbadf7091a1a435ba1d8018.tar.gz
paludis-af81c486651c7feb0dbadf7091a1a435ba1d8018.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc2250
2 files changed, 1012 insertions, 1242 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 3d875ea..cc3c1dc 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -470,13 +470,15 @@ fix_locked_dependencies_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
ebuild_flat_metadata_cache_TEST_SOURCES = ebuild_flat_metadata_cache_TEST.cc
ebuild_flat_metadata_cache_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
ebuild_flat_metadata_cache_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+ebuild_flat_metadata_cache_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
EXTRA_DIST = \
aa_visitor_TEST.cc \
dep_parser.se \
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
index f05eeba..62dfb1c 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
@@ -19,13 +19,16 @@
*/
#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>
@@ -36,11 +39,12 @@
#include <paludis/util/fs_stat.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/join.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+#include <paludis/util/stringify.hh>
+
#include <iterator>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -54,1246 +58,1010 @@ namespace
else
return mm->second;
}
+
+ std::string contents(const std::string & filename)
+ {
+ SafeIFStream s(FSPath(filename).realpath());
+ return std::string((std::istreambuf_iterator<char>(s)), std::istreambuf_iterator<char>());
+ }
}
-namespace test_cases
+TEST(EbuildFlatMetadataCache, FlatList)
{
- struct MetadataFlatListCachedTest : TestCase
- {
- MetadataFlatListCachedTest() : TestCase("metadata flat_list cached") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_list-stale");
- }
- } test_metadata_flat_list_stale;
-
- struct MetadataFlatListGuessedEAPITest : TestCase
- {
- MetadataFlatListGuessedEAPITest() : TestCase("metadata flat_list guessed EAPI") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- keys->insert("eapi_when_unknown", "1");
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-guessed-eapi-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_list-guessed-eapi");
- }
- } test_metadata_flat_list_guessed_eapi;
-
- struct MetadataFlatListEclassCachedTest : TestCase
- {
- MetadataFlatListEclassCachedTest() : TestCase("metadata flat_list eclass cached") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-wrong-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-gone-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-detection-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id->short_description_key()));
- TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash");
- }
- } test_metadata_flat_hash_cached;
-
- struct MetadataFlatHashGuessedEAPITest : TestCase
- {
- MetadataFlatHashGuessedEAPITest() : TestCase("metadata flat_hash guessed EAPI") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- keys->insert("eapi_when_unknown", "1");
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-guessed-eapi-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-guessed-eapi");
- }
- } test_metadata_flat_hash_guessed_eapi;
-
- struct MetadataFlatHashGuessedEAPIExtensionTest : TestCase
- {
- MetadataFlatHashGuessedEAPIExtensionTest() : TestCase("metadata flat_hash guessed EAPI by extension") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-guessed-eapi-extension-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-guessed-eapi-extension");
- }
- } test_metadata_flat_hash_guessed_eapi_extension;
-
- struct MetadataFlatHashCachedNoGuessedEAPITest : TestCase
- {
- MetadataFlatHashCachedNoGuessedEAPITest() : TestCase("metadata flat_hash no guessed EAPI") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-guessed-eapi-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id->short_description_key()));
- TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description-flat_hash-no-guessed-eapi");
- }
- } test_metadata_flat_hash_cached_no_guessed_eapi;
-
- struct MetadataFlatHashEmptyValueTest : TestCase
- {
- MetadataFlatHashEmptyValueTest() : TestCase("metadata flat_hash empty value") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-empty-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id->short_description_key()));
- TEST_CHECK_EQUAL(id->short_description_key()->value(), "");
- TEST_CHECK_STRINGIFY_EQUAL(id->slot_key()->value(), "the-slot");
- }
- } test_metadata_flat_hash_empty_value;
-
- struct MetadataFlatHashStaleTest : TestCase
- {
- MetadataFlatHashStaleTest() : TestCase("metadata flat_hash stale") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-mtime-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "the-description-flat_hash-no-mtime");
- }
- } test_metadata_flat_hash_no_mtime;
-
- struct MetadataFlatHashNoMtimeStaleTest : TestCase
- {
- MetadataFlatHashNoMtimeStaleTest() : TestCase("metadata flat_hash no mtime stale") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-mtime-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-no-mtime-stale");
- }
- } test_metadata_flat_hash_no_mtime_stale;
-
- struct MetadataFlatHashBadMtimeTest : TestCase
- {
- MetadataFlatHashBadMtimeTest() : TestCase("metadata flat_hash bad mtime") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-bad-mtime-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id1->short_description_key()));
- TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Generated Description flat_hash-bad-mtime");
- }
- } test_metadata_flat_hash_bad_mtime;
-
- struct MetadataFlatHashNoEAPITest : TestCase
- {
- MetadataFlatHashNoEAPITest() : TestCase("metadata flat_hash no EAPI") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-eapi-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-duplicate-key-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-wrong-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-gone-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-nonstandard-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-wrong-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-gone-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-truncated-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id->short_description_key()));
- TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-eclasses-truncated");
-
- std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-truncated-2",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-bad-mtime-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-spaces-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-percat-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-stale-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-wrong-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-gone-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-truncated-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id->short_description_key()));
- TEST_CHECK_EQUAL(id->short_description_key()->value(), "The Generated Description flat_hash-exlibs-truncated");
-
- std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-truncated-2",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-bad-mtime-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-spaces-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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)
- {
- SafeIFStream s(FSPath(filename).realpath());
- return std::string((std::istreambuf_iterator<char>(s)), std::istreambuf_iterator<char>());
- }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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");
- keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/write-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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_CHECK_EQUAL(FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-1").stat().mtim().seconds(), 60);
- }
- } test_metadata_write;
-
- struct MetadataWriteEAPI1Test : TestCase
- {
- MetadataWriteEAPI1Test() : TestCase("metadata write EAPI 1") { }
-
- std::string contents(const std::string & filename)
- {
- SafeIFStream s(FSPath(filename).realpath());
- return std::string((std::istreambuf_iterator<char>(s)), std::istreambuf_iterator<char>());
- }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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");
- keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/write-eapi1-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(id->short_description_key()));
- TEST_CHECK_EQUAL(contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eapi1-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-eapi1-1"));
- TEST_CHECK_EQUAL(FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eapi1-1").stat().mtim().seconds(), 60);
- }
- } test_metadata_write_eapi1;
-
- struct MetadataWriteEclassesTest : TestCase
- {
- MetadataWriteEclassesTest() : TestCase("metadata write eclasses") { }
-
- std::string contents(const std::string & filename)
- {
- SafeIFStream s(FSPath(filename).realpath());
- return std::string((std::istreambuf_iterator<char>(s)), std::istreambuf_iterator<char>());
- }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile"));
- keys->insert("eclassdirs",
- stringify((FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo/eclass").realpath())
- + " " + stringify((FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/extra_eclasses").realpath()));
- keys->insert("write_cache", "ebuild_flat_metadata_cache_TEST_dir/cache");
- keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/write-eclasses-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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_CHECK_EQUAL(FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eclasses-1").stat().mtim().seconds(), 60);
- }
- } test_metadata_write_eclasses;
-
- struct MetadataWriteExlibsTest : TestCase
- {
- MetadataWriteExlibsTest() : TestCase("metadata write exlibs") { }
-
- std::string contents(const std::string & filename)
- {
- SafeIFStream s(FSPath(filename).realpath());
- return std::string((std::istreambuf_iterator<char>(s)), std::istreambuf_iterator<char>());
- }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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");
- keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/write-exlibs-1",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(bool(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_CHECK_EQUAL(FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-exlibs-1").stat().mtim().seconds(), 60);
- }
- } test_metadata_write_exlibs;
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_list", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, FlatListStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_list-stale", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, GuessedEAPI)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ keys->insert("eapi_when_unknown", "1");
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-guessed-eapi-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_list-guessed-eapi", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, EclassCached)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_list-eclass", id->short_description_key()->value());
+ ASSERT_EQ("foo", 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(), " "));
+}
+
+TEST(EbuildFlatMetadataCache, EclassStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_list-eclass-stale", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, EclassWrong)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-wrong-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_list-eclass-wrong", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, EclassGone)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-eclass-gone-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_list-eclass-gone", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, FlatListDetection)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_list-detection-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_list-detection", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, FlatHash)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, FlatHashGuessedEAPI)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ keys->insert("eapi_when_unknown", "1");
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-guessed-eapi-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-guessed-eapi", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, FlatHashGuessedExtension)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-guessed-eapi-extension-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-guessed-eapi-extension", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, FlatHashNoGuessedEAPI)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-guessed-eapi-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-no-guessed-eapi", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, EmptyValue)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-empty-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("", id->short_description_key()->value());
+ EXPECT_EQ("the-slot", stringify(id->slot_key()->value()));
+}
+
+TEST(EbuildFlatMetadataCache, HashStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-stale", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashNoMTime)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-mtime-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-no-mtime", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashNoMTimeStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-mtime-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-no-mtime-stale", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashBadMtime)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-bad-mtime-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-bad-mtime", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashNoEAPI)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-no-eapi-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-no-eapi", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashDuplicateKey)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-duplicate-key-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id1->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-duplicate-key", id1->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashEclass)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-eclass", id->short_description_key()->value());
+ ASSERT_EQ("foo", 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(), " "));
+}
+
+TEST(EbuildFlatMetadataCache, HashEclassStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclass-stale", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashEclassWrong)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-wrong-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclass-wrong", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashEclassGone)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclass-gone-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclass-gone", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashFullEclass)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-full-eclass", id->short_description_key()->value());
+ ASSERT_EQ("foo", 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(), " "));
+}
+
+TEST(EbuildFlatMetadataCache, HashFullEclassNonStandard)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-nonstandard-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-full-eclass-nonstandard", id->short_description_key()->value());
+ ASSERT_EQ("bar foo", 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(), " "));
+}
+
+TEST(EbuildFlatMetadataCache, HashFullEclassStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-full-eclass-stale", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashFullEclassWrong)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-wrong-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-full-eclass-wrong", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashFullEclassGone)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-full-eclass-gone-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-full-eclass-gone", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashEclassTruncated)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-truncated-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclasses-truncated", id->short_description_key()->value());
+
+ std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-truncated-2",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id2->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclasses-truncated-2", id2->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashEclassBadMtime)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-bad-mtime-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclasses-bad-mtime", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashEclassSpaces)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-eclasses-spaces-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-eclasses-spaces", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashExlib)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-exlib", id->short_description_key()->value());
+ ASSERT_EQ("foo", 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(), " "));
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibPerCategory)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-percat-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("the-description-flat_hash-exlib-percat", id->short_description_key()->value());
+ ASSERT_EQ("bar foo", 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(), " "));
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibStale)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-stale-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlib-stale", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibWrong)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-wrong-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlib-wrong", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibGone)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlib-gone-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlib-gone", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibTruncated)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-truncated-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlibs-truncated", id->short_description_key()->value());
+
+ std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-truncated-2",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id2->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlibs-truncated-2", id2->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibBadMtime)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-bad-mtime-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlibs-bad-mtime", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, HashExlibSpaces)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/flat_hash-exlibs-spaces-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ("The Generated Description flat_hash-exlibs-spaces", id->short_description_key()->value());
+}
+
+TEST(EbuildFlatMetadataCache, Write)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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");
+ keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ(contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-1"));
+ EXPECT_EQ(60, FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-1").stat().mtim().seconds());
+}
+
+TEST(EbuildFlatMetadataCache, Write1)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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");
+ keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-eapi1-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ(contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-eapi1-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eapi1-1"));
+ EXPECT_EQ(60, FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eapi1-1").stat().mtim().seconds());
+}
+
+TEST(EbuildFlatMetadataCache, WriteEclasses)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo/profiles/profile"));
+ keys->insert("eclassdirs",
+ stringify((FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo/eclass").realpath())
+ + " " + stringify((FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/extra_eclasses").realpath()));
+ keys->insert("write_cache", "ebuild_flat_metadata_cache_TEST_dir/cache");
+ keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-eclasses-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ(contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-eclasses-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eclasses-1"));
+ EXPECT_EQ(60, FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-eclasses-1").stat().mtim().seconds());
+}
+
+TEST(EbuildFlatMetadataCache, WriteExlibs)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir/repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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");
+ keys->insert("builddir", stringify(FSPath::cwd() / "ebuild_flat_metadata_cache_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/write-exlibs-1",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+
+ ASSERT_TRUE(bool(id->short_description_key()));
+ EXPECT_EQ(contents("ebuild_flat_metadata_cache_TEST_dir/cache/expected/cat/write-exlibs-1"), contents("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-exlibs-1"));
+ EXPECT_EQ(60, FSPath("ebuild_flat_metadata_cache_TEST_dir/cache/test-repo/cat/write-exlibs-1").stat().mtim().seconds());
}