aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-05 15:30:29 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-05 15:30:29 +0000
commitfed1372c3d68212cecaa9fdc35c90b150d7fd2f2 (patch)
tree8819fcf803b5dd9dc83cd645430ad0a44793db89
parent1f50219439b49adc323d5d00ffc606861e6174fe (diff)
downloadpaludis-fed1372c3d68212cecaa9fdc35c90b150d7fd2f2.tar.gz
paludis-fed1372c3d68212cecaa9fdc35c90b150d7fd2f2.tar.xz
Split VDB tests up a bit
-rw-r--r--.gitignore2
-rw-r--r--paludis/repositories/e/Makefile.am32
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc850
-rw-r--r--paludis/repositories/e/vdb_repository_TEST_cache.cc683
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_cache_cleanup.sh11
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_cache_setup.sh107
-rw-r--r--paludis/repositories/e/vdb_repository_TEST_eapis.cc353
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_eapis_cleanup.sh9
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_eapis_setup.sh269
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_setup.sh356
10 files changed, 1466 insertions, 1206 deletions
diff --git a/.gitignore b/.gitignore
index 6ca15f8..d17ef6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -352,6 +352,8 @@ paludis-*.*.*.tar.bz2
/paludis/repositories/e/source_uri_finder_TEST
/paludis/repositories/e/vdb_merger_TEST
/paludis/repositories/e/vdb_repository_TEST
+/paludis/repositories/e/vdb_repository_TEST_eapis
+/paludis/repositories/e/vdb_repository_TEST_cache
/paludis/repositories/e/vdb_unmerger_TEST
/paludis/repositories/e/xml_things_TEST
/paludis/repositories/fake/dep_parser_TEST
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 2854e41..6c9aace 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -321,6 +321,28 @@ vdb_repository_TEST_LDADD = \
vdb_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+vdb_repository_TEST_eapis_SOURCES = vdb_repository_TEST_eapis.cc
+
+vdb_repository_TEST_eapis_LDADD = \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/test/libtest.a \
+ $(DYNAMIC_LD_LIBS)
+
+vdb_repository_TEST_eapis_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+
+vdb_repository_TEST_cache_SOURCES = vdb_repository_TEST_cache.cc
+
+vdb_repository_TEST_cache_LDADD = \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/test/libtest.a \
+ $(DYNAMIC_LD_LIBS)
+
+vdb_repository_TEST_cache_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+
exndbam_repository_TEST_SOURCES = exndbam_repository_TEST.cc
exndbam_repository_TEST_LDADD = \
@@ -505,6 +527,12 @@ EXTRA_DIST = \
vdb_repository_TEST.cc \
vdb_repository_TEST_setup.sh \
vdb_repository_TEST_cleanup.sh \
+ vdb_repository_TEST_eapis.cc \
+ vdb_repository_TEST_eapis_setup.sh \
+ vdb_repository_TEST_eapis_cleanup.sh \
+ vdb_repository_TEST_cache.cc \
+ vdb_repository_TEST_cache_setup.sh \
+ vdb_repository_TEST_cache_cleanup.sh \
vdb_merger_TEST.cc \
vdb_merger_TEST_setup.sh \
vdb_merger_TEST_cleanup.sh \
@@ -537,6 +565,8 @@ check_SCRIPTS = \
e_repository_TEST_symlink_rewriting_setup.sh e_repository_TEST_symlink_rewriting_cleanup.sh \
xml_things_TEST_setup.sh xml_things_TEST_cleanup.sh \
vdb_repository_TEST_setup.sh vdb_repository_TEST_cleanup.sh \
+ vdb_repository_TEST_eapis_setup.sh vdb_repository_TEST_eapis_cleanup.sh \
+ vdb_repository_TEST_cache_setup.sh vdb_repository_TEST_cache_cleanup.sh \
exndbam_repository_TEST_setup.sh exndbam_repository_TEST_cleanup.sh \
e_repository_sets_TEST_setup.sh e_repository_sets_TEST_cleanup.sh \
fetch_visitor_TEST_setup.sh fetch_visitor_TEST_cleanup.sh
@@ -608,6 +638,8 @@ dist_paludis_data_DATA = traditional.exclude ebuild_entries_suffixes.conf
TESTS = \
vdb_repository_TEST \
+ vdb_repository_TEST_eapis \
+ vdb_repository_TEST_cache \
e_repository_TEST \
e_repository_TEST_0 \
e_repository_TEST_1 \
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 2d4ec69..15e8d2c 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -258,856 +258,6 @@ namespace test_cases
}
} vdb_repository_contents_test;
- struct PhasesTest : TestCase
- {
- const std::string eapi;
-
- PhasesTest(const std::string & e) :
- TestCase("phases eapi " + e),
- eapi(e)
- {
- }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- bool repeatable() const
- {
- return false;
- }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- 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() / "vdb_repository_TEST_dir" / "srcrepo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "srcrepo/profiles/profile"));
- keys->insert("layout", "traditional");
- keys->insert("eapi_when_unknown", eapi);
- keys->insert("eapi_when_unspecified", eapi);
- keys->insert("profile_eapi", "0");
- keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(1, repo);
-
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "vdb");
- keys->insert("names_cache", "/var/empty");
- keys->insert("provides_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "repo3"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(0, vdb_repo);
-
- InstallAction install_action(make_named_values<InstallActionOptions>(
- n::destination() = vdb_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &do_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
-
- UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- n::config_protect() = "",
- n::if_for_install_id() = make_null_shared_ptr(),
- n::ignore_for_unmerge() = &ignore_nothing,
- n::is_overwrite() = false,
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- InfoActionOptions info_action_options(make_named_values<InfoActionOptions>(
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- ConfigActionOptions config_action_options(make_named_values<ConfigActionOptions>(
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- InfoAction info_action(info_action_options);
- ConfigAction config_action(config_action_options);
-
- {
- TestMessageSuffix suffix("install", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(install_action);
- }
-
- vdb_repo->invalidate();
-
- {
- TestMessageSuffix suffix("reinstall", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(install_action);
- }
-
- vdb_repo->invalidate();
-
- {
- TestMessageSuffix suffix("info", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(info_action);
- }
-
- {
- TestMessageSuffix suffix("config", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(config_action);
- }
-
- {
- TestMessageSuffix suffix("uninstall", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(uninstall_action);
- }
- }
- } test_phases_eapi_0("0"), test_phases_eapi_1("1"), test_phases_eapi_2("2"), test_phases_eapi_3("3"),
- test_phases_eapi_exheres_0("exheres-0");
-
- struct VarsTest : TestCase
- {
- const std::string eapi;
-
- VarsTest(const std::string & e) :
- TestCase("vars eapi " + e),
- eapi(e)
- {
- }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- bool repeatable() const
- {
- return false;
- }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- 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() / "vdb_repository_TEST_dir" / "srcrepo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "srcrepo/profiles/profile"));
- keys->insert("layout", "traditional");
- keys->insert("eapi_when_unknown", eapi);
- keys->insert("eapi_when_unspecified", eapi);
- keys->insert("profile_eapi", "0");
- keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(1, repo);
-
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "vdb");
- keys->insert("names_cache", "/var/empty");
- keys->insert("provides_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "repo3"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(0, vdb_repo);
-
- InstallAction install_action(make_named_values<InstallActionOptions>(
- n::destination() = vdb_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &do_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
-
- UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- n::config_protect() = "",
- n::if_for_install_id() = make_null_shared_ptr(),
- n::ignore_for_unmerge() = &ignore_nothing,
- n::is_overwrite() = false,
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- InfoActionOptions info_action_options(make_named_values<InfoActionOptions>(
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- ConfigActionOptions config_action_options(make_named_values<ConfigActionOptions>(
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- InfoAction info_action(info_action_options);
- ConfigAction config_action(config_action_options);
-
- {
- TestMessageSuffix suffix("vars", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(install_action);
- }
-
- vdb_repo->invalidate();
-
- {
- TestMessageSuffix suffix("reinstall", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(install_action);
- }
-
- vdb_repo->invalidate();
-
- {
- TestMessageSuffix suffix("info", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(info_action);
- }
-
- {
- TestMessageSuffix suffix("config", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(config_action);
- }
-
- {
- TestMessageSuffix suffix("uninstall", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- TEST_CHECK(bool(id));
- id->perform_action(uninstall_action);
- }
- }
- } test_vdb_vars_eapi_0("0"), test_vdb_vars_eapi_1("1"), test_vdb_vars_eapi_2("2"),
- test_vdb_vars_eapi_exheres_0("exheres-0");
-
- struct NamesCacheIncrementalTest : TestCase
- {
- FSPath names_cache;
-
- NamesCacheIncrementalTest() :
- TestCase("names cache incremental"),
- names_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "namesincrtest/.cache/names/installed"))
- {
- }
-
- bool repeatable() const
- {
- return false;
- }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- void install(const Environment & env,
- const std::shared_ptr<Repository> & vdb_repo,
- const std::string & chosen_one,
- const std::string & victim) const
- {
- std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
- if (! victim.empty())
- replacing->push_back(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec(victim,
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- InstallAction install_action(make_named_values<InstallActionOptions>(
- n::destination() = vdb_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &do_uninstall,
- n::replacing() = replacing,
- n::want_phase() = &want_all_phases
- ));
- (*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec(chosen_one,
- &env, { })), make_null_shared_ptr(), { }))]->begin())->perform_action(install_action);
- }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- 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() / "vdb_repository_TEST_dir" / "namesincrtest_src"));
- keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "namesincrtest_src/profiles/profile"));
- keys->insert("layout", "traditional");
- keys->insert("eapi_when_unknown", "0");
- keys->insert("eapi_when_unspecified", "0");
- keys->insert("profile_eapi", "0");
- keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(1, repo);
-
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "vdb");
- keys->insert("names_cache", stringify(names_cache.dirname()));
- keys->insert("provides_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "namesincrtest"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(0, vdb_repo);
-
- UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- n::config_protect() = "",
- n::if_for_install_id() = make_null_shared_ptr(),
- n::ignore_for_unmerge() = &ignore_nothing,
- n::is_overwrite() = false,
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- {
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 0U);
- }
-
- {
- TestMessageSuffix suffix("install", true);
- install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("reinstall", true);
- install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("upgrade", true);
- install(env, vdb_repo, "=cat1/pkg1-1.1::namesincrtest_src", "=cat1/pkg1-1::installed");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("downgrade", true);
- install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "=cat1/pkg1-1.1::installed");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("new slot", true);
- install(env, vdb_repo, "=cat1/pkg1-2::namesincrtest_src", "");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("remove other slot", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-2::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("new package", true);
- install(env, vdb_repo, "=cat1/pkg2-1::namesincrtest_src", "");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 2U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(cache_contents.back().basename(), "pkg2");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg2"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("remove other package", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg2-1::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("new category", true);
- install(env, vdb_repo, "=cat2/pkg1-1::namesincrtest_src", "");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\ncat2\n");
- }
-
- {
- TestMessageSuffix suffix("remove other category", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat2/pkg1-1::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
- }
-
- {
- TestMessageSuffix suffix("uninstall", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-1::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 0U);
- }
-
- {
- TestMessageSuffix suffix("install paludis-1", true);
- install(env, vdb_repo, "=cat3/pkg1-1::namesincrtest_src", "");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat3\n");
- }
-
- {
- TestMessageSuffix suffix("upgrade paludis-1", true);
- install(env, vdb_repo, "=cat3/pkg1-2::namesincrtest_src", "=cat3/pkg1-1::installed");
- vdb_repo->invalidate();
-
- std::vector<FSPath> cache_contents;
- read_cache(cache_contents);
- TEST_CHECK_EQUAL(cache_contents.size(), 1U);
- TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
- TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat3\n");
- }
- }
-
- void read_cache(std::vector<FSPath> & vec)
- {
- using namespace std::placeholders;
- std::remove_copy_if(FSIterator(names_cache, { fsio_include_dotfiles }),
- FSIterator(), std::back_inserter(vec),
- std::bind(&std::equal_to<std::string>::operator(),
- std::equal_to<std::string>(),
- "_VERSION_", std::bind(&FSPath::basename, _1)));
- }
-
- std::string read_file(const FSPath & f)
- {
- SafeIFStream s(f);
- std::stringstream ss;
- std::copy(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>(),
- std::ostreambuf_iterator<char>(ss));
- return ss.str();
- }
- } test_names_cache_incremental;
-
- struct ProvidesCacheTest : TestCase
- {
- FSPath provides_cache;
-
- ProvidesCacheTest() :
- TestCase("provides cache"),
- provides_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "providestest/.cache/provides"))
- {
- }
-
- bool repeatable() const
- {
- return false;
- }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "vdb");
- keys->insert("names_cache", "/var/empty");
- keys->insert("provides_cache", stringify(provides_cache));
- keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "providestest"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(0, vdb_repo);
-
- TEST_CHECK(! provides_cache.stat().exists());
-
- {
- std::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence> seq(vdb_repo->provides_interface()->provided_packages());
-
- for (RepositoryProvidesInterface::ProvidesSequence::ConstIterator s(seq->begin()), s_end(seq->end()) ;
- s != s_end ; ++s)
- TestMessageSuffix x(stringify(s->virtual_name()) + " by " + stringify(*s->provided_by()), true);
-
- TEST_CHECK_EQUAL(std::distance(seq->begin(), seq->end()), 5);
-
- RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1:1::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2:2::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2:2::installed");
- }
-
- vdb_repo->regenerate_cache();
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\ncat1/pkg1 2 virtual/foo\ncat1/pkg2 1 virtual/foo virtual/bar\ncat1/pkg2 2 virtual/bar\n");
- vdb_repo->invalidate();
-
- {
- std::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence> seq(vdb_repo->provides_interface()->provided_packages());
- TEST_CHECK_EQUAL(std::distance(seq->begin(), seq->end()), 5);
-
- for (auto i(seq->begin()), i_end(seq->end()) ;
- i != i_end ; ++i)
- TEST_CHECK(! stringify(i->provided_by()->slot_key()->value()).empty());
-
- RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1:1::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2:2::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
- TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2:2::installed");
- }
- }
-
- std::string read_file(const FSPath & f)
- {
- SafeIFStream s(f);
- std::stringstream ss;
- std::copy(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>(),
- std::ostreambuf_iterator<char>(ss));
- return ss.str();
- }
- } test_provides_cache;
-
- struct ProvidesCacheIncrementalTest : TestCase
- {
- FSPath provides_cache;
-
- ProvidesCacheIncrementalTest() :
- TestCase("provides cache incremental"),
- provides_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "providesincrtest/.cache/provides"))
- {
- }
-
- bool repeatable() const
- {
- return false;
- }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- void install(const Environment & env,
- const std::shared_ptr<Repository> & vdb_repo,
- const std::string & chosen_one,
- const std::string & victim) const
- {
- std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
- if (! victim.empty())
- replacing->push_back(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec(victim,
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- InstallAction install_action(make_named_values<InstallActionOptions>(
- n::destination() = vdb_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &do_uninstall,
- n::replacing() = replacing,
- n::want_phase() = &want_all_phases
- ));
- (*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec(chosen_one,
- &env, { })), make_null_shared_ptr(), { }))]->begin())->perform_action(install_action);
- }
-
- void run()
- {
- TestEnvironment env;
- env.set_paludis_command("/bin/false");
- 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() / "vdb_repository_TEST_dir" / "providesincrtest_src1"));
- keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "providesincrtest_src1/profiles/profile"));
- keys->insert("layout", "traditional");
- keys->insert("eapi_when_unknown", "0");
- keys->insert("eapi_when_unspecified", "0");
- keys->insert("profile_eapi", "0");
- keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(1, repo1);
-
- 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() / "vdb_repository_TEST_dir" / "providesincrtest_src2"));
- keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "providesincrtest_src1/profiles/profile"));
- keys->insert("layout", "traditional");
- keys->insert("eapi_when_unknown", "0");
- keys->insert("eapi_when_unspecified", "0");
- keys->insert("profile_eapi", "0");
- keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> repo2(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(2, repo2);
-
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "vdb");
- keys->insert("names_cache", "/var/empty");
- keys->insert("provides_cache", stringify(provides_cache));
- keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "providesincrtest"));
- keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.package_database()->add_repository(0, vdb_repo);
-
- UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- n::config_protect() = "",
- n::if_for_install_id() = make_null_shared_ptr(),
- n::ignore_for_unmerge() = &ignore_nothing,
- n::is_overwrite() = false,
- n::make_output_manager() = &make_standard_output_manager
- ));
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
-
- {
- TestMessageSuffix suffix("install", true);
- install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("reinstall", true);
- install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("upgrade", true);
- install(env, vdb_repo, "=cat1/pkg1-1.1::providesincrtest_src1", "=cat1/pkg1-1::installed");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1.1 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("reinstall equivalent", true);
- install(env, vdb_repo, "=cat1/pkg1-1.1::providesincrtest_src2", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1.1-r0 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("downgrade", true);
- install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "=cat1/pkg1-1.1::installed");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("reinstall different PROVIDE", true);
- install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src2", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n");
- }
-
- {
- TestMessageSuffix suffix("new slot", true);
- install(env, vdb_repo, "=cat1/pkg1-2::providesincrtest_src1", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\ncat1/pkg1 2 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("remove other slot", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-2::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n");
- }
-
- {
- TestMessageSuffix suffix("new package", true);
- install(env, vdb_repo, "=cat1/pkg2-1::providesincrtest_src1", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\ncat1/pkg2 1 virtual/foo\n");
- }
-
- {
- TestMessageSuffix suffix("remove other package", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg2-1::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n");
- }
-
- {
- TestMessageSuffix suffix("uninstall", true);
- const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-1::installed",
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- inst_id->perform_action(uninstall_action);
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
- }
-
- {
- TestMessageSuffix suffix("install paludis-1", true);
- install(env, vdb_repo, "=cat2/pkg1-1::providesincrtest_src1", "");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat2/pkg1 1 virtual/moo\n");
- }
-
- {
- TestMessageSuffix suffix("upgrade paludis-1", true);
- install(env, vdb_repo, "=cat2/pkg1-2::providesincrtest_src1", "=cat2/pkg1-1::installed");
- vdb_repo->invalidate();
-
- TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat2/pkg1 2 virtual/moo\n");
- }
- }
-
- std::string read_file(const FSPath & f)
- {
- SafeIFStream s(f);
- std::stringstream ss;
- std::copy(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>(),
- std::ostreambuf_iterator<char>(ss));
- return ss.str();
- }
- } test_provides_cache_incremental;
-
struct ReinstallTest : TestCase
{
ReinstallTest() : TestCase("reinstall") { }
diff --git a/paludis/repositories/e/vdb_repository_TEST_cache.cc b/paludis/repositories/e/vdb_repository_TEST_cache.cc
new file mode 100644
index 0000000..9194ad1
--- /dev/null
+++ b/paludis/repositories/e/vdb_repository_TEST_cache.cc
@@ -0,0 +1,683 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/vdb_repository.hh>
+#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/repositories/e/spec_tree_pretty_printer.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/package_database.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/fs_iterator.hh>
+#include <paludis/util/fs_stat.hh>
+#include <paludis/standard_output_manager.hh>
+#include <paludis/generator.hh>
+#include <paludis/filter.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/selection.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/action.hh>
+#include <paludis/choice.hh>
+#include <paludis/unformatted_pretty_printer.hh>
+
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include <functional>
+#include <algorithm>
+#include <iterator>
+#include <vector>
+
+using namespace test;
+using namespace paludis;
+
+namespace
+{
+ void do_uninstall(const std::shared_ptr<const PackageID> & id, const UninstallActionOptions & u)
+ {
+ UninstallAction a(u);
+ id->perform_action(a);
+ }
+
+ std::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return std::make_shared<StandardOutputManager>();
+ }
+
+ std::string from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+
+ WantPhase want_all_phases(const std::string &)
+ {
+ return wp_yes;
+ }
+
+ bool ignore_nothing(const FSPath &)
+ {
+ return false;
+ }
+}
+
+namespace test_cases
+{
+ struct NamesCacheIncrementalTest : TestCase
+ {
+ FSPath names_cache;
+
+ NamesCacheIncrementalTest() :
+ TestCase("names cache incremental"),
+ names_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "namesincrtest/.cache/names/installed"))
+ {
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ void install(const Environment & env,
+ const std::shared_ptr<Repository> & vdb_repo,
+ const std::string & chosen_one,
+ const std::string & victim) const
+ {
+ std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
+ if (! victim.empty())
+ replacing->push_back(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec(victim,
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ n::destination() = vdb_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &do_uninstall,
+ n::replacing() = replacing,
+ n::want_phase() = &want_all_phases
+ ));
+ (*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec(chosen_one,
+ &env, { })), make_null_shared_ptr(), { }))]->begin())->perform_action(install_action);
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ 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() / "vdb_repository_TEST_cache_dir" / "namesincrtest_src"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "namesincrtest_src/profiles/profile"));
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", "0");
+ keys->insert("eapi_when_unspecified", "0");
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_cache_dir/root").realpath()));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", stringify(names_cache.dirname()));
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "namesincrtest"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_cache_dir/root").realpath()));
+ std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ n::config_protect() = "",
+ n::if_for_install_id() = make_null_shared_ptr(),
+ n::ignore_for_unmerge() = &ignore_nothing,
+ n::is_overwrite() = false,
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ {
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 0U);
+ }
+
+ {
+ TestMessageSuffix suffix("install", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade", true);
+ install(env, vdb_repo, "=cat1/pkg1-1.1::namesincrtest_src", "=cat1/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("downgrade", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "=cat1/pkg1-1.1::installed");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("new slot", true);
+ install(env, vdb_repo, "=cat1/pkg1-2::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("remove other slot", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-2::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("new package", true);
+ install(env, vdb_repo, "=cat1/pkg2-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 2U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(cache_contents.back().basename(), "pkg2");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg2"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("remove other package", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg2-1::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("new category", true);
+ install(env, vdb_repo, "=cat2/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\ncat2\n");
+ }
+
+ {
+ TestMessageSuffix suffix("remove other category", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat2/pkg1-1::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat1\n");
+ }
+
+ {
+ TestMessageSuffix suffix("uninstall", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-1::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 0U);
+ }
+
+ {
+ TestMessageSuffix suffix("install paludis-1", true);
+ install(env, vdb_repo, "=cat3/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat3\n");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade paludis-1", true);
+ install(env, vdb_repo, "=cat3/pkg1-2::namesincrtest_src", "=cat3/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(cache_contents);
+ TEST_CHECK_EQUAL(cache_contents.size(), 1U);
+ TEST_CHECK_EQUAL(cache_contents.front().basename(), "pkg1");
+ TEST_CHECK_EQUAL(read_file(names_cache / "pkg1"), "cat3\n");
+ }
+ }
+
+ void read_cache(std::vector<FSPath> & vec)
+ {
+ using namespace std::placeholders;
+ std::remove_copy_if(FSIterator(names_cache, { fsio_include_dotfiles }),
+ FSIterator(), std::back_inserter(vec),
+ std::bind(&std::equal_to<std::string>::operator(),
+ std::equal_to<std::string>(),
+ "_VERSION_", std::bind(&FSPath::basename, _1)));
+ }
+
+ std::string read_file(const FSPath & f)
+ {
+ SafeIFStream s(f);
+ std::stringstream ss;
+ std::copy(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>(),
+ std::ostreambuf_iterator<char>(ss));
+ return ss.str();
+ }
+ } test_names_cache_incremental;
+
+ struct ProvidesCacheTest : TestCase
+ {
+ FSPath provides_cache;
+
+ ProvidesCacheTest() :
+ TestCase("provides cache"),
+ provides_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providestest/.cache/provides"))
+ {
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", stringify(provides_cache));
+ keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providestest"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_cache_dir/root").realpath()));
+ std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ TEST_CHECK(! provides_cache.stat().exists());
+
+ {
+ std::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence> seq(vdb_repo->provides_interface()->provided_packages());
+
+ for (RepositoryProvidesInterface::ProvidesSequence::ConstIterator s(seq->begin()), s_end(seq->end()) ;
+ s != s_end ; ++s)
+ TestMessageSuffix x(stringify(s->virtual_name()) + " by " + stringify(*s->provided_by()), true);
+
+ TEST_CHECK_EQUAL(std::distance(seq->begin(), seq->end()), 5);
+
+ RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1:1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2:2::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2:2::installed");
+ }
+
+ vdb_repo->regenerate_cache();
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\ncat1/pkg1 2 virtual/foo\ncat1/pkg2 1 virtual/foo virtual/bar\ncat1/pkg2 2 virtual/bar\n");
+ vdb_repo->invalidate();
+
+ {
+ std::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence> seq(vdb_repo->provides_interface()->provided_packages());
+ TEST_CHECK_EQUAL(std::distance(seq->begin(), seq->end()), 5);
+
+ for (auto i(seq->begin()), i_end(seq->end()) ;
+ i != i_end ; ++i)
+ TEST_CHECK(! stringify(i->provided_by()->slot_key()->value()).empty());
+
+ RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1:1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2:2::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2:2::installed");
+ }
+ }
+
+ std::string read_file(const FSPath & f)
+ {
+ SafeIFStream s(f);
+ std::stringstream ss;
+ std::copy(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>(),
+ std::ostreambuf_iterator<char>(ss));
+ return ss.str();
+ }
+ } test_provides_cache;
+
+ struct ProvidesCacheIncrementalTest : TestCase
+ {
+ FSPath provides_cache;
+
+ ProvidesCacheIncrementalTest() :
+ TestCase("provides cache incremental"),
+ provides_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providesincrtest/.cache/provides"))
+ {
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ void install(const Environment & env,
+ const std::shared_ptr<Repository> & vdb_repo,
+ const std::string & chosen_one,
+ const std::string & victim) const
+ {
+ std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
+ if (! victim.empty())
+ replacing->push_back(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec(victim,
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ n::destination() = vdb_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &do_uninstall,
+ n::replacing() = replacing,
+ n::want_phase() = &want_all_phases
+ ));
+ (*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec(chosen_one,
+ &env, { })), make_null_shared_ptr(), { }))]->begin())->perform_action(install_action);
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ 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() / "vdb_repository_TEST_cache_dir" / "providesincrtest_src1"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providesincrtest_src1/profiles/profile"));
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", "0");
+ keys->insert("eapi_when_unspecified", "0");
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_cache_dir/root").realpath()));
+ std::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(1, repo1);
+
+ 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() / "vdb_repository_TEST_cache_dir" / "providesincrtest_src2"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providesincrtest_src1/profiles/profile"));
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", "0");
+ keys->insert("eapi_when_unspecified", "0");
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_cache_dir/root").realpath()));
+ std::shared_ptr<Repository> repo2(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(2, repo2);
+
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", stringify(provides_cache));
+ keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providesincrtest"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_cache_dir/root").realpath()));
+ std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ n::config_protect() = "",
+ n::if_for_install_id() = make_null_shared_ptr(),
+ n::ignore_for_unmerge() = &ignore_nothing,
+ n::is_overwrite() = false,
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
+
+ {
+ TestMessageSuffix suffix("install", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade", true);
+ install(env, vdb_repo, "=cat1/pkg1-1.1::providesincrtest_src1", "=cat1/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1.1 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall equivalent", true);
+ install(env, vdb_repo, "=cat1/pkg1-1.1::providesincrtest_src2", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1.1-r0 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("downgrade", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "=cat1/pkg1-1.1::installed");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall different PROVIDE", true);
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src2", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n");
+ }
+
+ {
+ TestMessageSuffix suffix("new slot", true);
+ install(env, vdb_repo, "=cat1/pkg1-2::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\ncat1/pkg1 2 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("remove other slot", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-2::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n");
+ }
+
+ {
+ TestMessageSuffix suffix("new package", true);
+ install(env, vdb_repo, "=cat1/pkg2-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\ncat1/pkg2 1 virtual/foo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("remove other package", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg2-1::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n");
+ }
+
+ {
+ TestMessageSuffix suffix("uninstall", true);
+ const std::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat1/pkg1-1::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
+ }
+
+ {
+ TestMessageSuffix suffix("install paludis-1", true);
+ install(env, vdb_repo, "=cat2/pkg1-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat2/pkg1 1 virtual/moo\n");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade paludis-1", true);
+ install(env, vdb_repo, "=cat2/pkg1-2::providesincrtest_src1", "=cat2/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\ncat2/pkg1 2 virtual/moo\n");
+ }
+ }
+
+ std::string read_file(const FSPath & f)
+ {
+ SafeIFStream s(f);
+ std::stringstream ss;
+ std::copy(std::istreambuf_iterator<char>(s), std::istreambuf_iterator<char>(),
+ std::ostreambuf_iterator<char>(ss));
+ return ss.str();
+ }
+ } test_provides_cache_incremental;
+}
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_cache_cleanup.sh b/paludis/repositories/e/vdb_repository_TEST_cache_cleanup.sh
new file mode 100755
index 0000000..6eecf99
--- /dev/null
+++ b/paludis/repositories/e/vdb_repository_TEST_cache_cleanup.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d vdb_repository_TEST_cache_dir ] ; then
+ rm -fr vdb_repository_TEST_cache_dir
+else
+ true
+fi
+
+
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_cache_setup.sh b/paludis/repositories/e/vdb_repository_TEST_cache_setup.sh
new file mode 100755
index 0000000..241a689
--- /dev/null
+++ b/paludis/repositories/e/vdb_repository_TEST_cache_setup.sh
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir -p vdb_repository_TEST_cache_dir || exit 1
+cd vdb_repository_TEST_cache_dir || exit 1
+
+mkdir -p distdir
+mkdir -p build
+mkdir -p root/etc
+
+mkdir -p namesincrtest/.cache/names/installed namesincrtest_src/{eclass,profiles/profile,cat1/{pkg1,pkg2},{cat2,cat3}/pkg1} || exit 1
+echo paludis-2 >namesincrtest/.cache/names/installed/_VERSION_
+echo installed >>namesincrtest/.cache/names/installed/_VERSION_
+
+cat <<END > namesincrtest_src/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo namesincrtest_src >namesincrtest_src/profiles/repo_name
+echo cat1 >namesincrtest_src/profiles/categories
+echo cat2 >>namesincrtest_src/profiles/categories
+echo cat3 >>namesincrtest_src/profiles/categories
+
+cat <<END >namesincrtest_src/cat1/pkg1/pkg1-1.ebuild
+KEYWORDS="test"
+SLOT="\${PV:0:1}"
+END
+cp namesincrtest_src/cat1/pkg1/pkg1-{1,1.1}.ebuild
+cp namesincrtest_src/cat1/pkg1/pkg1-{1,2}.ebuild
+cp namesincrtest_src/cat1/{pkg1/pkg1,pkg2/pkg2}-1.ebuild
+cp namesincrtest_src/{cat1,cat2}/pkg1/pkg1-1.ebuild
+
+cat <<END >namesincrtest_src/cat3/pkg1/pkg1-1.ebuild
+EAPI=paludis-1
+KEYWORDS="test"
+SLOT="0"
+END
+cp namesincrtest_src/cat3/pkg1/pkg1-{1,2}.ebuild
+
+mkdir -p providestest/{.cache,cat1/{pkg1,pkg2,pkg3}-{1,2}} || exit 1
+for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/EAPI; do
+ echo 0 >${f}
+done
+for f in providestest/cat1/{pkg1,pkg2,pkg3}-1/SLOT; do
+ echo 1 >${f}
+done
+for f in providestest/cat1/{pkg1,pkg2,pkg3}-2/SLOT; do
+ echo 2 >${f}
+done
+for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/USE; do
+ echo enabled >${f}
+done
+for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/IUSE; do
+ echo disabled enabled >${f}
+done
+
+echo ' virtual/foo' >providestest/cat1/pkg1-1/PROVIDE
+echo 'enabled? ( virtual/foo )' >providestest/cat1/pkg1-2/PROVIDE
+echo 'enabled? ( virtual/foo ) virtual/bar' >providestest/cat1/pkg2-1/PROVIDE
+echo 'disabled? ( virtual/foo ) virtual/bar' >providestest/cat1/pkg2-2/PROVIDE
+echo 'disabled? ( virtual/foo )' >providestest/cat1/pkg3-1/PROVIDE
+echo '' >providestest/cat1/pkg3-2/PROVIDE
+
+mkdir -p providesincrtest/.cache providesincrtest_src{1,2}/{eclass,profiles/profile,{cat1,cat2}/{pkg1,pkg2}} || exit 1
+echo paludis-3 >providesincrtest/.cache/provides
+echo installed >>providesincrtest/.cache/provides
+
+cat <<END > providesincrtest_src1/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo providesincrtest_src1 >providesincrtest_src1/profiles/repo_name
+echo providesincrtest_src2 >providesincrtest_src2/profiles/repo_name
+echo cat1 >providesincrtest_src1/profiles/categories
+echo cat2 >>providesincrtest_src1/profiles/categories
+echo cat1 >providesincrtest_src2/profiles/categories
+
+cat <<END >providesincrtest_src1/cat1/pkg1/pkg1-1.ebuild
+KEYWORDS="test"
+SLOT="\${PV:0:1}"
+PROVIDE="enabled? ( virtual/foo ) disabled? ( virtual/bar )"
+IUSE="enabled disabled"
+END
+cp providesincrtest_src1/cat1/pkg1/pkg1-{1,1.1}.ebuild
+cp providesincrtest_src1/cat1/pkg1/pkg1-{1,2}.ebuild
+cp providesincrtest_src1/cat1/{pkg1/pkg1,pkg2/pkg2}-1.ebuild
+cp providesincrtest_src1/cat1/pkg1/pkg1-1.1.ebuild providesincrtest_src2/cat1/pkg1/pkg1-1.1-r0.ebuild
+
+cat <<END >providesincrtest_src2/cat1/pkg1/pkg1-1.ebuild
+KEYWORDS="test"
+SLOT="\${PV:0:1}"
+PROVIDE="enabled? ( virtual/bar ) disabled? ( virtual/foo )"
+IUSE="enabled disabled"
+END
+
+cat <<END >providesincrtest_src1/cat2/pkg1/pkg1-1.ebuild
+EAPI=paludis-1
+KEYWORDS="test"
+SLOT="0"
+PROVIDE="virtual/moo"
+END
+cp providesincrtest_src1/cat2/pkg1/pkg1-{1,2}.ebuild
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_eapis.cc b/paludis/repositories/e/vdb_repository_TEST_eapis.cc
new file mode 100644
index 0000000..0544eff
--- /dev/null
+++ b/paludis/repositories/e/vdb_repository_TEST_eapis.cc
@@ -0,0 +1,353 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/vdb_repository.hh>
+#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/repositories/e/spec_tree_pretty_printer.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/package_database.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/fs_iterator.hh>
+#include <paludis/util/fs_stat.hh>
+#include <paludis/standard_output_manager.hh>
+#include <paludis/generator.hh>
+#include <paludis/filter.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/selection.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/action.hh>
+#include <paludis/choice.hh>
+#include <paludis/unformatted_pretty_printer.hh>
+
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include <functional>
+#include <algorithm>
+#include <iterator>
+#include <vector>
+
+using namespace test;
+using namespace paludis;
+
+namespace
+{
+ void do_uninstall(const std::shared_ptr<const PackageID> & id, const UninstallActionOptions & u)
+ {
+ UninstallAction a(u);
+ id->perform_action(a);
+ }
+
+ std::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return std::make_shared<StandardOutputManager>();
+ }
+
+ std::string from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+
+ WantPhase want_all_phases(const std::string &)
+ {
+ return wp_yes;
+ }
+
+ bool ignore_nothing(const FSPath &)
+ {
+ return false;
+ }
+}
+
+namespace test_cases
+{
+ struct PhasesTest : TestCase
+ {
+ const std::string eapi;
+
+ PhasesTest(const std::string & e) :
+ TestCase("phases eapi " + e),
+ eapi(e)
+ {
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ 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() / "vdb_repository_TEST_eapis_dir" / "srcrepo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "srcrepo/profiles/profile"));
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", eapi);
+ keys->insert("eapi_when_unspecified", eapi);
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_eapis_dir/root").realpath()));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "dstrepo"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_eapis_dir/root").realpath()));
+ std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ n::destination() = vdb_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &do_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ n::config_protect() = "",
+ n::if_for_install_id() = make_null_shared_ptr(),
+ n::ignore_for_unmerge() = &ignore_nothing,
+ n::is_overwrite() = false,
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ InfoActionOptions info_action_options(make_named_values<InfoActionOptions>(
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ ConfigActionOptions config_action_options(make_named_values<ConfigActionOptions>(
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ InfoAction info_action(info_action_options);
+ ConfigAction config_action(config_action_options);
+
+ {
+ TestMessageSuffix suffix("install", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(install_action);
+ }
+
+ vdb_repo->invalidate();
+
+ {
+ TestMessageSuffix suffix("reinstall", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(install_action);
+ }
+
+ vdb_repo->invalidate();
+
+ {
+ TestMessageSuffix suffix("info", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(info_action);
+ }
+
+ {
+ TestMessageSuffix suffix("config", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(config_action);
+ }
+
+ {
+ TestMessageSuffix suffix("uninstall", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(uninstall_action);
+ }
+ }
+ } test_phases_eapi_0("0"), test_phases_eapi_1("1"), test_phases_eapi_2("2"), test_phases_eapi_3("3"),
+ test_phases_eapi_exheres_0("exheres-0");
+
+ struct VarsTest : TestCase
+ {
+ const std::string eapi;
+
+ VarsTest(const std::string & e) :
+ TestCase("vars eapi " + e),
+ eapi(e)
+ {
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ 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() / "vdb_repository_TEST_eapis_dir" / "srcrepo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "srcrepo/profiles/profile"));
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", eapi);
+ keys->insert("eapi_when_unspecified", eapi);
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_eapis_dir/root").realpath()));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(1, repo);
+
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "dstrepo"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_eapis_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_eapis_dir/root").realpath()));
+ std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.package_database()->add_repository(0, vdb_repo);
+
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ n::destination() = vdb_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &do_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ n::config_protect() = "",
+ n::if_for_install_id() = make_null_shared_ptr(),
+ n::ignore_for_unmerge() = &ignore_nothing,
+ n::is_overwrite() = false,
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ InfoActionOptions info_action_options(make_named_values<InfoActionOptions>(
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ ConfigActionOptions config_action_options(make_named_values<ConfigActionOptions>(
+ n::make_output_manager() = &make_standard_output_manager
+ ));
+
+ InfoAction info_action(info_action_options);
+ ConfigAction config_action(config_action_options);
+
+ {
+ TestMessageSuffix suffix("vars", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(install_action);
+ }
+
+ vdb_repo->invalidate();
+
+ {
+ TestMessageSuffix suffix("reinstall", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::srcrepo",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(install_action);
+ }
+
+ vdb_repo->invalidate();
+
+ {
+ TestMessageSuffix suffix("info", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(info_action);
+ }
+
+ {
+ TestMessageSuffix suffix("config", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(config_action);
+ }
+
+ {
+ TestMessageSuffix suffix("uninstall", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/target-" + eapi + "::installed",
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ TEST_CHECK(bool(id));
+ id->perform_action(uninstall_action);
+ }
+ }
+ } test_vdb_vars_eapi_0("0"), test_vdb_vars_eapi_1("1"), test_vdb_vars_eapi_2("2"),
+ test_vdb_vars_eapi_exheres_0("exheres-0");
+}
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_eapis_cleanup.sh b/paludis/repositories/e/vdb_repository_TEST_eapis_cleanup.sh
new file mode 100755
index 0000000..6fa8a1b
--- /dev/null
+++ b/paludis/repositories/e/vdb_repository_TEST_eapis_cleanup.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d vdb_repository_TEST_eapis_dir ] ; then
+ rm -fr vdb_repository_TEST_eapis_dir
+else
+ true
+fi
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_eapis_setup.sh b/paludis/repositories/e/vdb_repository_TEST_eapis_setup.sh
new file mode 100755
index 0000000..9ccbd2a
--- /dev/null
+++ b/paludis/repositories/e/vdb_repository_TEST_eapis_setup.sh
@@ -0,0 +1,269 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir -p vdb_repository_TEST_eapis_dir || exit 1
+cd vdb_repository_TEST_eapis_dir || exit 1
+
+mkdir -p distdir
+mkdir -p build
+mkdir -p root/etc
+
+mkdir -p dstrepo
+
+mkdir -p srcrepo/{profiles/profile,cat/{target,vars}{,-exheres},eclass}
+cat <<END > srcrepo/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo "srcrepo" > srcrepo/profiles/repo_name || exit 1
+
+cat <<'END' > srcrepo/cat/target/target-0.ebuild
+EAPI="0"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND="foo/bar"
+
+src_install() {
+ echo MONKEY > ${D}/monkey
+}
+
+pkg_info() {
+ echo "This is pkg_info"
+}
+
+pkg_config() {
+ echo "This is pkg_config"
+}
+END
+
+cat <<'END' > srcrepo/cat/target/target-1.ebuild
+EAPI="1"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND="foo/bar"
+
+src_install() {
+ echo MONKEY > ${D}/monkey
+}
+
+pkg_info() {
+ echo "This is pkg_info"
+}
+
+pkg_config() {
+ echo "This is pkg_config"
+}
+END
+
+cat <<'END' > srcrepo/cat/target/target-2.ebuild
+EAPI="2"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND="foo/bar"
+
+src_install() {
+ echo MONKEY > ${D}/monkey
+}
+
+pkg_info() {
+ echo "This is pkg_info"
+}
+
+pkg_config() {
+ echo "This is pkg_config"
+}
+END
+
+cat <<'END' > srcrepo/cat/target/target-3.ebuild
+EAPI="3"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND="foo/bar"
+S="${WORKDIR}"
+
+src_install() {
+ echo MONKEY > ${D}/monkey
+}
+
+pkg_info() {
+ echo "This is pkg_info"
+}
+
+pkg_config() {
+ echo "This is pkg_config"
+}
+END
+
+cat <<'END' > srcrepo/cat/target-exheres/target-exheres-0.ebuild
+EAPI="exheres-0"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS=""
+LICENCES="GPL-2"
+PLATFORMS="test"
+WORK="${WORKBASE}"
+DEPENDENCIES=""
+
+src_install() {
+ echo MONKEY > ${IMAGE}/monkey
+}
+
+pkg_info() {
+ echo "This is pkg_info"
+}
+
+pkg_config() {
+ echo "This is pkg_config"
+}
+END
+
+cat <<'END' > srcrepo/cat/vars/vars-0.ebuild
+EAPI="0"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND="foo/bar"
+
+pkg_setup() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+src_compile() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_preinst() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_prerm() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_info() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_config() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+END
+
+cat <<'END' > srcrepo/cat/vars/vars-1.ebuild
+EAPI="1"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+DEPEND="foo/bar"
+
+pkg_setup() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+src_compile() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_preinst() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_prerm() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_info() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+
+pkg_config() {
+ einfo "${EBUILD_PHASE}: T=${T}"
+ [[ -d "${T}" ]] || die "T not a dir"
+}
+END
+
+cat <<'END' > srcrepo/cat/vars-exheres/vars-exheres-0.ebuild
+EAPI="exheres-0"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS=""
+LICENCES="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES="foo/bar"
+
+pkg_setup() {
+ einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
+ [[ -d "${TEMP}" ]] || die "TEMP not a dir"
+}
+
+src_compile() {
+ einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
+ [[ -d "${TEMP}" ]] || die "TEMP not a dir"
+}
+
+pkg_preinst() {
+ einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
+ [[ -d "${TEMP}" ]] || die "TEMP not a dir"
+}
+
+pkg_prerm() {
+ einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
+ [[ -d "${TEMP}" ]] || die "TEMP not a dir"
+}
+
+pkg_info() {
+ einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
+ [[ -d "${TEMP}" ]] || die "TEMP not a dir"
+}
+
+pkg_config() {
+ einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
+ [[ -d "${TEMP}" ]] || die "TEMP not a dir"
+}
+END
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_setup.sh b/paludis/repositories/e/vdb_repository_TEST_setup.sh
index 75eb758..e5eabbe 100755
--- a/paludis/repositories/e/vdb_repository_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_repository_TEST_setup.sh
@@ -82,362 +82,6 @@ echo "exheres-0" >repo2/category/package-1/EAPI
echo "0" >repo2/category/package-1/SLOT
echo "cat/pkg1 build: cat/pkg2 build+run: cat/pkg3 suggestion: cat/pkg4 post: cat/pkg5" >repo2/category/package-1/DEPENDENCIES
-mkdir -p repo3
-
-mkdir -p srcrepo/{profiles/profile,cat/{target,vars}{,-exheres},eclass}
-cat <<END > srcrepo/profiles/profile/make.defaults
-ARCH=test
-USERLAND="GNU"
-KERNEL="linux"
-CHOST="i286-badger-linux-gnu"
-END
-echo "srcrepo" > srcrepo/profiles/repo_name || exit 1
-
-cat <<'END' > srcrepo/cat/target/target-0.ebuild
-EAPI="0"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND="foo/bar"
-
-src_install() {
- echo MONKEY > ${D}/monkey
-}
-
-pkg_info() {
- echo "This is pkg_info"
-}
-
-pkg_config() {
- echo "This is pkg_config"
-}
-END
-
-cat <<'END' > srcrepo/cat/target/target-1.ebuild
-EAPI="1"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND="foo/bar"
-
-src_install() {
- echo MONKEY > ${D}/monkey
-}
-
-pkg_info() {
- echo "This is pkg_info"
-}
-
-pkg_config() {
- echo "This is pkg_config"
-}
-END
-
-cat <<'END' > srcrepo/cat/target/target-2.ebuild
-EAPI="2"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND="foo/bar"
-
-src_install() {
- echo MONKEY > ${D}/monkey
-}
-
-pkg_info() {
- echo "This is pkg_info"
-}
-
-pkg_config() {
- echo "This is pkg_config"
-}
-END
-
-cat <<'END' > srcrepo/cat/target/target-3.ebuild
-EAPI="3"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND="foo/bar"
-S="${WORKDIR}"
-
-src_install() {
- echo MONKEY > ${D}/monkey
-}
-
-pkg_info() {
- echo "This is pkg_info"
-}
-
-pkg_config() {
- echo "This is pkg_config"
-}
-END
-
-cat <<'END' > srcrepo/cat/target-exheres/target-exheres-0.ebuild
-EAPI="exheres-0"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-DOWNLOADS=""
-SLOT="0"
-MYOPTIONS=""
-LICENCES="GPL-2"
-PLATFORMS="test"
-WORK="${WORKBASE}"
-DEPENDENCIES=""
-
-src_install() {
- echo MONKEY > ${IMAGE}/monkey
-}
-
-pkg_info() {
- echo "This is pkg_info"
-}
-
-pkg_config() {
- echo "This is pkg_config"
-}
-END
-
-cat <<'END' > srcrepo/cat/vars/vars-0.ebuild
-EAPI="0"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND="foo/bar"
-
-pkg_setup() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-src_compile() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_preinst() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_prerm() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_info() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_config() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-END
-
-cat <<'END' > srcrepo/cat/vars/vars-1.ebuild
-EAPI="1"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-DEPEND="foo/bar"
-
-pkg_setup() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-src_compile() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_preinst() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_prerm() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_info() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-
-pkg_config() {
- einfo "${EBUILD_PHASE}: T=${T}"
- [[ -d "${T}" ]] || die "T not a dir"
-}
-END
-
-cat <<'END' > srcrepo/cat/vars-exheres/vars-exheres-0.ebuild
-EAPI="exheres-0"
-DESCRIPTION="The Description"
-HOMEPAGE="http://example.com/"
-DOWNLOADS=""
-SLOT="0"
-MYOPTIONS=""
-LICENCES="GPL-2"
-PLATFORMS="test"
-DEPENDENCIES="foo/bar"
-
-pkg_setup() {
- einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
- [[ -d "${TEMP}" ]] || die "TEMP not a dir"
-}
-
-src_compile() {
- einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
- [[ -d "${TEMP}" ]] || die "TEMP not a dir"
-}
-
-pkg_preinst() {
- einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
- [[ -d "${TEMP}" ]] || die "TEMP not a dir"
-}
-
-pkg_prerm() {
- einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
- [[ -d "${TEMP}" ]] || die "TEMP not a dir"
-}
-
-pkg_info() {
- einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
- [[ -d "${TEMP}" ]] || die "TEMP not a dir"
-}
-
-pkg_config() {
- einfo "${EBUILD_PHASE}: TEMP=${TEMP}"
- [[ -d "${TEMP}" ]] || die "TEMP not a dir"
-}
-END
-
-mkdir -p namesincrtest/.cache/names/installed namesincrtest_src/{eclass,profiles/profile,cat1/{pkg1,pkg2},{cat2,cat3}/pkg1} || exit 1
-echo paludis-2 >namesincrtest/.cache/names/installed/_VERSION_
-echo installed >>namesincrtest/.cache/names/installed/_VERSION_
-
-cat <<END > namesincrtest_src/profiles/profile/make.defaults
-ARCH=test
-USERLAND="GNU"
-KERNEL="linux"
-CHOST="i286-badger-linux-gnu"
-END
-echo namesincrtest_src >namesincrtest_src/profiles/repo_name
-echo cat1 >namesincrtest_src/profiles/categories
-echo cat2 >>namesincrtest_src/profiles/categories
-echo cat3 >>namesincrtest_src/profiles/categories
-
-cat <<END >namesincrtest_src/cat1/pkg1/pkg1-1.ebuild
-KEYWORDS="test"
-SLOT="\${PV:0:1}"
-END
-cp namesincrtest_src/cat1/pkg1/pkg1-{1,1.1}.ebuild
-cp namesincrtest_src/cat1/pkg1/pkg1-{1,2}.ebuild
-cp namesincrtest_src/cat1/{pkg1/pkg1,pkg2/pkg2}-1.ebuild
-cp namesincrtest_src/{cat1,cat2}/pkg1/pkg1-1.ebuild
-
-cat <<END >namesincrtest_src/cat3/pkg1/pkg1-1.ebuild
-EAPI=paludis-1
-KEYWORDS="test"
-SLOT="0"
-END
-cp namesincrtest_src/cat3/pkg1/pkg1-{1,2}.ebuild
-
-mkdir -p providestest/{.cache,cat1/{pkg1,pkg2,pkg3}-{1,2}} || exit 1
-for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/EAPI; do
- echo 0 >${f}
-done
-for f in providestest/cat1/{pkg1,pkg2,pkg3}-1/SLOT; do
- echo 1 >${f}
-done
-for f in providestest/cat1/{pkg1,pkg2,pkg3}-2/SLOT; do
- echo 2 >${f}
-done
-for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/USE; do
- echo enabled >${f}
-done
-for f in providestest/cat1/{pkg1,pkg2,pkg3}-{1,2}/IUSE; do
- echo disabled enabled >${f}
-done
-
-echo ' virtual/foo' >providestest/cat1/pkg1-1/PROVIDE
-echo 'enabled? ( virtual/foo )' >providestest/cat1/pkg1-2/PROVIDE
-echo 'enabled? ( virtual/foo ) virtual/bar' >providestest/cat1/pkg2-1/PROVIDE
-echo 'disabled? ( virtual/foo ) virtual/bar' >providestest/cat1/pkg2-2/PROVIDE
-echo 'disabled? ( virtual/foo )' >providestest/cat1/pkg3-1/PROVIDE
-echo '' >providestest/cat1/pkg3-2/PROVIDE
-
-mkdir -p providesincrtest/.cache providesincrtest_src{1,2}/{eclass,profiles/profile,{cat1,cat2}/{pkg1,pkg2}} || exit 1
-echo paludis-3 >providesincrtest/.cache/provides
-echo installed >>providesincrtest/.cache/provides
-
-cat <<END > providesincrtest_src1/profiles/profile/make.defaults
-ARCH=test
-USERLAND="GNU"
-KERNEL="linux"
-CHOST="i286-badger-linux-gnu"
-END
-echo providesincrtest_src1 >providesincrtest_src1/profiles/repo_name
-echo providesincrtest_src2 >providesincrtest_src2/profiles/repo_name
-echo cat1 >providesincrtest_src1/profiles/categories
-echo cat2 >>providesincrtest_src1/profiles/categories
-echo cat1 >providesincrtest_src2/profiles/categories
-
-cat <<END >providesincrtest_src1/cat1/pkg1/pkg1-1.ebuild
-KEYWORDS="test"
-SLOT="\${PV:0:1}"
-PROVIDE="enabled? ( virtual/foo ) disabled? ( virtual/bar )"
-IUSE="enabled disabled"
-END
-cp providesincrtest_src1/cat1/pkg1/pkg1-{1,1.1}.ebuild
-cp providesincrtest_src1/cat1/pkg1/pkg1-{1,2}.ebuild
-cp providesincrtest_src1/cat1/{pkg1/pkg1,pkg2/pkg2}-1.ebuild
-cp providesincrtest_src1/cat1/pkg1/pkg1-1.1.ebuild providesincrtest_src2/cat1/pkg1/pkg1-1.1-r0.ebuild
-
-cat <<END >providesincrtest_src2/cat1/pkg1/pkg1-1.ebuild
-KEYWORDS="test"
-SLOT="\${PV:0:1}"
-PROVIDE="enabled? ( virtual/bar ) disabled? ( virtual/foo )"
-IUSE="enabled disabled"
-END
-
-cat <<END >providesincrtest_src1/cat2/pkg1/pkg1-1.ebuild
-EAPI=paludis-1
-KEYWORDS="test"
-SLOT="0"
-PROVIDE="virtual/moo"
-END
-cp providesincrtest_src1/cat2/pkg1/pkg1-{1,2}.ebuild
-
mkdir -p reinstalltest reinstalltest_src{1,2}/{eclass,profiles/profile,cat/pkg} || exit 1
cat <<END > reinstalltest_src1/profiles/profile/make.defaults