aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 15:02:46 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 15:33:40 +0000
commit2f60a9e598fce6821b539b3883d76053933cfb3f (patch)
tree251068a7a30b1084d7462fd7b5147529b3fa9cf9
parenta678722d65d9bc11d76626cde63f11b21f79278d (diff)
downloadpaludis-2f60a9e598fce6821b539b3883d76053933cfb3f.tar.gz
paludis-2f60a9e598fce6821b539b3883d76053933cfb3f.tar.xz
Test removable blockers
-rw-r--r--paludis/resolver/resolver_TEST_blockers.cc42
-rwxr-xr-xpaludis/resolver/resolver_TEST_blockers_setup.sh20
-rw-r--r--paludis/resolver/resolver_test.cc15
-rw-r--r--paludis/resolver/resolver_test.hh5
4 files changed, 76 insertions, 6 deletions
diff --git a/paludis/resolver/resolver_TEST_blockers.cc b/paludis/resolver/resolver_TEST_blockers.cc
index 3bc2b89..65984b4 100644
--- a/paludis/resolver/resolver_TEST_blockers.cc
+++ b/paludis/resolver/resolver_TEST_blockers.cc
@@ -149,5 +149,47 @@ namespace test_cases
}
}
} test_unfixable_blocker(false), test_unfixable_blocker_transient(true);
+
+ struct TestRemoveBlocker : ResolverBlockersTestCase
+ {
+ const bool transient;
+
+ TestRemoveBlocker(const bool t) :
+ ResolverBlockersTestCase("remove " + std::string(t ? " transient" : "")),
+ transient(t)
+ {
+ allowed_to_remove_names->insert(QualifiedPackageName("remove/a-pkg"));
+ }
+
+ void run()
+ {
+ install("remove", "a-pkg", "1")->transient_key()->set_value(transient);
+
+ std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("remove/target"));
+
+ {
+ TestMessageSuffix s("taken errors");
+ check_resolution_list(resolutions->jobs(), resolutions->taken_error_job_ids(), ResolutionListChecks()
+ .finished()
+ );
+ }
+
+ {
+ TestMessageSuffix s("untaken errors");
+ check_resolution_list(resolutions->jobs(), resolutions->untaken_error_job_ids(), ResolutionListChecks()
+ .finished()
+ );
+ }
+
+ {
+ TestMessageSuffix s("ordered");
+ check_resolution_list(resolutions->jobs(), resolutions->taken_job_ids(), ResolutionListChecks()
+ .kind("remove_decision", QualifiedPackageName("remove/a-pkg"))
+ .qpn(QualifiedPackageName("remove/target"))
+ .finished()
+ );
+ }
+ }
+ } test_remove_blocker(false), test_remove_blocker_transient(true);
}
diff --git a/paludis/resolver/resolver_TEST_blockers_setup.sh b/paludis/resolver/resolver_TEST_blockers_setup.sh
index 9d7dd4c..2b270da 100755
--- a/paludis/resolver/resolver_TEST_blockers_setup.sh
+++ b/paludis/resolver/resolver_TEST_blockers_setup.sh
@@ -61,5 +61,25 @@ PLATFORMS="test"
SLOT="0"
END
+# remove
+echo 'remove' >> metadata/categories.conf
+
+mkdir -p 'packages/remove/target'
+cat <<END > packages/remove/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="
+ ( !remove/a-pkg )
+ "
+END
+
+mkdir -p 'packages/remove/a-pkg'
+cat <<END > packages/remove/a-pkg/a-pkg-2.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+END
+
cd ..
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 52b40a9..de44a21 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -38,6 +38,7 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/set-impl.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repository_factory.hh>
#include <paludis/package_database.hh>
@@ -245,14 +246,17 @@ paludis::resolver::resolver_test::find_repository_for_fn(
}
bool
-paludis::resolver::resolver_test::allowed_to_remove_fn(const std::tr1::shared_ptr<const PackageID> &)
+paludis::resolver::resolver_test::allowed_to_remove_fn(
+ const std::tr1::shared_ptr<const QualifiedPackageNameSet> & s,
+ const std::tr1::shared_ptr<const PackageID> & i)
{
- return false;
+ return s->end() != s->find(i->name());
}
ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
const std::string & l) :
- TestCase(s)
+ TestCase(s),
+ allowed_to_remove_names(new QualifiedPackageNameSet)
{
std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
keys->insert("format", "exheres");
@@ -284,7 +288,7 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
value_for<n::environment>(&env),
value_for<n::name>(RepositoryName("fake-inst")),
value_for<n::suitable_destination>(true),
- value_for<n::supports_uninstall>(false)
+ value_for<n::supports_uninstall>(true)
)));
env.package_database()->add_repository(1, fake_inst_repo);
@@ -298,7 +302,8 @@ ResolverFunctions
ResolverTestCase::get_resolver_functions(InitialConstraints & initial_constraints)
{
return make_named_values<ResolverFunctions>(
- value_for<n::allowed_to_remove_fn>(&allowed_to_remove_fn),
+ value_for<n::allowed_to_remove_fn>(std::tr1::bind(&allowed_to_remove_fn,
+ allowed_to_remove_names, std::tr1::placeholders::_1)),
value_for<n::care_about_dep_fn>(&care_about_dep_fn),
value_for<n::find_repository_for_fn>(std::tr1::bind(&find_repository_for_fn,
&env, std::tr1::placeholders::_1, std::tr1::placeholders::_2,
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index c118281..77bc583 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -90,13 +90,16 @@ namespace paludis
const std::tr1::shared_ptr<const PackageID> &,
const std::tr1::shared_ptr<const Reason> &);
- bool allowed_to_remove_fn(const std::tr1::shared_ptr<const PackageID> &);
+ bool allowed_to_remove_fn(
+ const std::tr1::shared_ptr<const QualifiedPackageNameSet> &,
+ const std::tr1::shared_ptr<const PackageID> &);
struct ResolverTestCase : test::TestCase
{
TestEnvironment env;
std::tr1::shared_ptr<Repository> repo, inst_repo;
std::tr1::shared_ptr<FakeInstalledRepository> fake_inst_repo;
+ std::tr1::shared_ptr<QualifiedPackageNameSet> allowed_to_remove_names;
ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
const std::string & layout);