aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Paul Mulders <info@mld.demon.nl> 2010-03-11 17:13:05 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-11 17:35:43 +0000
commitef5d3ecffec6ee97bbd213fbc5569de904191aed (patch)
tree7eab9f8551984f0e4b99b941c310f147d4204959
parent706d500571fd267118144ee3df3a724bf61b9c58 (diff)
downloadpaludis-ef5d3ecffec6ee97bbd213fbc5569de904191aed.tar.gz
paludis-ef5d3ecffec6ee97bbd213fbc5569de904191aed.tar.xz
Add user dep spec user key requirement tests.
-rw-r--r--paludis/repositories/fake/fake_package_id.cc13
-rw-r--r--paludis/repositories/fake/fake_package_id.hh1
-rw-r--r--paludis/user_dep_spec_TEST.cc71
3 files changed, 85 insertions, 0 deletions
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 425ed67..707ccb4 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -720,6 +720,7 @@ namespace paludis
std::tr1::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> > homepage;
std::tr1::shared_ptr<FakeMetadataChoicesKey> choices;
std::tr1::shared_ptr<FakeMetadataValueKey<bool> > transient;
+ std::tr1::shared_ptr<FakeMetadataValueKey<long> > hitchhiker;
std::tr1::shared_ptr<Mask> unsupported_mask;
mutable bool has_masks;
@@ -1043,6 +1044,9 @@ FakePackageID::need_keys_added() const
_imp->transient.reset(new FakeMetadataValueKey<bool>("TRANSIENT", "Transient",
mkt_internal, false));
+ _imp->hitchhiker.reset(new FakeMetadataValueKey<long>("HITCHHIKER", "Hitchhiker",
+ mkt_internal, 42));
+
add_metadata_key(_imp->slot);
add_metadata_key(_imp->build_dependencies);
add_metadata_key(_imp->run_dependencies);
@@ -1054,6 +1058,7 @@ FakePackageID::need_keys_added() const
add_metadata_key(_imp->license);
add_metadata_key(_imp->choices);
add_metadata_key(_imp->transient);
+ add_metadata_key(_imp->hitchhiker);
}
}
@@ -1314,6 +1319,13 @@ FakePackageID::transient_key()
return _imp->transient;
}
+const std::tr1::shared_ptr<FakeMetadataValueKey<long> >
+FakePackageID::hitchhiker_key()
+{
+ need_keys_added();
+ return _imp->hitchhiker;
+}
+
char
FakePackageID::use_expand_separator() const
{
@@ -1375,4 +1387,5 @@ template class FakeMetadataSpecTreeKey<SimpleURISpecTree>;
template class FakeMetadataCollectionKey<KeywordNameSet>;
template class FakeMetadataValueKey<bool>;
+template class FakeMetadataValueKey<long>;
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index 547ce7d..20d1ac1 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -308,6 +308,7 @@ namespace paludis
const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> > homepage_key();
const std::tr1::shared_ptr<FakeMetadataChoicesKey> choices_key();
const std::tr1::shared_ptr<FakeMetadataValueKey<bool> > transient_key();
+ const std::tr1::shared_ptr<FakeMetadataValueKey<long> > hitchhiker_key();
void set_slot(const SlotName &);
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index 05444af..ece8567 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -20,6 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/package_database.hh>
+#include <paludis/match_package.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -32,6 +33,7 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -400,5 +402,74 @@ namespace test_cases
TEST_CHECK_THROWS(parse_user_package_dep_spec("system", &env, UserPackageDepSpecOptions()), NoSuchPackageError);
}
} test_user_package_dep_spec_sets;
+
+ struct UserPackageDepSpecUserKeyReqTest : UserDepSpecTestCase
+ {
+ UserPackageDepSpecUserKeyReqTest() : UserDepSpecTestCase("user package dep spec user key requirements") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::tr1::shared_ptr<FakeRepository> fake(new FakeRepository(make_named_values<FakeRepositoryParams>(
+ value_for<n::environment>(&env),
+ value_for<n::name>(RepositoryName("fake")))));
+ env.package_database()->add_repository(1, fake);
+
+ std::tr1::shared_ptr<FakePackageID> pkg1(fake->add_version("cat", "pkg1", "1"));
+ pkg1->keywords_key()->set_from_string("~a ~b");
+ std::tr1::shared_ptr<FakePackageID> pkg2(fake->add_version("cat", "pkg1", "2"));
+ pkg2->keywords_key()->set_from_string("~a ~c");
+ std::tr1::shared_ptr<FakePackageID> pkg3(fake->add_version("cat", "pkg1", "3"));
+ pkg3->keywords_key()->set_from_string("~d");
+
+ PackageDepSpec a(parse_user_package_dep_spec("cat/pkg1[.KEYWORDS<~a]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(match_package(env, a, *pkg1, MatchPackageOptions()));
+ TEST_CHECK(match_package(env, a, *pkg2, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, a, *pkg3, MatchPackageOptions()));
+
+ PackageDepSpec b(parse_user_package_dep_spec("cat/pkg1[.KEYWORDS<~b]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(match_package(env, b, *pkg1, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, b, *pkg2, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, b, *pkg3, MatchPackageOptions()));
+
+ PackageDepSpec c(parse_user_package_dep_spec("cat/pkg1[.KEYWORDS<~c]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, c, *pkg1, MatchPackageOptions()));
+ TEST_CHECK(match_package(env, c, *pkg2, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, c, *pkg3, MatchPackageOptions()));
+
+ PackageDepSpec d(parse_user_package_dep_spec("cat/pkg1[.KEYWORDS>~a]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, d, *pkg1, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, d, *pkg2, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, d, *pkg3, MatchPackageOptions()));
+
+ PackageDepSpec e(parse_user_package_dep_spec("cat/pkg1[.KEYWORDS=~d]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, e, *pkg1, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, e, *pkg2, MatchPackageOptions()));
+ TEST_CHECK(match_package(env, e, *pkg3, MatchPackageOptions()));
+
+ PackageDepSpec f(parse_user_package_dep_spec("cat/pkg1[.KEYWORDS=~a ~c]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, f, *pkg1, MatchPackageOptions()));
+ TEST_CHECK(match_package(env, f, *pkg2, MatchPackageOptions()));
+ TEST_CHECK(! match_package(env, f, *pkg3, MatchPackageOptions()));
+
+ PackageDepSpec g(parse_user_package_dep_spec("cat/pkg1[.HITCHHIKER=42]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(match_package(env, g, *pkg1, MatchPackageOptions()));
+
+ PackageDepSpec h(parse_user_package_dep_spec("cat/pkg1[.HITCHHIKER<41]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, h, *pkg1, MatchPackageOptions()));
+
+ PackageDepSpec i(parse_user_package_dep_spec("cat/pkg1[.HITCHHIKER<42]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, i, *pkg1, MatchPackageOptions()));
+
+ PackageDepSpec j(parse_user_package_dep_spec("cat/pkg1[.HITCHHIKER<43]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(match_package(env, j, *pkg1, MatchPackageOptions()));
+
+ PackageDepSpec k(parse_user_package_dep_spec("cat/pkg1[.HITCHHIKER>42]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(! match_package(env, k, *pkg1, MatchPackageOptions()));
+
+ PackageDepSpec l(parse_user_package_dep_spec("cat/pkg1[.HITCHHIKER>41]", &env, UserPackageDepSpecOptions()));
+ TEST_CHECK(match_package(env, l, *pkg1, MatchPackageOptions()));
+ }
+ } test_user_package_dep_spec_user_key_req;
}