aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/e_repository_TEST_4.cc
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/repositories/e/e_repository_TEST_4.cc')
-rw-r--r--paludis/repositories/e/e_repository_TEST_4.cc199
1 files changed, 199 insertions, 0 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_4.cc b/paludis/repositories/e/e_repository_TEST_4.cc
index aec0405b5..9e875681c 100644
--- a/paludis/repositories/e/e_repository_TEST_4.cc
+++ b/paludis/repositories/e/e_repository_TEST_4.cc
@@ -408,5 +408,204 @@ namespace test_cases
}
} test_e_repository_eapi_4_merge_type_bin;
#endif
+
+ struct ERepositoryEAPI4RequiredUseTest : TestCase
+ {
+ ERepositoryEAPI4RequiredUseTest() : TestCase("eapi 4 required use") { }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ void run()
+ {
+ FSPath root(FSPath::cwd() / "e_repository_TEST_4_dir" / "root");
+
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "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.package_database()->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.package_database()->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>()
+ ));
+
+ TestMessageSuffix suffix("all good", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-all-good-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(! pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("all empty", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-all-empty-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(! pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("all one not good", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-all-one-not-good-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("any good", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-any-good-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(! pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("any empty", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-any-empty-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(! pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("any none", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-any-none-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("one none", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-one-none-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("one none", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-one-none-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(pretend_action.failed());
+ }
+
+ {
+ 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>()
+ ));
+
+ TestMessageSuffix suffix("one good", true);
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-one-good-4::test-repo",
+ &env, { })), { }))]->last());
+ TEST_CHECK(bool(id));
+ TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "4");
+ id->perform_action(pretend_action);
+ TEST_CHECK(! pretend_action.failed());
+ }
+ }
+ } test_e_repository_eapi_4_required_use;
}