aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-12-06 16:57:58 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2009-12-06 16:57:58 +0000
commit956ad7409b5099e5a40443b98a3eca16e599549a (patch)
tree546eb1cf61a0c776f9f6ded28765fcad85998d74
parent360080c80c74da04af2b6b12fd55d8c9d7aad2e7 (diff)
downloadpaludis-956ad7409b5099e5a40443b98a3eca16e599549a.tar.gz
paludis-956ad7409b5099e5a40443b98a3eca16e599549a.tar.xz
Handle empty ( ) blocks in || ( ) properly
-rw-r--r--.gitignore1
-rw-r--r--paludis/resolver/Makefile.am17
-rw-r--r--paludis/resolver/decider.cc3
-rw-r--r--paludis/resolver/resolver_TEST_any.cc150
-rwxr-xr-xpaludis/resolver/resolver_TEST_any_cleanup.sh9
-rwxr-xr-xpaludis/resolver/resolver_TEST_any_setup.sh38
-rw-r--r--paludis/resolver/sanitised_dependencies.cc8
7 files changed, 221 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 0196894..7f84d2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -318,6 +318,7 @@ paludis-*.*.*.tar.bz2
/paludis/repositories/virtuals/installed_virtuals_repository_TEST
/paludis/repositories/virtuals/virtuals_repository_TEST
/paludis/repository_name_cache_TEST
+/paludis/resolver/resolver_TEST_any
/paludis/resolver/resolver_TEST_blockers
/paludis/resolver/resolver_TEST_cycles
/paludis/resolver/resolver_TEST_serialisation
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index d7f31af..8b21ff3 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -82,6 +82,7 @@ TESTS = \
resolver_TEST_blockers \
resolver_TEST_cycles \
resolver_TEST_suggestions \
+ resolver_TEST_any \
$(virtuals_tests)
endif
@@ -93,7 +94,8 @@ check_SCRIPTS = \
resolver_TEST_serialisation_setup.sh resolver_TEST_serialisation_cleanup.sh \
resolver_TEST_suggestions_setup.sh resolver_TEST_suggestions_cleanup.sh \
resolver_TEST_simple_setup.sh resolver_TEST_simple_cleanup.sh \
- resolver_TEST_virtuals_setup.sh resolver_TEST_virtuals_cleanup.sh
+ resolver_TEST_virtuals_setup.sh resolver_TEST_virtuals_cleanup.sh \
+ resolver_TEST_any_setup.sh resolver_TEST_any_cleanup.sh
check_LIBRARIES = libpaludisresolvertest.a
libpaludisresolvertest_a_SOURCES = \
@@ -178,6 +180,19 @@ resolver_TEST_simple_LDADD = \
resolver_TEST_simple_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_any_SOURCES = resolver_TEST_any.cc
+
+resolver_TEST_any_LDADD = \
+ libpaludisresolvertest.a \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ libpaludisresolver.a \
+ $(DYNAMIC_LD_LIBS)
+
+resolver_TEST_any_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+
use_existing-se.hh : use_existing.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/use_existing.se > $@ ; then rm -f $@ ; exit 1 ; fi
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 1d2205f..fc9e175 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -744,6 +744,9 @@ Decider::find_any_score(const Resolvent & our_resolvent, const SanitisedDependen
const PackageDepSpec & spec(*dep.spec().if_package());
+ // note: make sure the worst_score declaration in
+ // AnyDepSpecChildHandler::commit in satitised_dependencies.cc
+ // matches this logic
int operator_bias(0);
if (spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty())
{
diff --git a/paludis/resolver/resolver_TEST_any.cc b/paludis/resolver/resolver_TEST_any.cc
new file mode 100644
index 0000000..5b55b6f
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_any.cc
@@ -0,0 +1,150 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009 David Leverton
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/resolver.hh>
+#include <paludis/resolver/resolver_functions.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/resolutions.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolvent.hh>
+#include <paludis/resolver/suggest_restart.hh>
+#include <paludis/resolver/resolver_lists.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/repository_factory.hh>
+#include <paludis/package_database.hh>
+
+#include <paludis/resolver/resolver_test.hh>
+#include <test/test_runner.hh>
+#include <test/test_framework.hh>
+
+#include <list>
+#include <tr1/functional>
+#include <algorithm>
+#include <map>
+
+using namespace paludis;
+using namespace paludis::resolver;
+using namespace paludis::resolver::resolver_test;
+using namespace test;
+
+namespace
+{
+ struct ResolverAnyTestCase : ResolverTestCase
+ {
+ ResolverAnyTestCase(const std::string & s) :
+ ResolverTestCase("any", s, "exheres-0", "exheres")
+ {
+ }
+ };
+}
+
+namespace test_cases
+{
+ struct TestEmptyAlternative : ResolverAnyTestCase
+ {
+ TestEmptyAlternative() : ResolverAnyTestCase("empty alternative") { }
+
+ void run()
+ {
+ std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("test/target"));
+
+ {
+ TestMessageSuffix s("errors");
+ check_resolution_list(resolutions->jobs(), resolutions->error_resolutions(), ResolutionListChecks()
+ .finished()
+ );
+ }
+
+ {
+ TestMessageSuffix s("ordered");
+ check_resolution_list(resolutions->jobs(), resolutions->ordered_job_ids(), ResolutionListChecks()
+ .qpn(QualifiedPackageName("test/target"))
+ .finished()
+ );
+ }
+ }
+ } test_empty_alternative;
+
+ struct TestEmptyAlternativeWithUpgrade : ResolverAnyTestCase
+ {
+ TestEmptyAlternativeWithUpgrade() : ResolverAnyTestCase("empty alternative with upgrade") { }
+
+ void run()
+ {
+ install("test", "dep", "2");
+
+ std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("test/target"));
+
+ {
+ TestMessageSuffix s("errors");
+ check_resolution_list(resolutions->jobs(), resolutions->error_resolutions(), ResolutionListChecks()
+ .finished()
+ );
+ }
+
+ {
+ TestMessageSuffix s("ordered");
+ check_resolution_list(resolutions->jobs(), resolutions->ordered_job_ids(), ResolutionListChecks()
+ .qpn(QualifiedPackageName("test/dep"))
+ .qpn(QualifiedPackageName("test/target"))
+ .finished()
+ );
+ }
+ }
+ } test_empty_alternative_with_upgrade;
+
+ struct TestEmptyAlternativeWithUntakenUpgrade : ResolverAnyTestCase
+ {
+ TestEmptyAlternativeWithUntakenUpgrade() : ResolverAnyTestCase("empty alternative with untaken upgrade") { }
+
+ void run()
+ {
+ install("test", "dep", "1");
+
+ std::tr1::shared_ptr<const ResolverLists> resolutions(get_resolutions("test/target"));
+
+ {
+ TestMessageSuffix s("errors");
+ check_resolution_list(resolutions->jobs(), resolutions->error_resolutions(), ResolutionListChecks()
+ .finished()
+ );
+ }
+
+ {
+ TestMessageSuffix s("ordered");
+ check_resolution_list(resolutions->jobs(), resolutions->ordered_job_ids(), ResolutionListChecks()
+ .qpn(QualifiedPackageName("test/target"))
+ .finished()
+ );
+ }
+ }
+ } test_empty_alternative_with_untaken_upgrade;
+}
+
diff --git a/paludis/resolver/resolver_TEST_any_cleanup.sh b/paludis/resolver/resolver_TEST_any_cleanup.sh
new file mode 100755
index 0000000..cc19ab5
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_any_cleanup.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d resolver_TEST_any_dir ] ; then
+ rm -fr resolver_TEST_any_dir
+else
+ true
+fi
+
diff --git a/paludis/resolver/resolver_TEST_any_setup.sh b/paludis/resolver/resolver_TEST_any_setup.sh
new file mode 100755
index 0000000..9100d13
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_any_setup.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir resolver_TEST_any_dir || exit 1
+cd resolver_TEST_any_dir || exit 1
+
+mkdir -p build
+mkdir -p distdir
+mkdir -p installed
+
+mkdir -p repo/{profiles/profile,metadata}
+
+cd repo
+echo "repo" > profiles/repo_name
+: > metadata/categories.conf
+
+# test
+echo 'test' >> metadata/categories.conf
+
+mkdir -p 'packages/test/target'
+cat <<END > packages/test/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="
+ || ( test/dep[>=2] ( ) )
+ "
+END
+
+mkdir -p 'packages/test/dep'
+cat <<END > packages/test/dep/dep-3.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+END
+
+cd ..
+
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index 61864ec..e0d1055 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -259,10 +259,10 @@ namespace
g_end(child_groups.end()) ;
g != g_end ; ++g)
{
- int worst_score(-1);
-
- if (g->empty())
- throw InternalError(PALUDIS_HERE, "why did that happen?");
+ // should match Decider::find_any_score logic:
+ // equivalent to an already installed spec with no
+ // version operator
+ int worst_score(59);
/* score of a group is the score of the worst child. */
for (std::list<PackageOrBlockDepSpec>::const_iterator h(g->begin()), h_end(g->end()) ;