aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/vdb_repository_TEST.cc
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/repositories/e/vdb_repository_TEST.cc')
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc850
1 files changed, 0 insertions, 850 deletions
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 2d4ec6939..15e8d2c2f 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") { }