aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 22:57:05 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 22:57:05 +0000
commit7dbc681dbb4fdf452d0ae5074c4ef8fac1e07a34 (patch)
tree112a0468d734cf6498d0d395fc37b8ca4e0e4912
parent35a9f42174ccb4c50ecb74cf1d55c3564a76ed78 (diff)
downloadpaludis-7dbc681dbb4fdf452d0ae5074c4ef8fac1e07a34.tar.gz
paludis-7dbc681dbb4fdf452d0ae5074c4ef8fac1e07a34.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/vdb_repository_TEST_cache.cc1064
2 files changed, 475 insertions, 593 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 81436ec..1dfa2c2 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -350,13 +350,15 @@ vdb_repository_TEST_eapis_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXX
vdb_repository_TEST_cache_SOURCES = vdb_repository_TEST_cache.cc
vdb_repository_TEST_cache_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
vdb_repository_TEST_cache_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+vdb_repository_TEST_cache_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
exndbam_repository_TEST_SOURCES = exndbam_repository_TEST.cc
exndbam_repository_TEST_LDADD = \
diff --git a/paludis/repositories/e/vdb_repository_TEST_cache.cc b/paludis/repositories/e/vdb_repository_TEST_cache.cc
index 21dff28..9b5a5c0 100644
--- a/paludis/repositories/e/vdb_repository_TEST_cache.cc
+++ b/paludis/repositories/e/vdb_repository_TEST_cache.cc
@@ -20,8 +20,9 @@
#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/metadata_key.hh>
+
#include <paludis/util/sequence.hh>
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
@@ -29,6 +30,11 @@
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/fs_iterator.hh>
#include <paludis/util/fs_stat.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+
+#include <paludis/metadata_key.hh>
#include <paludis/standard_output_manager.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
@@ -40,17 +46,13 @@
#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;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -85,595 +87,473 @@ namespace
{
return false;
}
+
+ void install(const Environment & env,
+ const std::shared_ptr<Repository> & vdb_repo,
+ const std::string & chosen_one,
+ const std::string & victim)
+ {
+ 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 read_cache(const FSPath & names_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();
+ }
}
-namespace test_cases
+TEST(NamesCache, Incremental)
{
- 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,
+ FSPath names_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "namesincrtest/.cache/names/installed"));
+
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "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.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.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(names_cache, cache_contents);
+ EXPECT_EQ(0U, cache_contents.size());
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1.1::namesincrtest_src", "=cat1/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::namesincrtest_src", "=cat1/pkg1-1.1::installed");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-2::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ 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());
- 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;
- 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.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.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;
- 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.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,
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg2-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(2U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("pkg2", cache_contents.back().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg2"));
+ }
+
+ {
+ 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());
- 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;
- 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.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.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.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;
+ inst_id->perform_action(uninstall_action);
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat2/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\ncat2\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ 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(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat1\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ 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(names_cache, cache_contents);
+ EXPECT_EQ(0U, cache_contents.size());
+ }
+
+ {
+ install(env, vdb_repo, "=cat3/pkg1-1::namesincrtest_src", "");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat3\n", read_file(names_cache / "pkg1"));
+ }
+
+ {
+ install(env, vdb_repo, "=cat3/pkg1-2::namesincrtest_src", "=cat3/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ std::vector<FSPath> cache_contents;
+ read_cache(names_cache, cache_contents);
+ EXPECT_EQ(1U, cache_contents.size());
+ EXPECT_EQ("pkg1", cache_contents.front().basename());
+ EXPECT_EQ("cat3\n", read_file(names_cache / "pkg1"));
+ }
+}
+
+TEST(ProvidesCache, Works)
+{
+ FSPath provides_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providestest/.cache/provides"));
+
+ TestEnvironment env;
+ 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.add_repository(0, vdb_repo);
+
+ ASSERT_TRUE(! 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)
+
+ EXPECT_EQ(5, std::distance(seq->begin(), seq->end()));
+
+ RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
+ EXPECT_EQ("virtual/foo", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg1-1:1::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/foo", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg1-2:2::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/foo", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg2-1:1::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/bar", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg2-1:1::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/bar", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg2-2:2::installed", stringify(*(*it++).provided_by()));
+ }
+
+ vdb_repo->regenerate_cache();
+ EXPECT_EQ("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", read_file(provides_cache));
+ vdb_repo->invalidate();
+
+ {
+ std::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence> seq(vdb_repo->provides_interface()->provided_packages());
+ EXPECT_EQ(5, std::distance(seq->begin(), seq->end()));
+
+ for (auto i(seq->begin()), i_end(seq->end()) ;
+ i != i_end ; ++i)
+ ASSERT_TRUE(! stringify(i->provided_by()->slot_key()->value()).empty());
+
+ RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
+ EXPECT_EQ("virtual/foo", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg1-1:1::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/foo", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg1-2:2::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/foo", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg2-1:1::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/bar", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg2-1:1::installed", stringify(*(*it++).provided_by()));
+ EXPECT_EQ("virtual/bar", stringify(it->virtual_name()));
+ EXPECT_EQ("cat1/pkg2-2:2::installed", stringify(*(*it++).provided_by()));
+ }
+}
+
+TEST(ProvidesCache, Incremental)
+{
+ FSPath provides_cache(stringify(FSPath::cwd() / "vdb_repository_TEST_cache_dir" / "providesincrtest/.cache/provides"));
+
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "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.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.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.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
+ ));
+
+ EXPECT_EQ("paludis-3\ninstalled\n", read_file(provides_cache));
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1.1::providesincrtest_src1", "=cat1/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1.1 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1.1::providesincrtest_src2", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1.1-r0 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src1", "=cat1/pkg1-1.1::installed");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-1::providesincrtest_src2", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg1-2::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\ncat1/pkg1 2 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ 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();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat1/pkg2-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\ncat1/pkg2 1 virtual/foo\n", read_file(provides_cache));
+ }
+
+ {
+ 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();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat1/pkg1 1 virtual/bar\n", read_file(provides_cache));
+ }
+
+ {
+ 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();
+
+ EXPECT_EQ("paludis-3\ninstalled\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat2/pkg1-1::providesincrtest_src1", "");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat2/pkg1 1 virtual/moo\n", read_file(provides_cache));
+ }
+
+ {
+ install(env, vdb_repo, "=cat2/pkg1-2::providesincrtest_src1", "=cat2/pkg1-1::installed");
+ vdb_repo->invalidate();
+
+ EXPECT_EQ("paludis-3\ninstalled\ncat2/pkg1 2 virtual/moo\n", read_file(provides_cache));
+ }
}