aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2012-09-09 18:42:27 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2012-09-09 18:42:27 +0100
commitff055935bf6917e86b39bd9d547c86c2fd58a0ef (patch)
treefa43f612c6b89d87344991dc93283165a0f67def
parente446142987bae268abd3c27daf8a0216f6bdab14 (diff)
downloadpaludis-ff055935bf6917e86b39bd9d547c86c2fd58a0ef.tar.gz
paludis-ff055935bf6917e86b39bd9d547c86c2fd58a0ef.tar.xz
Tidy up tests a bit
-rw-r--r--paludis/repositories/e/e_repository_TEST_4.cc122
-rw-r--r--paludis/repositories/e/e_repository_TEST_5.cc178
2 files changed, 61 insertions, 239 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_4.cc b/paludis/repositories/e/e_repository_TEST_4.cc
index c258682..7fe5b1e 100644
--- a/paludis/repositories/e/e_repository_TEST_4.cc
+++ b/paludis/repositories/e/e_repository_TEST_4.cc
@@ -141,13 +141,19 @@ TEST(ERepository, InstallEAPI4)
}
{
+ // can't use same action as the others as the failure is sticky
+ PretendAction pretend_action2(make_named_values<PretendActionOptions>(
+ n::destination() = installed_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::replacing() = std::make_shared<PackageIDSequence>()
+ ));
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
PackageDepSpec(parse_user_package_dep_spec("=cat/pkg_pretend-failure-4",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("4", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(pretend_action);
- ASSERT_TRUE(pretend_action.failed());
+ id->perform_action(pretend_action2);
+ ASSERT_TRUE(pretend_action2.failed());
}
{
@@ -238,6 +244,25 @@ TEST(ERepository, InstallEAPI4)
ASSERT_TRUE(bool(id));
id->perform_action(action);
}
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/no-eapi5-commands-4::test-repo",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("4", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ id->perform_action(pretend_action);
+ ASSERT_TRUE(! pretend_action.failed());
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/no-new-stdin-4::test-repo",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("4", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ id->perform_action(action);
+ }
}
TEST(ERepository, EAPI4MergeType)
@@ -552,96 +577,3 @@ TEST(ERepository, RequiredUse)
}
}
-TEST(ERepository, NoEAPI5Commands)
-{
- FSPath root(FSPath::cwd() / "e_repository_TEST_4_dir" / "root");
-
- 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() / "e_repository_TEST_4_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "repo/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() / "e_repository_TEST_4_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>(
- make_named_values<FakeInstalledRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("installed"),
- n::suitable_destination() = true,
- n::supports_uninstall() = true
- )));
- env.add_repository(2, installed_repo);
-
- {
- PretendAction pretend_action(make_named_values<PretendActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::replacing() = std::make_shared<PackageIDSequence>()
- ));
-
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/no-eapi5-commands-4::test-repo",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- ASSERT_TRUE(bool(id));
- EXPECT_EQ("4", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(pretend_action);
- ASSERT_TRUE(! pretend_action.failed());
- }
-}
-
-TEST(ERepository, NoNewStdin)
-{
- FSPath root(FSPath::cwd() / "e_repository_TEST_4_dir" / "root");
-
- 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() / "e_repository_TEST_4_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "repo/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() / "e_repository_TEST_4_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<Map<std::string, std::string> > v_keys(std::make_shared<Map<std::string, std::string>>());
- v_keys->insert("format", "vdb");
- v_keys->insert("names_cache", "/var/empty");
- v_keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_4_dir" / "vdb"));
- v_keys->insert("root", stringify(root));
- std::shared_ptr<Repository> v_repo(VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, v_keys, std::placeholders::_1)));
- env.add_repository(1, v_repo);
-
- {
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = v_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
- ));
-
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/no-new-stdin-4::test-repo",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- ASSERT_TRUE(bool(id));
- EXPECT_EQ("4", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(action);
- }
-}
-
diff --git a/paludis/repositories/e/e_repository_TEST_5.cc b/paludis/repositories/e/e_repository_TEST_5.cc
index 7b391f4..23427b7 100644
--- a/paludis/repositories/e/e_repository_TEST_5.cc
+++ b/paludis/repositories/e/e_repository_TEST_5.cc
@@ -141,111 +141,70 @@ TEST(ERepository, InstallEAPI5)
{
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/strict-use-5",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/usex-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(action);
+ id->perform_action(pretend_action);
+ ASSERT_TRUE(! pretend_action.failed());
}
{
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/strict-use-fail-5",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/new-stdin-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ id->perform_action(action);
}
{
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/strict-use-injection-5",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/doheader-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
id->perform_action(action);
}
-}
-
-TEST(ERepository, RequiredUse)
-{
- FSPath root(FSPath::cwd() / "e_repository_TEST_5_dir" / "root");
-
- 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() / "e_repository_TEST_5_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "repo/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() / "e_repository_TEST_5_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>(
- make_named_values<FakeInstalledRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("installed"),
- n::suitable_destination() = true,
- n::supports_uninstall() = true
- )));
- env.add_repository(2, installed_repo);
{
- PretendAction pretend_action(make_named_values<PretendActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::replacing() = std::make_shared<PackageIDSequence>()
- ));
-
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-none-5::test-repo",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/doheader-dies-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(pretend_action);
- ASSERT_TRUE(! pretend_action.failed());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
}
{
- PretendAction pretend_action(make_named_values<PretendActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::replacing() = std::make_shared<PackageIDSequence>()
- ));
-
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-one-5::test-repo",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/strict-use-5",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(pretend_action);
- ASSERT_TRUE(! pretend_action.failed());
+ id->perform_action(action);
}
{
- PretendAction pretend_action(make_named_values<PretendActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::replacing() = std::make_shared<PackageIDSequence>()
- ));
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/strict-use-fail-5",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+ {
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-two-5::test-repo",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/strict-use-injection-5",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(pretend_action);
- ASSERT_TRUE(pretend_action.failed());
+ id->perform_action(action);
}
}
-TEST(ERepository, UseX)
+TEST(ERepository, RequiredUse)
{
FSPath root(FSPath::cwd() / "e_repository_TEST_5_dir" / "root");
@@ -282,113 +241,44 @@ TEST(ERepository, UseX)
));
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/usex-5::test-repo",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-none-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
id->perform_action(pretend_action);
ASSERT_TRUE(! pretend_action.failed());
}
-}
-
-TEST(ERepository, NewStdin)
-{
- FSPath root(FSPath::cwd() / "e_repository_TEST_5_dir" / "root");
-
- 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() / "e_repository_TEST_5_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "repo/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() / "e_repository_TEST_5_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<Map<std::string, std::string> > v_keys(std::make_shared<Map<std::string, std::string>>());
- v_keys->insert("format", "vdb");
- v_keys->insert("names_cache", "/var/empty");
- v_keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "vdb"));
- v_keys->insert("root", stringify(root));
- std::shared_ptr<Repository> v_repo(VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, v_keys, std::placeholders::_1)));
- env.add_repository(1, v_repo);
{
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = v_repo,
+ PretendAction pretend_action(make_named_values<PretendActionOptions>(
+ 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
+ n::replacing() = std::make_shared<PackageIDSequence>()
));
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/new-stdin-5::test-repo",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-one-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(action);
+ id->perform_action(pretend_action);
+ ASSERT_TRUE(! pretend_action.failed());
}
-}
-
-TEST(ERepository, Doheader)
-{
- FSPath root(FSPath::cwd() / "e_repository_TEST_5_dir" / "root");
-
- 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() / "e_repository_TEST_5_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "repo/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() / "e_repository_TEST_5_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<Map<std::string, std::string> > v_keys(std::make_shared<Map<std::string, std::string>>());
- v_keys->insert("format", "vdb");
- v_keys->insert("names_cache", "/var/empty");
- v_keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "vdb"));
- v_keys->insert("root", stringify(root));
- std::shared_ptr<Repository> v_repo(VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, v_keys, std::placeholders::_1)));
- env.add_repository(1, v_repo);
{
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = v_repo,
+ PretendAction pretend_action(make_named_values<PretendActionOptions>(
+ 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
+ n::replacing() = std::make_shared<PackageIDSequence>()
));
const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/doheader-5::test-repo",
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-two-5::test-repo",
&env, { })), make_null_shared_ptr(), { }))]->last());
ASSERT_TRUE(bool(id));
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
- id->perform_action(action);
-
- const std::shared_ptr<const PackageID> id2(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/doheader-dies-5::test-repo",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- ASSERT_TRUE(bool(id2));
- EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id2->find_metadata("EAPI"))->parse_value());
- EXPECT_THROW(id2->perform_action(action), ActionFailedError);
+ id->perform_action(pretend_action);
+ ASSERT_TRUE(pretend_action.failed());
}
}