aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-21 13:29:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-21 13:29:52 +0000
commit8f4ab738cb670fb018bc2aae2bf0e94b6e1d8bbf (patch)
tree34ce7ac5dfe44657e2086ee27952a440e0670d40
parent8caf9128e15a16826d1521a13b08fb763e8e5378 (diff)
downloadpaludis-8f4ab738cb670fb018bc2aae2bf0e94b6e1d8bbf.tar.gz
paludis-8f4ab738cb670fb018bc2aae2bf0e94b6e1d8bbf.tar.xz
gtest more
-rw-r--r--paludis/elike_use_requirement_TEST.cc1703
-rw-r--r--paludis/files.m42
2 files changed, 818 insertions, 887 deletions
diff --git a/paludis/elike_use_requirement_TEST.cc b/paludis/elike_use_requirement_TEST.cc
index c3d32bb..31f9b17 100644
--- a/paludis/elike_use_requirement_TEST.cc
+++ b/paludis/elike_use_requirement_TEST.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2008 David Leverton
+ * Copyright (c) 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
@@ -20,20 +21,23 @@
#include <paludis/dep_spec.hh>
#include <paludis/elike_use_requirement.hh>
#include <paludis/package_database.hh>
+#include <paludis/choice.hh>
+#include <paludis/additional_package_dep_spec_requirement.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
+
#include <paludis/util/tokeniser.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/choice.hh>
-#include <paludis/additional_package_dep_spec_requirement.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
#include <list>
+#include <gtest/gtest.h>
+
using namespace paludis;
-using namespace test;
namespace
{
@@ -54,900 +58,827 @@ namespace
}
}
-namespace test_cases
+TEST(ELikeUseRequirements, Simple)
{
- struct SimpleUseRequirementsTest : TestCase
- {
- SimpleUseRequirementsTest() : TestCase("simple use requirements") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
- set_conditionals(id, "enabled disabled");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("enabled", { euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[enabled]");
- TEST_CHECK_EQUAL(req1->as_human_string(make_null_shared_ptr()), "Flag 'enabled' enabled");
- TEST_CHECK(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("disabled", { euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[disabled]");
- TEST_CHECK_EQUAL(req2->as_human_string(make_null_shared_ptr()), "Flag 'disabled' enabled");
- TEST_CHECK(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
- parse_elike_use_requirement("-enabled", { euro_strict_parsing }));
- TEST_CHECK_EQUAL(req3->as_raw_string(), "[-enabled]");
- TEST_CHECK_EQUAL(req3->as_human_string(make_null_shared_ptr()), "Flag 'enabled' disabled");
- TEST_CHECK(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
- parse_elike_use_requirement("-disabled", { euro_strict_parsing }));
- TEST_CHECK_EQUAL(req4->as_raw_string(), "[-disabled]");
- TEST_CHECK_EQUAL(req4->as_human_string(make_null_shared_ptr()), "Flag 'disabled' disabled");
- TEST_CHECK(req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- }
- } test_simple_use_requirements;
-
- struct SimpleUseRequirementsPortageSyntaxTest : TestCase
- {
- SimpleUseRequirementsPortageSyntaxTest() : TestCase("simple use requirements portage syntax") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("repo")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
- set_conditionals(id, "enabled disabled");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("enabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[enabled]");
- TEST_CHECK_EQUAL(req1->as_human_string(make_null_shared_ptr()), "Flag 'enabled' enabled");
- TEST_CHECK(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("disabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[disabled]");
- TEST_CHECK_EQUAL(req2->as_human_string(make_null_shared_ptr()), "Flag 'disabled' enabled");
- TEST_CHECK(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
- parse_elike_use_requirement("-enabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req3->as_raw_string(), "[-enabled]");
- TEST_CHECK_EQUAL(req3->as_human_string(make_null_shared_ptr()), "Flag 'enabled' disabled");
- TEST_CHECK(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
- parse_elike_use_requirement("-disabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req4->as_raw_string(), "[-disabled]");
- TEST_CHECK_EQUAL(req4->as_human_string(make_null_shared_ptr()), "Flag 'disabled' disabled");
- TEST_CHECK(req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- }
- } test_simple_use_requirements_portage_syntax;
-
- struct MultipleUseRequirementsPortageSyntaxTest : TestCase
- {
- MultipleUseRequirementsPortageSyntaxTest() : TestCase("multiple use requirements portage syntax") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
- set_conditionals(id, "enabled disabled");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("enabled,-disabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[enabled,-disabled]");
- TEST_CHECK_EQUAL(req1->as_human_string(make_null_shared_ptr()), "Flag 'enabled' enabled; Flag 'disabled' disabled");
- TEST_CHECK(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("enabled,disabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[enabled,disabled]");
- TEST_CHECK_EQUAL(req2->as_human_string(make_null_shared_ptr()), "Flag 'enabled' enabled; Flag 'disabled' enabled");
- TEST_CHECK(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
- parse_elike_use_requirement("-enabled,-disabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req3->as_raw_string(), "[-enabled,-disabled]");
- TEST_CHECK_EQUAL(req3->as_human_string(make_null_shared_ptr()), "Flag 'enabled' disabled; Flag 'disabled' disabled");
- TEST_CHECK(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
- parse_elike_use_requirement("enabled,-disabled,-enabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req4->as_raw_string(), "[enabled,-disabled,-enabled]");
- TEST_CHECK_EQUAL(req4->as_human_string(make_null_shared_ptr()), "Flag 'enabled' enabled; Flag 'disabled' disabled; Flag 'enabled' disabled");
- TEST_CHECK(! req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req5(
- parse_elike_use_requirement("enabled,-disabled,enabled", { euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req5->as_raw_string(), "[enabled,-disabled,enabled]");
- TEST_CHECK_EQUAL(req5->as_human_string(make_null_shared_ptr()), "Flag 'enabled' enabled; Flag 'disabled' disabled; Flag 'enabled' enabled");
- TEST_CHECK(req5->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- }
- } test_multiple_use_requirements_portage_syntax;
-
- struct ComplexUseRequirementsTest : TestCase
- {
- ComplexUseRequirementsTest() : TestCase("complex use requirements") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
- std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
- set_conditionals(id2, "pkgname");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req1->as_human_string(id), "Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req1->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req1->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req2->as_human_string(id2), "Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req2->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req2->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req3->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req3->as_human_string(id), "Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req3->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req3->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req4->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req4->as_human_string(id2), "Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req4->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req4->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req5(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req5->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req5->as_human_string(id), "Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req5->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req5->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req6(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req6->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req6->as_human_string(id2), "Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req6->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req6->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req7->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req7->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req7->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req7->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req8->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req8->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req8->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req8->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req9->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req9->as_human_string(id), "Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req9->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req9->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req10->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req10->as_human_string(id2), "Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req10->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req10->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req11->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req11->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req11->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req11->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req12->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req12->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req12->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req12->requirement_met(&env, 0, id2, id2, 0).first);
- }
- } test_complex_use_requirements;
-
- struct ComplexUseRequirementsPortageSyntaxTest : TestCase
- {
- ComplexUseRequirementsPortageSyntaxTest() : TestCase("complex use requirements portage syntax") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
- std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
- set_conditionals(id2, "pkgname");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req1->as_human_string(id), "Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req1->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req1->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req2->as_human_string(id2), "Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req2->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req2->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req7->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req7->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req7->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req7->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req8->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req8->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req8->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req8->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req9->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req9->as_human_string(id), "Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req9->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req9->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req10->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req10->as_human_string(id2), "Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req10->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req10->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req11->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req11->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req11->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req11->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req12->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req12->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req12->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req12->requirement_met(&env, 0, id2, id2, 0).first);
- }
- } test_complex_use_requirements_portage_syntax;
-
- struct ComplexUseRequirementsBothSyntaxesTest : TestCase
- {
- ComplexUseRequirementsBothSyntaxesTest() : TestCase("complex use requirements both syntaxes") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
- std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
- set_conditionals(id2, "pkgname");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req1->as_human_string(id), "Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req1->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req1->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req2->as_human_string(id2), "Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req2->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req2->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req7->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req7->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req7->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req7->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req8->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req8->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req8->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req8->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req9->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req9->as_human_string(id), "Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req9->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req9->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req10->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req10->as_human_string(id2), "Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req10->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req10->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req11->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req11->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req11->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req11->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req12->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req12->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req12->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req12->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req13->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req13->as_human_string(id), "Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req13->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req13->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req14->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req14->as_human_string(id2), "Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req14->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req14->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req15->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req15->as_human_string(id), "Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req15->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req15->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req16->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req16->as_human_string(id2), "Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req16->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req16->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req17->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req17->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req17->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req17->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req18->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req18->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req18->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req18->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req19->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req19->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req19->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req19->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req20->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req20->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req20->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req20->requirement_met(&env, 0, id2, id2, 0).first);
- }
- } test_complex_use_requirements_both_syntaxes;
-
- struct MalformedUseRequirementsTest : TestCase
- {
- MalformedUseRequirementsTest() : TestCase("malformed use requirements") { }
-
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
-
- TEST_CHECK_THROWS(parse_elike_use_requirement("", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-!?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("=", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!=", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
-
- TEST_CHECK_THROWS(parse_elike_use_requirement("!test?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!test=", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("test1,test2", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
- }
- } test_malformed_use_requirements;
-
- struct MalformedUseRequirementsPortageSyntaxTest : TestCase
- {
- MalformedUseRequirementsPortageSyntaxTest() : TestCase("malformed use requirements portage syntax") { }
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("repo")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id, "enabled disabled");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("enabled", { euro_strict_parsing }));
+ EXPECT_EQ("[enabled]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' enabled", req1->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("disabled", { euro_strict_parsing }));
+ EXPECT_EQ("[disabled]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'disabled' enabled", req2->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
+ parse_elike_use_requirement("-enabled", { euro_strict_parsing }));
+ EXPECT_EQ("[-enabled]", req3->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' disabled", req3->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
+ parse_elike_use_requirement("-disabled", { euro_strict_parsing }));
+ EXPECT_EQ("[-disabled]", req4->as_raw_string());
+ EXPECT_EQ("Flag 'disabled' disabled", req4->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
-
- TEST_CHECK_THROWS(parse_elike_use_requirement("", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
-
- TEST_CHECK_THROWS(parse_elike_use_requirement(",", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("test,", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement(",test", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("test,,test", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
-
- TEST_CHECK_THROWS(parse_elike_use_requirement("test!?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-test?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-test!?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("test!=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
- }
- } test_malformed_use_requirements_portage_syntax;
+TEST(ELikeUseRequirements, Portage)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("repo")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id, "enabled disabled");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("enabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[enabled]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' enabled", req1->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("disabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[disabled]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'disabled' enabled", req2->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
+ parse_elike_use_requirement("-enabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[-enabled]", req3->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' disabled", req3->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
+ parse_elike_use_requirement("-disabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[-disabled]", req4->as_raw_string());
+ EXPECT_EQ("Flag 'disabled' disabled", req4->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+}
- struct MalformedUseRequirementsBothSyntaxesTest : TestCase
- {
- MalformedUseRequirementsBothSyntaxesTest() : TestCase("malformed use requirements both syntaxes") { }
+TEST(ELikeUseRequirements, Multiple)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id, "enabled disabled");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("enabled,-disabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[enabled,-disabled]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' disabled", req1->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("enabled,disabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[enabled,disabled]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' enabled", req2->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
+ parse_elike_use_requirement("-enabled,-disabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[-enabled,-disabled]", req3->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' disabled; Flag 'disabled' disabled", req3->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
+ parse_elike_use_requirement("enabled,-disabled,-enabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[enabled,-disabled,-enabled]", req4->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' disabled; Flag 'enabled' disabled", req4->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req5(
+ parse_elike_use_requirement("enabled,-disabled,enabled", { euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[enabled,-disabled,enabled]", req5->as_raw_string());
+ EXPECT_EQ("Flag 'enabled' enabled; Flag 'disabled' disabled; Flag 'enabled' enabled", req5->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req5->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
-
- TEST_CHECK_THROWS(parse_elike_use_requirement("", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("-", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
-
- TEST_CHECK_THROWS(parse_elike_use_requirement(",", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("test,", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement(",test", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- TEST_CHECK_THROWS(parse_elike_use_requirement("test,,test", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
- }
- } test_malformed_use_requirements_both_syntaxes;
+TEST(ELikeUseRequirements, Complex)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+ std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
+ set_conditionals(id2, "pkgname");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname?]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname?]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname?]", req3->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req3->as_human_string(id));
+ EXPECT_TRUE(! req3->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req3->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname?]", req4->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req4->as_human_string(id2));
+ EXPECT_TRUE(req4->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req4->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req5(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!?]", req5->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req5->as_human_string(id));
+ EXPECT_TRUE(req5->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req5->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req6(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!?]", req6->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req6->as_human_string(id2));
+ EXPECT_TRUE(req6->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req6->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname!?]", req7->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname!?]", req8->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
+ EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname=]", req9->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
+ EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname=]", req10->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
+ EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!=]", req11->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
+ EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!=]", req12->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
+ EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
+}
- struct ComplexUseRequirementsNonstrictTest : TestCase
- {
- ComplexUseRequirementsNonstrictTest() : TestCase("complex use requirements non-strict") { }
+TEST(ELikeUseRequirements, ComplexPortage)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+ std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
+ set_conditionals(id2, "pkgname");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname?]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname?]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
+ EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname=]", req9->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
+ EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname=]", req10->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
+ EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
+ EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
+ EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
- std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
- set_conditionals(id2, "pkgname");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req1->as_human_string(id), "Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req1->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req1->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req2->as_human_string(id2), "Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req2->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req2->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req7->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req7->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req7->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req7->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req8->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req8->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req8->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req8->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req9->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req9->as_human_string(id), "Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req9->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req9->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req10->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req10->as_human_string(id2), "Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req10->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req10->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req11->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req11->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req11->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req11->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req12->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req12->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req12->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req12->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req13->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req13->as_human_string(id), "Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req13->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req13->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req14->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req14->as_human_string(id2), "Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req14->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req14->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req15->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req15->as_human_string(id), "Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req15->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req15->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req16->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req16->as_human_string(id2), "Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req16->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req16->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req17->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req17->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req17->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req17->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req18->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req18->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req18->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req18->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req19->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req19->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req19->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req19->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req20->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req20->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req20->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req20->requirement_met(&env, 0, id2, id2, 0).first);
- }
- } test_complex_use_requirements_nonstrict;
+TEST(ELikeUseRequirements, Both)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+ std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
+ set_conditionals(id2, "pkgname");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname?]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname?]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
+ EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname=]", req9->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
+ EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname=]", req10->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
+ EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
+ EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
+ EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname?]", req13->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req13->as_human_string(id));
+ EXPECT_TRUE(! req13->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req13->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname?]", req14->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req14->as_human_string(id2));
+ EXPECT_TRUE(req14->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req14->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!?]", req15->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req15->as_human_string(id));
+ EXPECT_TRUE(req15->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req15->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!?]", req16->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req16->as_human_string(id2));
+ EXPECT_TRUE(req16->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req16->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname!?]", req17->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req17->as_human_string(id));
+ EXPECT_TRUE(req17->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req17->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[-pkgname!?]", req18->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req18->as_human_string(id2));
+ EXPECT_TRUE(! req18->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req18->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!=]", req19->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req19->as_human_string(id));
+ EXPECT_TRUE(! req19->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req19->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }));
+ EXPECT_EQ("[pkgname!=]", req20->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req20->as_human_string(id2));
+ EXPECT_TRUE(req20->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req20->requirement_met(&env, 0, id2, id2, 0).first);
+}
- struct ComplexUseRequirementsPortageSyntaxNonstrictTest : TestCase
- {
- ComplexUseRequirementsPortageSyntaxNonstrictTest() : TestCase("complex use requirements portage syntax non-strict") { }
+TEST(ELikeUseRequirements, Malformed)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+
+ EXPECT_THROW(parse_elike_use_requirement("", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-!?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("=", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!=", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+
+ EXPECT_THROW(parse_elike_use_requirement("!test?", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!test=", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("test1,test2", { euro_allow_self_deps, euro_strict_parsing }), ELikeUseRequirementError);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
- set_conditionals(id, "pkgname");
- std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
- set_conditionals(id2, "pkgname");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req1->as_human_string(id), "Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req1->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req1->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[pkgname?]");
- TEST_CHECK_EQUAL(req2->as_human_string(id2), "Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req2->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req2->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req7->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req7->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req7->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req7->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
- parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req8->as_raw_string(), "[!pkgname?]");
- TEST_CHECK_EQUAL(req8->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req8->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req8->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req9->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req9->as_human_string(id), "Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req9->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(! req9->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
- parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req10->as_raw_string(), "[pkgname=]");
- TEST_CHECK_EQUAL(req10->as_human_string(id2), "Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req10->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req10->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req11->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req11->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req11->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req11->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
- parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req12->as_raw_string(), "[!pkgname=]");
- TEST_CHECK_EQUAL(req12->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req12->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req12->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req13->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req13->as_human_string(id), "Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req13->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req13->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
- parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req14->as_raw_string(), "[-pkgname?]");
- TEST_CHECK_EQUAL(req14->as_human_string(id2), "Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req14->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req14->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req15->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req15->as_human_string(id), "Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req15->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req15->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
- parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req16->as_raw_string(), "[pkgname!?]");
- TEST_CHECK_EQUAL(req16->as_human_string(id2), "Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req16->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req16->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req17->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req17->as_human_string(id), "Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'");
- TEST_CHECK(req17->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req17->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
- parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req18->as_raw_string(), "[-pkgname!?]");
- TEST_CHECK_EQUAL(req18->as_human_string(id2), "Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'");
- TEST_CHECK(! req18->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(req18->requirement_met(&env, 0, id2, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req19->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req19->as_human_string(id), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'");
- TEST_CHECK(! req19->requirement_met(&env, 0, id, id, 0).first);
- TEST_CHECK(req19->requirement_met(&env, 0, id2, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
- parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_portage_syntax }));
- TEST_CHECK_EQUAL(req20->as_raw_string(), "[pkgname!=]");
- TEST_CHECK_EQUAL(req20->as_human_string(id2), "Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'");
- TEST_CHECK(req20->requirement_met(&env, 0, id, id2, 0).first);
- TEST_CHECK(! req20->requirement_met(&env, 0, id2, id2, 0).first);
- }
- } test_complex_use_requirements_portage_syntax_nonstrict;
+TEST(ELikeUseRequirements, MalformedPortage)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+
+ EXPECT_THROW(parse_elike_use_requirement("", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+
+ EXPECT_THROW(parse_elike_use_requirement(",", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("test,", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement(",test", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("test,,test", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+
+ EXPECT_THROW(parse_elike_use_requirement("test!?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-test?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-test!?", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("test!=", { euro_allow_self_deps, euro_portage_syntax, euro_strict_parsing }), ELikeUseRequirementError);
+}
- struct UseRequirementsWithDefaultsTest : TestCase
- {
- UseRequirementsWithDefaultsTest() : TestCase("use requirements with defaults") { }
+TEST(ELikeUseRequirements, MalformedBoth)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+
+ EXPECT_THROW(parse_elike_use_requirement("", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("-", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!?", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("!=", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+
+ EXPECT_THROW(parse_elike_use_requirement(",", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("test,", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement(",test", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+ EXPECT_THROW(parse_elike_use_requirement("test,,test", { euro_allow_self_deps, euro_both_syntaxes, euro_strict_parsing }), ELikeUseRequirementError);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
- set_conditionals(id, "enabled disabled");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("missing(+)", { euro_allow_default_values, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[missing(+)]");
- TEST_CHECK_EQUAL(req1->as_human_string(make_null_shared_ptr()), "Flag 'missing' enabled, assuming enabled if missing");
- TEST_CHECK(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("missing(-)", { euro_allow_default_values, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[missing(-)]");
- TEST_CHECK_EQUAL(req2->as_human_string(make_null_shared_ptr()), "Flag 'missing' enabled, assuming disabled if missing");
- TEST_CHECK(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
- parse_elike_use_requirement("-missing(+)", { euro_allow_default_values, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req3->as_raw_string(), "[-missing(+)]");
- TEST_CHECK_EQUAL(req3->as_human_string(make_null_shared_ptr()), "Flag 'missing' disabled, assuming enabled if missing");
- TEST_CHECK(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
- parse_elike_use_requirement("-missing(-)", { euro_allow_default_values, euro_strict_parsing }));
- TEST_CHECK_EQUAL(req4->as_raw_string(), "[-missing(-)]");
- TEST_CHECK_EQUAL(req4->as_human_string(make_null_shared_ptr()), "Flag 'missing' disabled, assuming disabled if missing");
- TEST_CHECK(req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
- }
- } test_use_requirements_with_defaults;
+TEST(ELikeUseRequirements, ComplexNonStrict)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+ std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
+ set_conditionals(id2, "pkgname");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname?]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname?]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps }));
+ EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps }));
+ EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
+ EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname=]", req9->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
+ EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname=]", req10->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
+ EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps }));
+ EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
+ EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps }));
+ EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
+ EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps }));
+ EXPECT_EQ("[-pkgname?]", req13->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req13->as_human_string(id));
+ EXPECT_TRUE(! req13->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req13->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps }));
+ EXPECT_EQ("[-pkgname?]", req14->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req14->as_human_string(id2));
+ EXPECT_TRUE(req14->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req14->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname!?]", req15->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req15->as_human_string(id));
+ EXPECT_TRUE(req15->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req15->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname!?]", req16->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req16->as_human_string(id2));
+ EXPECT_TRUE(req16->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req16->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps }));
+ EXPECT_EQ("[-pkgname!?]", req17->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req17->as_human_string(id));
+ EXPECT_TRUE(req17->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req17->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps }));
+ EXPECT_EQ("[-pkgname!?]", req18->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req18->as_human_string(id2));
+ EXPECT_TRUE(! req18->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req18->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname!=]", req19->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req19->as_human_string(id));
+ EXPECT_TRUE(! req19->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req19->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps }));
+ EXPECT_EQ("[pkgname!=]", req20->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req20->as_human_string(id2));
+ EXPECT_TRUE(req20->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req20->requirement_met(&env, 0, id2, id2, 0).first);
+}
- struct PrefixStarUseRequirementsTest : TestCase
- {
- PrefixStarUseRequirementsTest() : TestCase("prefix:*") { }
+TEST(ELikeUseRequirements, PortageNonStrict)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "enabled", "1"));
+ set_conditionals(id, "pkgname");
+ std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "disabled", "1"));
+ set_conditionals(id2, "pkgname");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname?]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/enabled-1:0::fake'", req1->as_human_string(id));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req1->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname?]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is enabled for 'cat/disabled-1:0::fake'", req2->as_human_string(id2));
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req7(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[!pkgname?]", req7->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req7->as_human_string(id));
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req7->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req8(
+ parse_elike_use_requirement("!pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[!pkgname?]", req8->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req8->as_human_string(id2));
+ EXPECT_TRUE(! req8->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req8->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req9(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname=]", req9->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/enabled-1:0::fake'", req9->as_human_string(id));
+ EXPECT_TRUE(req9->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(! req9->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req10(
+ parse_elike_use_requirement("pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname=]", req10->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled like it is for 'cat/disabled-1:0::fake'", req10->as_human_string(id2));
+ EXPECT_TRUE(! req10->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req10->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req11(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[!pkgname=]", req11->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req11->as_human_string(id));
+ EXPECT_TRUE(! req11->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req11->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req12(
+ parse_elike_use_requirement("!pkgname=", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[!pkgname=]", req12->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req12->as_human_string(id2));
+ EXPECT_TRUE(req12->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req12->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req13(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[-pkgname?]", req13->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/enabled-1:0::fake'", req13->as_human_string(id));
+ EXPECT_TRUE(! req13->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req13->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req14(
+ parse_elike_use_requirement("-pkgname?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[-pkgname?]", req14->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is enabled for 'cat/disabled-1:0::fake'", req14->as_human_string(id2));
+ EXPECT_TRUE(req14->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req14->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req15(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname!?]", req15->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/enabled-1:0::fake'", req15->as_human_string(id));
+ EXPECT_TRUE(req15->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req15->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req16(
+ parse_elike_use_requirement("pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname!?]", req16->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled if it is disabled for 'cat/disabled-1:0::fake'", req16->as_human_string(id2));
+ EXPECT_TRUE(req16->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req16->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req17(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[-pkgname!?]", req17->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/enabled-1:0::fake'", req17->as_human_string(id));
+ EXPECT_TRUE(req17->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req17->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req18(
+ parse_elike_use_requirement("-pkgname!?", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[-pkgname!?]", req18->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' disabled if it is disabled for 'cat/disabled-1:0::fake'", req18->as_human_string(id2));
+ EXPECT_TRUE(! req18->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(req18->requirement_met(&env, 0, id2, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req19(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname!=]", req19->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/enabled-1:0::fake'", req19->as_human_string(id));
+ EXPECT_TRUE(! req19->requirement_met(&env, 0, id, id, 0).first);
+ EXPECT_TRUE(req19->requirement_met(&env, 0, id2, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req20(
+ parse_elike_use_requirement("pkgname!=", { euro_allow_self_deps, euro_portage_syntax }));
+ EXPECT_EQ("[pkgname!=]", req20->as_raw_string());
+ EXPECT_EQ("Flag 'pkgname' enabled or disabled opposite to how it is for 'cat/disabled-1:0::fake'", req20->as_human_string(id2));
+ EXPECT_TRUE(req20->requirement_met(&env, 0, id, id2, 0).first);
+ EXPECT_TRUE(! req20->requirement_met(&env, 0, id2, id2, 0).first);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
- std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
- set_conditionals(id, "foo:enabled foo:disabled");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("foo:*", { euro_allow_default_values, euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[foo:*]");
- TEST_CHECK(! req1->requirement_met(&env, 0, id, id, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("foo:*=", { euro_allow_default_values, euro_allow_self_deps }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[foo:*=]");
- TEST_CHECK(req2->requirement_met(&env, 0, id, id, 0).first);
- }
- } test_prefix_star_use_requirements;
+TEST(ELikeUseRequirements, Defaults)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id, "enabled disabled");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("missing(+)", { euro_allow_default_values, euro_strict_parsing }));
+ EXPECT_EQ("[missing(+)]", req1->as_raw_string());
+ EXPECT_EQ("Flag 'missing' enabled, assuming enabled if missing", req1->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("missing(-)", { euro_allow_default_values, euro_strict_parsing }));
+ EXPECT_EQ("[missing(-)]", req2->as_raw_string());
+ EXPECT_EQ("Flag 'missing' enabled, assuming disabled if missing", req2->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req2->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req3(
+ parse_elike_use_requirement("-missing(+)", { euro_allow_default_values, euro_strict_parsing }));
+ EXPECT_EQ("[-missing(+)]", req3->as_raw_string());
+ EXPECT_EQ("Flag 'missing' disabled, assuming enabled if missing", req3->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(! req3->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req4(
+ parse_elike_use_requirement("-missing(-)", { euro_allow_default_values, euro_strict_parsing }));
+ EXPECT_EQ("[-missing(-)]", req4->as_raw_string());
+ EXPECT_EQ("Flag 'missing' disabled, assuming disabled if missing", req4->as_human_string(make_null_shared_ptr()));
+ EXPECT_TRUE(req4->requirement_met(&env, 0, id, make_null_shared_ptr(), 0).first);
+}
- struct PrefixQuestionDefaultsRequirementsTest : TestCase
- {
- PrefixQuestionDefaultsRequirementsTest() : TestCase("(?) defaults") { }
+TEST(ELikeUseRequirements, PrefixStar)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+ std::shared_ptr<FakePackageID> id(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id, "foo:enabled foo:disabled");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("foo:*", { euro_allow_default_values, euro_allow_self_deps }));
+ EXPECT_EQ("[foo:*]", req1->as_raw_string());
+ EXPECT_TRUE(! req1->requirement_met(&env, 0, id, id, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("foo:*=", { euro_allow_default_values, euro_allow_self_deps }));
+ EXPECT_EQ("[foo:*=]", req2->as_raw_string());
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id, id, 0).first);
+}
- void run()
- {
- TestEnvironment env;
- const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("fake")
- )));
- env.package_database()->add_repository(1, fake);
-
- std::shared_ptr<FakePackageID> id1(fake->add_version("cat", "pkg1", "1"));
- set_conditionals(id1, "foo:enabled foo:disabled");
-
- std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "pkg2", "1"));
- set_conditionals(id2, "foo:enabled foo:disabled bar:enabled bar:disabled");
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
- parse_elike_use_requirement("foo:*(?)=", { euro_allow_default_values, euro_allow_self_deps, euro_allow_default_question_values }));
- TEST_CHECK_EQUAL(req1->as_raw_string(), "[foo:*(?)=]");
- TEST_CHECK(req1->requirement_met(&env, 0, id2, id2, 0).first);
- TEST_CHECK(req1->requirement_met(&env, 0, id1, id2, 0).first);
-
- std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
- parse_elike_use_requirement("bar:*(?)=", { euro_allow_default_values, euro_allow_self_deps, euro_allow_default_question_values }));
- TEST_CHECK_EQUAL(req2->as_raw_string(), "[bar:*(?)=]");
- TEST_CHECK(req2->requirement_met(&env, 0, id2, id2, 0).first);
- TEST_CHECK(req2->requirement_met(&env, 0, id1, id2, 0).first);
- }
- } test_question_default_requirements;
+TEST(ELikeUseRequirements, QuestionDefaults)
+{
+ TestEnvironment env;
+ const std::shared_ptr<FakeRepository> fake(std::make_shared<FakeRepository>(make_named_values<FakeRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("fake")
+ )));
+ env.package_database()->add_repository(1, fake);
+
+ std::shared_ptr<FakePackageID> id1(fake->add_version("cat", "pkg1", "1"));
+ set_conditionals(id1, "foo:enabled foo:disabled");
+
+ std::shared_ptr<FakePackageID> id2(fake->add_version("cat", "pkg2", "1"));
+ set_conditionals(id2, "foo:enabled foo:disabled bar:enabled bar:disabled");
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req1(
+ parse_elike_use_requirement("foo:*(?)=", { euro_allow_default_values, euro_allow_self_deps, euro_allow_default_question_values }));
+ EXPECT_EQ("[foo:*(?)=]", req1->as_raw_string());
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id2, id2, 0).first);
+ EXPECT_TRUE(req1->requirement_met(&env, 0, id1, id2, 0).first);
+
+ std::shared_ptr<const AdditionalPackageDepSpecRequirement> req2(
+ parse_elike_use_requirement("bar:*(?)=", { euro_allow_default_values, euro_allow_self_deps, euro_allow_default_question_values }));
+ EXPECT_EQ("[bar:*(?)=]", req2->as_raw_string());
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id2, id2, 0).first);
+ EXPECT_TRUE(req2->requirement_met(&env, 0, id1, id2, 0).first);
}
diff --git a/paludis/files.m4 b/paludis/files.m4
index 2e92e51..1279a8d 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -39,7 +39,7 @@ add(`elike_dep_parser', `hh', `cc', `fwd', `gtest', `
add(`elike_conditional_dep_spec', `hh', `cc', `fwd')
add(`elike_package_dep_spec', `hh', `cc', `fwd', `se')
add(`elike_slot_requirement', `hh', `cc', `fwd')
-add(`elike_use_requirement', `hh', `cc', `fwd', `se', `test')
+add(`elike_use_requirement', `hh', `cc', `fwd', `se', `gtest')
add(`environment', `hh', `fwd', `cc')
add(`environment_factory', `hh', `fwd', `cc')
add(`environment_implementation', `hh', `cc')