aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-25 11:46:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-25 16:55:34 +0000
commitf9a3c30b1e96d8288068dbea0ea7c4447f3654bb (patch)
treee28474a602af4316107d5a081eda6b30bbb4d03b
parentd95b2ec676cd49c2d31990a6316f4a14a0fec6aa (diff)
downloadpaludis-f9a3c30b1e96d8288068dbea0ea7c4447f3654bb.tar.gz
paludis-f9a3c30b1e96d8288068dbea0ea7c4447f3654bb.tar.xz
gtest more
-rw-r--r--paludis/repositories/unpackaged/Makefile.am9
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc958
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc486
3 files changed, 676 insertions, 777 deletions
diff --git a/paludis/repositories/unpackaged/Makefile.am b/paludis/repositories/unpackaged/Makefile.am
index 9ef30d0..ce9ea21 100644
--- a/paludis/repositories/unpackaged/Makefile.am
+++ b/paludis/repositories/unpackaged/Makefile.am
@@ -34,23 +34,28 @@ libpaludisunpackagedrepository_la_SOURCES = \
unpackaged_repository_TEST_SOURCES = unpackaged_repository_TEST.cc
unpackaged_repository_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
unpackaged_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+unpackaged_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
installed_repository_TEST_SOURCES = installed_repository_TEST.cc
installed_repository_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(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)
installed_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+installed_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
EXTRA_DIST = \
unpackaged_repository_TEST.cc \
unpackaged_repository_TEST_setup.sh \
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index ff55498..9dc5b0c 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -19,7 +19,9 @@
#include <paludis/repositories/unpackaged/unpackaged_repository.hh>
#include <paludis/repositories/unpackaged/installed_repository.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
#include <paludis/action.hh>
@@ -30,6 +32,7 @@
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
#include <paludis/standard_output_manager.hh>
+
#include <paludis/util/sequence.hh>
#include <paludis/util/join.hh>
#include <paludis/util/options.hh>
@@ -38,12 +41,12 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/util/fs_stat.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
#include <algorithm>
#include <sstream>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -95,560 +98,493 @@ namespace
}
}
-namespace test_cases
+TEST(InstalledRepository, Content)
{
- struct MembersTest : TestCase
- {
- MembersTest() : TestCase("members") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo1"),
- n::root() = FSPath("installed_repository_TEST_dir/root")
- )));
- env.package_database()->add_repository(1, repo);
-
- const std::shared_ptr<const PackageIDSequence> ids(
- env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "),
- "cat-one/foo-1:0::installed-unpackaged cat-one/foo-2:1::installed-unpackaged");
- }
- } test_members;
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo1"),
+ n::root() = FSPath("installed_repository_TEST_dir/root")
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageIDSequence> ids(
+ env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("cat-one/foo-1:0::installed-unpackaged cat-one/foo-2:1::installed-unpackaged",
+ join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+}
- struct MetadataTest : TestCase
- {
- MetadataTest() : TestCase("metadata") { }
+TEST(InstalledRepository, Metadata)
+{
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo1"),
+ n::root() = FSPath("installed_repository_TEST_dir/root")
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("cat-one/foo:0",
+ &env, { }), make_null_shared_ptr(), { }))]->begin());
+
+ EXPECT_EQ(id1->version(), VersionSpec("1", { }));
+ EXPECT_EQ(SlotName("0"), id1->slot_key()->value());
+ EXPECT_EQ(QualifiedPackageName("cat-one/foo"), id1->name());
+ EXPECT_EQ(RepositoryName("installed-unpackaged"), id1->repository_name());
+ EXPECT_TRUE(bool(id1->fs_location_key()));
+ EXPECT_EQ(id1->fs_location_key()->value(), FSPath::cwd() / "installed_repository_TEST_dir/repo1/data/giant-space-weasel/1:0:foo/");
+
+ EXPECT_TRUE(bool(id1->contents_key()));
+ ContentsDumper d1;
+ std::for_each(indirect_iterator(id1->contents_key()->value()->begin()),
+ indirect_iterator(id1->contents_key()->value()->end()), accept_visitor(d1));
+ EXPECT_EQ("dir</fnord>", d1.s.str());
+
+ const std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("cat-one/foo:1",
+ &env, { }), make_null_shared_ptr(), { }))]->begin());
+
+ EXPECT_EQ(id2->version(), VersionSpec("2", { }));
+ EXPECT_EQ(SlotName("1"), id2->slot_key()->value());
+ EXPECT_EQ(QualifiedPackageName("cat-one/foo"), id2->name());
+ EXPECT_EQ(RepositoryName("installed-unpackaged"), id2->repository_name());
+ EXPECT_TRUE(bool(id2->fs_location_key()));
+ EXPECT_EQ(id2->fs_location_key()->value(), FSPath::cwd() / "installed_repository_TEST_dir/repo1/data/giant-space-weasel/2:1:bar/");
+
+ EXPECT_TRUE(bool(id2->contents_key()));
+ ContentsDumper d2;
+ std::for_each(indirect_iterator(id2->contents_key()->value()->begin()),
+ indirect_iterator(id2->contents_key()->value()->end()), accept_visitor(d2));
+ EXPECT_EQ("dir</stilton>file</stilton/cheese>file</stilton/is delicious>", d2.s.str());
+}
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo1"),
- n::root() = FSPath("installed_repository_TEST_dir/root")
- )));
- env.package_database()->add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("cat-one/foo:0",
- &env, { }), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK_EQUAL(id1->version(), VersionSpec("1", { }));
- TEST_CHECK_EQUAL(id1->slot_key()->value(), SlotName("0"));
- TEST_CHECK_EQUAL(id1->name(), QualifiedPackageName("cat-one/foo"));
- TEST_CHECK_EQUAL(id1->repository_name(), RepositoryName("installed-unpackaged"));
- TEST_CHECK(bool(id1->fs_location_key()));
- TEST_CHECK_EQUAL(id1->fs_location_key()->value(),
- FSPath::cwd() / "installed_repository_TEST_dir/repo1/data/giant-space-weasel/1:0:foo/");
-
- TEST_CHECK(bool(id1->contents_key()));
- ContentsDumper d1;
- std::for_each(indirect_iterator(id1->contents_key()->value()->begin()),
- indirect_iterator(id1->contents_key()->value()->end()), accept_visitor(d1));
- TEST_CHECK_EQUAL(d1.s.str(), "dir</fnord>");
-
- const std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("cat-one/foo:1",
- &env, { }), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK_EQUAL(id2->version(), VersionSpec("2", { }));
- TEST_CHECK_EQUAL(id2->slot_key()->value(), SlotName("1"));
- TEST_CHECK_EQUAL(id2->name(), QualifiedPackageName("cat-one/foo"));
- TEST_CHECK_EQUAL(id2->repository_name(), RepositoryName("installed-unpackaged"));
- TEST_CHECK(bool(id2->fs_location_key()));
- TEST_CHECK_EQUAL(id2->fs_location_key()->value(),
- FSPath::cwd() / "installed_repository_TEST_dir/repo1/data/giant-space-weasel/2:1:bar/");
-
- TEST_CHECK(bool(id2->contents_key()));
- ContentsDumper d2;
- std::for_each(indirect_iterator(id2->contents_key()->value()->begin()),
- indirect_iterator(id2->contents_key()->value()->end()), accept_visitor(d2));
- TEST_CHECK_EQUAL(d2.s.str(), "dir</stilton>file</stilton/cheese>file</stilton/is delicious>");
- }
- } test_metadata;
+TEST(InstalledRepository, Masks)
+{
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo1"),
+ n::root() = FSPath("installed_repository_TEST_dir/root")
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("cat-one/foo:0",
+ &env, { }), make_null_shared_ptr(), { }))]->begin());
+
+ EXPECT_TRUE(! id1->masked());
+
+ const std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("cat-one/foo:1",
+ &env, { }), make_null_shared_ptr(), { }))]->begin());
+
+ EXPECT_TRUE(! id2->masked());
+}
- struct MasksTest : TestCase
- {
- MasksTest() : TestCase("masks") { }
+TEST(InstalledRepository, Actions)
+{
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo1"),
+ n::root() = FSPath("installed_repository_TEST_dir/root")
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<InstallAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<ConfigAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<PretendAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<InfoAction>()));
+ EXPECT_TRUE(repo->some_ids_might_support_action(SupportsActionTest<UninstallAction>()));
+
+ const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("cat-one/foo:1",
+ &env, { }), make_null_shared_ptr(), { }))]->begin());
+
+ EXPECT_TRUE(! id1->supports_action(SupportsActionTest<InstallAction>()));
+ EXPECT_TRUE(! id1->supports_action(SupportsActionTest<ConfigAction>()));
+ EXPECT_TRUE(! id1->supports_action(SupportsActionTest<PretendAction>()));
+ EXPECT_TRUE(! id1->supports_action(SupportsActionTest<InfoAction>()));
+ EXPECT_TRUE(id1->supports_action(SupportsActionTest<UninstallAction>()));
+}
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo1"),
- n::root() = FSPath("installed_repository_TEST_dir/root")
- )));
- env.package_database()->add_repository(1, repo);
+TEST(InstalledRepository, UninstallLast)
+{
+ TestEnvironment env;
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("cat-one/foo:0",
- &env, { }), make_null_shared_ptr(), { }))]->begin());
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo2"),
+ n::root() = FSPath("installed_repository_TEST_dir/root2")
+ )));
+ env.package_database()->add_repository(1, repo);
- TEST_CHECK(! id1->masked());
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("cat-one/foo-1.2.3:fred::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
- const std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("cat-one/foo:1",
- &env, { }), make_null_shared_ptr(), { }))]->begin());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root2/first").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root2/second").stat().is_regular_file());
- TEST_CHECK(! id2->masked());
- }
- } test_masks;
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/repo2/indices/categories/cat-one/foo").stat().is_symlink());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/repo2/indices/packages/foo/cat-one").stat().is_symlink());
- struct ActionsTest : TestCase
- {
- ActionsTest() : TestCase("actions") { }
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::All())]->begin());
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo1"),
- n::root() = FSPath("installed_repository_TEST_dir/root")
- )));
- env.package_database()->add_repository(1, repo);
-
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<InstallAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<ConfigAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<PretendAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<InfoAction>()));
- TEST_CHECK(repo->some_ids_might_support_action(SupportsActionTest<UninstallAction>()));
-
- const std::shared_ptr<const PackageID> id1(*env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("cat-one/foo:1",
- &env, { }), make_null_shared_ptr(), { }))]->begin());
-
- TEST_CHECK(! id1->supports_action(SupportsActionTest<InstallAction>()));
- TEST_CHECK(! id1->supports_action(SupportsActionTest<ConfigAction>()));
- TEST_CHECK(! id1->supports_action(SupportsActionTest<PretendAction>()));
- TEST_CHECK(! id1->supports_action(SupportsActionTest<InfoAction>()));
- TEST_CHECK(id1->supports_action(SupportsActionTest<UninstallAction>()));
- }
- } test_actions;
+ UninstallAction 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
+ ));
+ id->perform_action(action);
- struct UninstallLastTest : TestCase
- {
- UninstallLastTest() : TestCase("uninstall last") { }
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root2/first").stat().exists());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root2/second").stat().is_regular_file());
- void run()
- {
- TestEnvironment env;
-
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo2"),
- n::root() = FSPath("installed_repository_TEST_dir/root2")
- )));
- env.package_database()->add_repository(1, repo);
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/repo2/indices/categories/cat-one/foo").stat().is_symlink());
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/repo2/indices/packages/foo/cat-one").stat().is_symlink());
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat-one/foo-1.2.3:fred::installed-unpackaged");
+ repo->invalidate();
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root2/first").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root2/second").stat().is_regular_file());
+ const std::shared_ptr<const PackageIDSequence> post_ids(env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("", join(indirect_iterator(post_ids->begin()),
+ indirect_iterator(post_ids->end()), " "));
+}
- TEST_CHECK(FSPath("installed_repository_TEST_dir/repo2/indices/categories/cat-one/foo").stat().is_symlink());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/repo2/indices/packages/foo/cat-one").stat().is_symlink());
+TEST(InstalledRepository, UninstallNotLast)
+{
+ TestEnvironment env;
+
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo3"),
+ n::root() = FSPath("installed_repository_TEST_dir/root3")
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("cat-one/foo-1.2.3:fred::installed-unpackaged cat-one/foo-3.2.1:barney::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/repo3/indices/categories/cat-one/foo").stat().is_symlink());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/repo3/indices/packages/foo/cat-one").stat().is_symlink());
+
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(
+ generator::Matches(parse_user_package_dep_spec("cat-one/foo:fred",
+ &env, { }), make_null_shared_ptr(), { }))]->begin());
+
+ UninstallAction 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
+ ));
+ id->perform_action(action);
+
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/repo3/indices/categories/cat-one/foo").stat().is_symlink());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/repo3/indices/packages/foo/cat-one").stat().is_symlink());
+
+ repo->invalidate();
+
+ const std::shared_ptr<const PackageIDSequence> post_ids(env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("cat-one/foo-3.2.1:barney::installed-unpackaged",
+ join(indirect_iterator(post_ids->begin()), indirect_iterator(post_ids->end()), " "));
+}
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::All())]->begin());
+TEST(InstalledRepository, MultipleOps)
+{
+ {
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo4"),
+ n::root() = FSPath("installed_repository_TEST_dir/root4")
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("", join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir").stat().exists());
+ }
- UninstallAction 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
- ));
- id->perform_action(action);
+ {
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo4"),
+ n::root() = FSPath("installed_repository_TEST_dir/root4")
+ )));
+ env.package_database()->add_repository(0, repo);
+
+ std::shared_ptr<Repository> source_repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("installed_repository_TEST_dir/src4a"),
+ n::name() = QualifiedPackageName("cat/pkg4a"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, source_repo);
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root2/first").stat().exists());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root2/second").stat().is_regular_file());
+ {
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("", join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+ }
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/repo2/indices/categories/cat-one/foo").stat().is_symlink());
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/repo2/indices/packages/foo/cat-one").stat().is_symlink());
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir").stat().exists());
- repo->invalidate();
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+ (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
- const std::shared_ptr<const PackageIDSequence> post_ids(env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(post_ids->begin()), indirect_iterator(post_ids->end()), " "), "");
- }
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
- bool repeatable() const
+ repo->invalidate();
{
- return false;
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4a-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
}
- } test_uninstall_last;
+ }
- struct UninstallNotLastTest : TestCase
{
- UninstallNotLastTest() : TestCase("uninstall not last") { }
-
- void run()
- {
- TestEnvironment env;
-
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo3"),
- n::root() = FSPath("installed_repository_TEST_dir/root3")
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo4"),
+ n::root() = FSPath("installed_repository_TEST_dir/root4")
+ )));
+ env.package_database()->add_repository(0, repo);
+
+ std::shared_ptr<Repository> source_repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("installed_repository_TEST_dir/src4b1"),
+ n::name() = QualifiedPackageName("cat/pkg4b"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
)));
- env.package_database()->add_repository(1, repo);
+ env.package_database()->add_repository(1, source_repo);
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat-one/foo-1.2.3:fred::installed-unpackaged cat-one/foo-3.2.1:barney::installed-unpackaged");
+ {
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4a-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+ }
- TEST_CHECK(FSPath("installed_repository_TEST_dir/repo3/indices/categories/cat-one/foo").stat().is_symlink());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/repo3/indices/packages/foo/cat-one").stat().is_symlink());
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+ (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
+
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4b").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4b1").stat().is_regular_file());
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir/4b2").stat().is_regular_file());
+
+ repo->invalidate();
+ {
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+ }
+ }
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(
- generator::Matches(parse_user_package_dep_spec("cat-one/foo:fred",
- &env, { }), make_null_shared_ptr(), { }))]->begin());
+ {
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo4"),
+ n::root() = FSPath("installed_repository_TEST_dir/root4")
+ )));
+ env.package_database()->add_repository(0, repo);
+
+ std::shared_ptr<Repository> source_repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("installed_repository_TEST_dir/src4b2"),
+ n::name() = QualifiedPackageName("cat/pkg4b"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, source_repo);
- UninstallAction 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
- ));
- id->perform_action(action);
+ {
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+ }
- TEST_CHECK(FSPath("installed_repository_TEST_dir/repo3/indices/categories/cat-one/foo").stat().is_symlink());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/repo3/indices/packages/foo/cat-one").stat().is_symlink());
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+ (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
+
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4b").stat().is_regular_file());
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir/4b1").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4b2").stat().is_regular_file());
+
+ repo->invalidate();
+ {
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
+ }
+ }
- repo->invalidate();
+ {
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo4"),
+ n::root() = FSPath("installed_repository_TEST_dir/root4")
+ )));
+ env.package_database()->add_repository(0, repo);
- const std::shared_ptr<const PackageIDSequence> post_ids(env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(post_ids->begin()), indirect_iterator(post_ids->end()), " "),
- "cat-one/foo-3.2.1:barney::installed-unpackaged");
+ {
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
}
- bool repeatable() const
+ UninstallAction 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
+ ));
+ (*env[selection::RequireExactlyOne(generator::Matches(
+ parse_user_package_dep_spec("cat/pkg4a",
+ &env, { }), make_null_shared_ptr(), { }))]->begin())->perform_action(action);
+
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4b").stat().is_regular_file());
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir/4b1").stat().is_regular_file());
+ EXPECT_TRUE(FSPath("installed_repository_TEST_dir/root4/dir/4b2").stat().is_regular_file());
+
+ repo->invalidate();
{
- return false;
+ const std::shared_ptr<const PackageIDSequence> pre_ids(
+ env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4b-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
}
- } test_uninstall_not_last;
+ }
- struct MultipleOpsTest : TestCase
{
- MultipleOpsTest() : TestCase("multiple ops") { }
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("installed_repository_TEST_dir/repo4"),
+ n::root() = FSPath("installed_repository_TEST_dir/root4")
+ )));
+ env.package_database()->add_repository(0, repo);
- void run()
{
- {
- TestMessageSuffix suffix("initial", true);
-
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo4"),
- n::root() = FSPath("installed_repository_TEST_dir/root4")
- )));
- env.package_database()->add_repository(1, repo);
-
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "), "");
-
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir").stat().exists());
- }
-
- {
- TestMessageSuffix suffix("install 4a", true);
-
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo4"),
- n::root() = FSPath("installed_repository_TEST_dir/root4")
- )));
- env.package_database()->add_repository(0, repo);
-
- std::shared_ptr<Repository> source_repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("installed_repository_TEST_dir/src4a"),
- n::name() = QualifiedPackageName("cat/pkg4a"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, source_repo);
-
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "), "");
- }
-
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir").stat().exists());
-
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &cannot_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
- (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
-
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
-
- repo->invalidate();
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4a-1.0:foo::installed-unpackaged");
- }
- }
-
- {
- TestMessageSuffix suffix("install 4b1", true);
-
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo4"),
- n::root() = FSPath("installed_repository_TEST_dir/root4")
- )));
- env.package_database()->add_repository(0, repo);
-
- std::shared_ptr<Repository> source_repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("installed_repository_TEST_dir/src4b1"),
- n::name() = QualifiedPackageName("cat/pkg4b"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, source_repo);
-
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4a-1.0:foo::installed-unpackaged");
- }
-
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &cannot_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
- (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
-
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4b").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4b1").stat().is_regular_file());
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir/4b2").stat().is_regular_file());
-
- repo->invalidate();
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged");
- }
- }
-
- {
- TestMessageSuffix suffix("install 4b2", true);
-
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo4"),
- n::root() = FSPath("installed_repository_TEST_dir/root4")
- )));
- env.package_database()->add_repository(0, repo);
-
- std::shared_ptr<Repository> source_repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("installed_repository_TEST_dir/src4b2"),
- n::name() = QualifiedPackageName("cat/pkg4b"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, source_repo);
-
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged");
- }
-
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &cannot_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
- (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
-
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4b").stat().is_regular_file());
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir/4b1").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4b2").stat().is_regular_file());
-
- repo->invalidate();
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged");
- }
- }
-
- {
- TestMessageSuffix suffix("uninstall 4a", true);
-
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo4"),
- n::root() = FSPath("installed_repository_TEST_dir/root4")
- )));
- env.package_database()->add_repository(0, repo);
-
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged");
- }
-
- UninstallAction 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
- ));
- (*env[selection::RequireExactlyOne(generator::Matches(
- parse_user_package_dep_spec("cat/pkg4a",
- &env, { }), make_null_shared_ptr(), { }))]->begin())->perform_action(action);
-
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir/4a").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4b").stat().is_regular_file());
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir/4b1").stat().is_regular_file());
- TEST_CHECK(FSPath("installed_repository_TEST_dir/root4/dir/4b2").stat().is_regular_file());
-
- repo->invalidate();
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(
- env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4b-1.0:foo::installed-unpackaged");
- }
- }
-
- {
- TestMessageSuffix suffix("uninstall 4b", true);
-
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("installed_repository_TEST_dir/repo4"),
- n::root() = FSPath("installed_repository_TEST_dir/root4")
- )));
- env.package_database()->add_repository(0, repo);
-
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "cat/pkg4b-1.0:foo::installed-unpackaged");
- }
-
- UninstallAction 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
- ));
- (*env[selection::RequireExactlyOne(generator::Matches(
- parse_user_package_dep_spec("cat/pkg4b",
- &env, { }), make_null_shared_ptr(), { }))]->begin())->perform_action(action);
-
- TEST_CHECK(! FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
-
- repo->invalidate();
- {
- const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("installed-unpackaged")))]);
- TEST_CHECK_EQUAL(join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "),
- "");
- }
- }
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("cat/pkg4b-1.0:foo::installed-unpackaged",
+ join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
}
- bool repeatable() const
+ UninstallAction 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
+ ));
+ (*env[selection::RequireExactlyOne(generator::Matches(
+ parse_user_package_dep_spec("cat/pkg4b",
+ &env, { }), make_null_shared_ptr(), { }))]->begin())->perform_action(action);
+
+ EXPECT_TRUE(! FSPath("installed_repository_TEST_dir/root4/dir").stat().is_directory());
+
+ repo->invalidate();
{
- return false;
+ const std::shared_ptr<const PackageIDSequence> pre_ids(env[selection::AllVersionsSorted(
+ generator::InRepository(RepositoryName("installed-unpackaged")))]);
+ EXPECT_EQ("", join(indirect_iterator(pre_ids->begin()), indirect_iterator(pre_ids->end()), " "));
}
- } test_multiple_ops;
+ }
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index cd91cb2..0d89315 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 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
@@ -19,7 +19,9 @@
#include <paludis/repositories/unpackaged/unpackaged_repository.hh>
#include <paludis/repositories/unpackaged/installed_repository.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
#include <paludis/action.hh>
@@ -28,17 +30,17 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
+#include <paludis/standard_output_manager.hh>
+
#include <paludis/util/sequence.hh>
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/fs_stat.hh>
-#include <paludis/standard_output_manager.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -64,265 +66,221 @@ namespace
}
}
-namespace test_cases
+TEST(UnpackagedRepository, Members)
{
- struct MembersTest : TestCase
- {
- MembersTest() : TestCase("members") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
- n::name() = QualifiedPackageName("cat/pkg"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, repo);
-
- const std::shared_ptr<const PackageIDSequence> ids(
- env[selection::AllVersionsSorted(generator::All())]);
- TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "),
- "cat/pkg-1.0:foo::unpackaged");
- }
- } test_members;
-
- struct MetadataTest : TestCase
- {
- MetadataTest() : TestCase("metadata") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
- n::name() = QualifiedPackageName("cat/pkg"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id(
- *env[selection::RequireExactlyOne(generator::All())]->begin());
-
- TEST_CHECK_EQUAL(id->version(), VersionSpec("1.0", { }));
- TEST_CHECK_EQUAL(id->slot_key()->value(), SlotName("foo"));
- TEST_CHECK_EQUAL(id->name(), QualifiedPackageName("cat/pkg"));
- TEST_CHECK_EQUAL(id->repository_name(), RepositoryName("unpackaged"));
- TEST_CHECK(bool(id->fs_location_key()));
- TEST_CHECK_EQUAL(id->fs_location_key()->value(), FSPath("unpackaged_repository_TEST_dir/pkg"));
- }
- } test_metadata;
-
- struct MasksTest : TestCase
- {
- MasksTest() : TestCase("masks") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
- n::name() = QualifiedPackageName("cat/pkg"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, repo);
-
- const std::shared_ptr<const PackageID> id(
- *env[selection::RequireExactlyOne(generator::All())]->begin());
-
- TEST_CHECK(! id->masked());
- }
- } test_masks;
-
- struct ActionsTest : TestCase
- {
- ActionsTest() : TestCase("actions") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
- n::name() = QualifiedPackageName("cat/pkg"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, repo);
-
- TEST_CHECK(repo->some_ids_might_support_action(SupportsActionTest<InstallAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<ConfigAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<PretendAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<InfoAction>()));
- TEST_CHECK(! repo->some_ids_might_support_action(SupportsActionTest<UninstallAction>()));
-
- const std::shared_ptr<const PackageID> id(
- *env[selection::RequireExactlyOne(generator::All())]->begin());
-
- TEST_CHECK(id->supports_action(SupportsActionTest<InstallAction>()));
- TEST_CHECK(! id->supports_action(SupportsActionTest<ConfigAction>()));
- TEST_CHECK(! id->supports_action(SupportsActionTest<PretendAction>()));
- TEST_CHECK(! id->supports_action(SupportsActionTest<InfoAction>()));
- TEST_CHECK(! id->supports_action(SupportsActionTest<UninstallAction>()));
- }
- } test_actions;
-
- struct InstallTest : TestCase
- {
- InstallTest() : TestCase("install") { }
-
- void run()
- {
- TestEnvironment env;
-
- std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/"),
- n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
- n::name() = QualifiedPackageName("cat/pkg"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, repo);
-
- std::shared_ptr<Repository> installed_repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("unpackaged_repository_TEST_dir/installed"),
- n::root() = FSPath("unpackaged_repository_TEST_dir/root")
- )));
- env.package_database()->add_repository(0, installed_repo);
-
- TEST_CHECK(! FSPath("unpackaged_repository_TEST_dir/root/first").stat().is_regular_file());
-
- const std::shared_ptr<const PackageID> id(
- *env[selection::RequireExactlyOne(generator::All())]->begin());
-
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &cannot_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
- id->perform_action(action);
-
- TEST_CHECK(FSPath("unpackaged_repository_TEST_dir/root/first").stat().is_regular_file());
- }
-
- bool repeatable() const
- {
- return false;
- }
- } test_install;
-
- struct InstallUnderTest : TestCase
- {
- InstallUnderTest() : TestCase("install under") { }
-
- void run()
- {
- TestEnvironment env;
-
- std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
- RepositoryName("unpackaged"),
- make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
- n::build_dependencies() = "",
- n::description() = "",
- n::environment() = &env,
- n::install_under() = FSPath("/magic/pixie"),
- n::location() = FSPath("unpackaged_repository_TEST_dir/under_pkg"),
- n::name() = QualifiedPackageName("cat/pkg"),
- n::preserve_work() = indeterminate,
- n::rewrite_ids_over_to_root() = -1,
- n::run_dependencies() = "",
- n::slot() = SlotName("foo"),
- n::strip() = indeterminate,
- n::version() = VersionSpec("1.0", { })
- )));
- env.package_database()->add_repository(1, repo);
-
- std::shared_ptr<Repository> installed_repo(std::make_shared<InstalledUnpackagedRepository>(
- RepositoryName("installed-unpackaged"),
- make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
- n::environment() = &env,
- n::location() = FSPath("unpackaged_repository_TEST_dir/under_installed"),
- n::root() = FSPath("unpackaged_repository_TEST_dir/under_root")
- )));
- env.package_database()->add_repository(0, installed_repo);
-
- TEST_CHECK(! FSPath("unpackaged_repository_TEST_dir/under_root/magic/pixie/first").stat().is_regular_file());
-
- const std::shared_ptr<const PackageID> id(
- *env[selection::RequireExactlyOne(generator::All())]->begin());
-
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &cannot_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
- id->perform_action(action);
-
- TEST_CHECK(FSPath("unpackaged_repository_TEST_dir/under_root/magic/pixie/first").stat().is_regular_file());
- }
-
- bool repeatable() const
- {
- return false;
- }
- } test_install_under;
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
+ n::name() = QualifiedPackageName("cat/pkg"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageIDSequence> ids(
+ env[selection::AllVersionsSorted(generator::All())]);
+ EXPECT_EQ("cat/pkg-1.0:foo::unpackaged", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+}
+
+TEST(UnpackagedRepository, Metadata)
+{
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
+ n::name() = QualifiedPackageName("cat/pkg"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id(
+ *env[selection::RequireExactlyOne(generator::All())]->begin());
+
+ EXPECT_EQ(id->version(), VersionSpec("1.0", { }));
+ EXPECT_EQ(SlotName("foo"), id->slot_key()->value());
+ EXPECT_EQ(QualifiedPackageName("cat/pkg"), id->name());
+ EXPECT_EQ(RepositoryName("unpackaged"), id->repository_name());
+ ASSERT_TRUE(bool(id->fs_location_key()));
+ EXPECT_EQ(FSPath("unpackaged_repository_TEST_dir/pkg"), id->fs_location_key()->value());
+}
+
+TEST(UnpackagedRepository, Masks)
+{
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
+ n::name() = QualifiedPackageName("cat/pkg"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ const std::shared_ptr<const PackageID> id(
+ *env[selection::RequireExactlyOne(generator::All())]->begin());
+
+ EXPECT_TRUE(! id->masked());
+}
+
+TEST(UnpackagedRepository, Actions)
+{
+ TestEnvironment env;
+ std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
+ n::name() = QualifiedPackageName("cat/pkg"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ EXPECT_TRUE(repo->some_ids_might_support_action(SupportsActionTest<InstallAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<ConfigAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<PretendAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<InfoAction>()));
+ EXPECT_TRUE(! repo->some_ids_might_support_action(SupportsActionTest<UninstallAction>()));
+
+ const std::shared_ptr<const PackageID> id(
+ *env[selection::RequireExactlyOne(generator::All())]->begin());
+
+ EXPECT_TRUE(id->supports_action(SupportsActionTest<InstallAction>()));
+ EXPECT_TRUE(! id->supports_action(SupportsActionTest<ConfigAction>()));
+ EXPECT_TRUE(! id->supports_action(SupportsActionTest<PretendAction>()));
+ EXPECT_TRUE(! id->supports_action(SupportsActionTest<InfoAction>()));
+ EXPECT_TRUE(! id->supports_action(SupportsActionTest<UninstallAction>()));
+}
+
+TEST(UnpackagedRepository, Install)
+{
+ TestEnvironment env;
+
+ std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/"),
+ n::location() = FSPath("unpackaged_repository_TEST_dir/pkg"),
+ n::name() = QualifiedPackageName("cat/pkg"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ std::shared_ptr<Repository> installed_repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("unpackaged_repository_TEST_dir/installed"),
+ n::root() = FSPath("unpackaged_repository_TEST_dir/root")
+ )));
+ env.package_database()->add_repository(0, installed_repo);
+
+ EXPECT_TRUE(! FSPath("unpackaged_repository_TEST_dir/root/first").stat().is_regular_file());
+
+ const std::shared_ptr<const PackageID> id(
+ *env[selection::RequireExactlyOne(generator::All())]->begin());
+
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = installed_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+ id->perform_action(action);
+
+ EXPECT_TRUE(FSPath("unpackaged_repository_TEST_dir/root/first").stat().is_regular_file());
+}
+
+TEST(UnpackagedRepository, InstallUnder)
+{
+ TestEnvironment env;
+
+ std::shared_ptr<Repository> repo(std::make_shared<UnpackagedRepository>(
+ RepositoryName("unpackaged"),
+ make_named_values<unpackaged_repositories::UnpackagedRepositoryParams>(
+ n::build_dependencies() = "",
+ n::description() = "",
+ n::environment() = &env,
+ n::install_under() = FSPath("/magic/pixie"),
+ n::location() = FSPath("unpackaged_repository_TEST_dir/under_pkg"),
+ n::name() = QualifiedPackageName("cat/pkg"),
+ n::preserve_work() = indeterminate,
+ n::rewrite_ids_over_to_root() = -1,
+ n::run_dependencies() = "",
+ n::slot() = SlotName("foo"),
+ n::strip() = indeterminate,
+ n::version() = VersionSpec("1.0", { })
+ )));
+ env.package_database()->add_repository(1, repo);
+
+ std::shared_ptr<Repository> installed_repo(std::make_shared<InstalledUnpackagedRepository>(
+ RepositoryName("installed-unpackaged"),
+ make_named_values<unpackaged_repositories::InstalledUnpackagedRepositoryParams>(
+ n::environment() = &env,
+ n::location() = FSPath("unpackaged_repository_TEST_dir/under_installed"),
+ n::root() = FSPath("unpackaged_repository_TEST_dir/under_root")
+ )));
+ env.package_database()->add_repository(0, installed_repo);
+
+ EXPECT_TRUE(! FSPath("unpackaged_repository_TEST_dir/under_root/magic/pixie/first").stat().is_regular_file());
+
+ const std::shared_ptr<const PackageID> id(
+ *env[selection::RequireExactlyOne(generator::All())]->begin());
+
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = installed_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+ id->perform_action(action);
+
+ EXPECT_TRUE(FSPath("unpackaged_repository_TEST_dir/under_root/magic/pixie/first").stat().is_regular_file());
}