aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-24 15:55:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-24 17:39:10 +0000
commit565efcf8bf3f4a06d74f15257207361877693eac (patch)
treeb209a557900114cd42d2738e4b673b6a36d1c648
parent9a247e8712e6ad30184c8bd11b95fb9d501cd51a (diff)
downloadpaludis-565efcf8bf3f4a06d74f15257207361877693eac.tar.gz
paludis-565efcf8bf3f4a06d74f15257207361877693eac.tar.xz
Can't add identical IDs to fake repos
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc25
-rw-r--r--paludis/resolver/resolver_TEST_any.cc16
-rw-r--r--paludis/resolver/resolver_TEST_blockers.cc17
-rw-r--r--paludis/resolver/resolver_TEST_cycles.cc18
4 files changed, 52 insertions, 24 deletions
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 0b51bdc..1d88e57 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 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
@@ -134,10 +134,33 @@ FakeRepositoryBase::add_package(const QualifiedPackageName & q)
_imp->ids.insert(std::make_pair(q, new PackageIDSequence));
}
+namespace
+{
+ struct VersionIs
+ {
+ const VersionSpec version;
+
+ VersionIs(const VersionSpec & v) :
+ version(v)
+ {
+ }
+
+ bool operator() (const std::tr1::shared_ptr<const PackageID> & i) const
+ {
+ return i->version() == version;
+ }
+ };
+}
+
std::tr1::shared_ptr<FakePackageID>
FakeRepositoryBase::add_version(const QualifiedPackageName & q, const VersionSpec & v)
{
add_package(q);
+
+ if (_imp->ids.find(q)->second->end() != std::find_if(_imp->ids.find(q)->second->begin(),
+ _imp->ids.find(q)->second->end(), VersionIs(v)))
+ throw InternalError(PALUDIS_HERE, "duplicate id added");
+
std::tr1::shared_ptr<FakePackageID> id(new FakePackageID(_imp->env, shared_from_this(), q, v));
_imp->ids.find(q)->second->push_back(id);
return id;
diff --git a/paludis/resolver/resolver_TEST_any.cc b/paludis/resolver/resolver_TEST_any.cc
index 77c81b2..a300ae2 100644
--- a/paludis/resolver/resolver_TEST_any.cc
+++ b/paludis/resolver/resolver_TEST_any.cc
@@ -102,12 +102,14 @@ namespace test_cases
struct TestEmptyAlternativeWithUpgrade : ResolverAnyTestCase
{
- TestEmptyAlternativeWithUpgrade() : ResolverAnyTestCase("empty alternative with upgrade") { }
-
- void run()
+ TestEmptyAlternativeWithUpgrade() :
+ ResolverAnyTestCase("empty alternative with upgrade")
{
install("test", "dep", "2");
+ }
+ void run()
+ {
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("test/target"));
{
@@ -137,12 +139,14 @@ namespace test_cases
struct TestEmptyAlternativeWithUntakenUpgrade : ResolverAnyTestCase
{
- TestEmptyAlternativeWithUntakenUpgrade() : ResolverAnyTestCase("empty alternative with untaken upgrade") { }
-
- void run()
+ TestEmptyAlternativeWithUntakenUpgrade() :
+ ResolverAnyTestCase("empty alternative with untaken upgrade")
{
install("test", "dep", "1");
+ }
+ void run()
+ {
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("test/target"));
{
diff --git a/paludis/resolver/resolver_TEST_blockers.cc b/paludis/resolver/resolver_TEST_blockers.cc
index 300a114..b79c1ca 100644
--- a/paludis/resolver/resolver_TEST_blockers.cc
+++ b/paludis/resolver/resolver_TEST_blockers.cc
@@ -74,13 +74,12 @@ namespace test_cases
ResolverBlockersTestCase("hard" + std::string(t ? " transient" : "")),
transient(t)
{
+ install("hard", "a-pkg", "1");
+ install("hard", "z-pkg", "1");
}
void run()
{
- install("hard", "a-pkg", "1");
- install("hard", "z-pkg", "1");
-
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("hard/target"));
{
@@ -117,12 +116,11 @@ namespace test_cases
ResolverBlockersTestCase("unfixable" + std::string(t ? " transient" : "")),
transient(t)
{
+ install("unfixable", "a-pkg", "1")->transient_key()->set_value(transient);
}
void run()
{
- install("unfixable", "a-pkg", "1")->transient_key()->set_value(transient);
-
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("unfixable/target"));
{
@@ -159,12 +157,11 @@ namespace test_cases
transient(t)
{
allowed_to_remove_names->insert(QualifiedPackageName("remove/a-pkg"));
+ install("remove", "a-pkg", "1")->transient_key()->set_value(transient);
}
void run()
{
- install("remove", "a-pkg", "1")->transient_key()->set_value(transient);
-
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("remove/target"));
{
@@ -201,13 +198,13 @@ namespace test_cases
exists(x)
{
allowed_to_remove_names->insert(QualifiedPackageName("target/target"));
- }
- void run()
- {
if (exists)
install("target", "target", "1");
+ }
+ void run()
+ {
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions(BlockDepSpec(
"!target/target",
parse_user_package_dep_spec("target/target", &env, UserPackageDepSpecOptions()),
diff --git a/paludis/resolver/resolver_TEST_cycles.cc b/paludis/resolver/resolver_TEST_cycles.cc
index 71ba3eb..ed1ab0c 100644
--- a/paludis/resolver/resolver_TEST_cycles.cc
+++ b/paludis/resolver/resolver_TEST_cycles.cc
@@ -77,7 +77,12 @@ namespace test_cases
{
struct TestNoChanges : ResolverCyclesTestCase
{
- TestNoChanges() : ResolverCyclesTestCase("no-changes") { }
+ TestNoChanges() :
+ ResolverCyclesTestCase("no-changes")
+ {
+ install("no-changes", "dep-a", "1")->build_dependencies_key()->set_from_string("no-changes/dep-b");
+ install("no-changes", "dep-b", "1")->build_dependencies_key()->set_from_string("no-changes/dep-a");
+ }
virtual ResolverFunctions get_resolver_functions(InitialConstraints & initial_constraints)
{
@@ -89,9 +94,6 @@ namespace test_cases
void run()
{
- install("no-changes", "dep-a", "1")->build_dependencies_key()->set_from_string("no-changes/dep-b");
- install("no-changes", "dep-b", "1")->build_dependencies_key()->set_from_string("no-changes/dep-a");
-
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("no-changes/target"));
{
@@ -120,12 +122,14 @@ namespace test_cases
struct TestExistingUsable : ResolverCyclesTestCase
{
- TestExistingUsable() : ResolverCyclesTestCase("existing-usable") { }
-
- void run()
+ TestExistingUsable() :
+ ResolverCyclesTestCase("existing-usable")
{
install("existing-usable", "dep", "1");
+ }
+ void run()
+ {
std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("existing-usable/target"));
{