aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-27 14:07:13 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-27 14:07:13 +0100
commit9d7a170ae6703a68d2c04d56e8bd2792194f0deb (patch)
tree4c0ae754d5000b68156af4048720f2f2182f334a
parent7686d9b323c8305442d02ddd1695e03022ed7666 (diff)
downloadpaludis-9d7a170ae6703a68d2c04d56e8bd2792194f0deb.tar.gz
paludis-9d7a170ae6703a68d2c04d56e8bd2792194f0deb.tar.xz
gtest more
Ugly, because WithParamInterface isn't in a released gtest yet.
-rw-r--r--paludis/resolver/Makefile.am48
-rw-r--r--paludis/resolver/resolver_TEST_any.cc369
-rw-r--r--paludis/resolver/resolver_TEST_blockers.cc676
-rw-r--r--paludis/resolver/resolver_TEST_continue_on_failure.cc198
-rw-r--r--paludis/resolver/resolver_TEST_cycles.cc442
-rw-r--r--paludis/resolver/resolver_TEST_errors.cc64
-rw-r--r--paludis/resolver/resolver_TEST_fetches.cc106
-rw-r--r--paludis/resolver/resolver_TEST_purges.cc152
-rw-r--r--paludis/resolver/resolver_TEST_serialisation.cc83
-rw-r--r--paludis/resolver/resolver_TEST_simple.cc211
-rw-r--r--paludis/resolver/resolver_TEST_suggestions.cc159
-rw-r--r--paludis/resolver/resolver_TEST_uninstalls.cc73
-rw-r--r--paludis/resolver/resolver_TEST_virtuals.cc104
-rw-r--r--paludis/resolver/resolver_test.cc67
-rw-r--r--paludis/resolver/resolver_test.hh22
15 files changed, 1348 insertions, 1426 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 926aa22..e26b114 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -217,7 +217,7 @@ resolver_TEST_blockers_SOURCES = resolver_TEST_blockers.cc
resolver_TEST_blockers_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -225,11 +225,13 @@ resolver_TEST_blockers_LDADD = \
resolver_TEST_blockers_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_blockers_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_cycles_SOURCES = resolver_TEST_cycles.cc
resolver_TEST_cycles_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -237,11 +239,13 @@ resolver_TEST_cycles_LDADD = \
resolver_TEST_cycles_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_cycles_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_virtuals_SOURCES = resolver_TEST_virtuals.cc
resolver_TEST_virtuals_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -249,11 +253,13 @@ resolver_TEST_virtuals_LDADD = \
resolver_TEST_virtuals_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_virtuals_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_suggestions_SOURCES = resolver_TEST_suggestions.cc
resolver_TEST_suggestions_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -261,11 +267,13 @@ resolver_TEST_suggestions_LDADD = \
resolver_TEST_suggestions_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_suggestions_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_serialisation_SOURCES = resolver_TEST_serialisation.cc
resolver_TEST_serialisation_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -273,23 +281,27 @@ resolver_TEST_serialisation_LDADD = \
resolver_TEST_serialisation_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_serialisation_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_simple_SOURCES = resolver_TEST_simple.cc
resolver_TEST_simple_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
$(DYNAMIC_LD_LIBS)
+resolver_TEST_simple_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
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)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -297,11 +309,13 @@ resolver_TEST_any_LDADD = \
resolver_TEST_any_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_any_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_errors_SOURCES = resolver_TEST_errors.cc
resolver_TEST_errors_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -309,11 +323,13 @@ resolver_TEST_errors_LDADD = \
resolver_TEST_errors_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_errors_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_continue_on_failure_SOURCES = resolver_TEST_continue_on_failure.cc
resolver_TEST_continue_on_failure_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -321,11 +337,13 @@ resolver_TEST_continue_on_failure_LDADD = \
resolver_TEST_continue_on_failure_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_continue_on_failure_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_uninstalls_SOURCES = resolver_TEST_uninstalls.cc
resolver_TEST_uninstalls_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -333,11 +351,13 @@ resolver_TEST_uninstalls_LDADD = \
resolver_TEST_uninstalls_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_uninstalls_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_fetches_SOURCES = resolver_TEST_fetches.cc
resolver_TEST_fetches_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -345,11 +365,13 @@ resolver_TEST_fetches_LDADD = \
resolver_TEST_fetches_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_fetches_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
resolver_TEST_purges_SOURCES = resolver_TEST_purges.cc
resolver_TEST_purges_LDADD = \
libpaludisresolvertest.a \
- $(top_builddir)/test/libtest.a \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
libpaludisresolver.a \
@@ -357,6 +379,8 @@ resolver_TEST_purges_LDADD = \
resolver_TEST_purges_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+resolver_TEST_purges_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
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/resolver_TEST_any.cc b/paludis/resolver/resolver_TEST_any.cc
index 794c7dd..2f7c6fe 100644
--- a/paludis/resolver/resolver_TEST_any.cc
+++ b/paludis/resolver/resolver_TEST_any.cc
@@ -25,7 +25,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -35,12 +37,11 @@
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/make_shared_copy.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -50,131 +51,115 @@
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")
- {
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
- }
- };
-}
-
-namespace test_cases
-{
- struct TestEmptyAlternative : ResolverAnyTestCase
- {
- TestEmptyAlternative() : ResolverAnyTestCase("empty alternative") { }
+ std::shared_ptr<ResolverTestData> data;
- void run()
+ void SetUp()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("test/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("test/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
+ data = std::make_shared<ResolverTestData>("any", "exheres-0", "exheres");
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
}
- } test_empty_alternative;
- struct TestEmptyAlternativeWithUpgrade : ResolverAnyTestCase
- {
- TestEmptyAlternativeWithUpgrade() :
- ResolverAnyTestCase("empty alternative with upgrade")
+ void TearDown()
{
- install("test", "dep", "2");
+ data.reset();
}
+ };
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("test/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("test/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_empty_alternative_with_upgrade;
+TEST_F(ResolverAnyTestCase, EmptyAlternative)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("test/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("test/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct TestEmptyAlternativeWithUntakenUpgrade : ResolverAnyTestCase
- {
- TestEmptyAlternativeWithUntakenUpgrade() :
- ResolverAnyTestCase("empty alternative with untaken upgrade")
- {
- install("test", "dep", "1");
- }
+TEST_F(ResolverAnyTestCase, EmptyAlternativeWithUpdate)
+{
+ data->install("test", "dep", "2");
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("test/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("test/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("test/target"));
+TEST_F(ResolverAnyTestCase, EmptyAlternativeWithUntakenUpgrade)
+{
+ data->install("test", "dep", "1");
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("test/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("test/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("test/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_empty_alternative_with_untaken_upgrade;
+namespace
+{
+ enum TriboolValue { tri_true, tri_false, tri_indeterminate };
- struct TestEmptyPreferences : ResolverAnyTestCase
+ template <TriboolValue a_, TriboolValue b_>
+ struct ResolverAnyTestEmptyPreferences :
+ ResolverAnyTestCase
{
- const Tribool a, b;
-
- TestEmptyPreferences(const Tribool aa, const Tribool bb) :
- ResolverAnyTestCase("empty preferences " + stringify(aa) + " " + stringify(bb)),
- a(aa),
- b(bb)
+ void common_test_code()
{
+ Tribool a(a_ == tri_true ? true : a_ == tri_false ? false : Tribool(indeterminate));
+ Tribool b(b_ == tri_true ? true : b_ == tri_false ? false : Tribool(indeterminate));
+
if (a.is_true())
- prefer_or_avoid_helper.add_prefer_name(QualifiedPackageName("preferences/dep-a"));
+ data->prefer_or_avoid_helper.add_prefer_name(QualifiedPackageName("preferences/dep-a"));
else if (a.is_false())
- prefer_or_avoid_helper.add_avoid_name(QualifiedPackageName("preferences/dep-a"));
+ data->prefer_or_avoid_helper.add_avoid_name(QualifiedPackageName("preferences/dep-a"));
if (b.is_true())
- prefer_or_avoid_helper.add_prefer_name(QualifiedPackageName("preferences/dep-b"));
+ data->prefer_or_avoid_helper.add_prefer_name(QualifiedPackageName("preferences/dep-b"));
else if (b.is_false())
- prefer_or_avoid_helper.add_avoid_name(QualifiedPackageName("preferences/dep-b"));
- }
+ data->prefer_or_avoid_helper.add_avoid_name(QualifiedPackageName("preferences/dep-b"));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("preferences/target"));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("preferences/target"));
std::shared_ptr<DecisionChecks> checks;
@@ -221,101 +206,93 @@ namespace test_cases
.finished())
);
}
- } test_empty_preferences_tt(true, true),
- test_empty_preferences_ti(true, indeterminate), test_empty_preferences_tf(true, false),
- test_empty_preferences_it(indeterminate, true), test_empty_preferences_ii(indeterminate, indeterminate),
- test_empty_preferences_if(indeterminate, false), test_empty_preferences_ft(false, true),
- test_empty_preferences_fi(false, indeterminate), test_empty_preferences_ff(false, false);
-
- struct TestSelfUseFirst : ResolverAnyTestCase
- {
- TestSelfUseFirst() :
- ResolverAnyTestCase("self use first")
- {
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("self-use-first/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("self-use-first/dep"))
- .change(QualifiedPackageName("self-use-first/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_self_use_first;
-
- struct TestSelfUseSecond : ResolverAnyTestCase
- {
- TestSelfUseSecond() :
- ResolverAnyTestCase("self use second")
- {
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("self-use-second/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("self-use-second/dep"))
- .change(QualifiedPackageName("self-use-second/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_self_use_second;
+ };
+}
- struct TestSelfUseNeither : ResolverAnyTestCase
- {
- TestSelfUseNeither() :
- ResolverAnyTestCase("self use neither")
- {
- }
+typedef ResolverAnyTestEmptyPreferences<tri_true, tri_true> TestEmptyPreferencesTT;
+typedef ResolverAnyTestEmptyPreferences<tri_true, tri_false> TestEmptyPreferencesTF;
+typedef ResolverAnyTestEmptyPreferences<tri_true, tri_indeterminate> TestEmptyPreferencesTI;
+typedef ResolverAnyTestEmptyPreferences<tri_false, tri_true> TestEmptyPreferencesFT;
+typedef ResolverAnyTestEmptyPreferences<tri_false, tri_false> TestEmptyPreferencesFF;
+typedef ResolverAnyTestEmptyPreferences<tri_false, tri_indeterminate> TestEmptyPreferencesFI;
+typedef ResolverAnyTestEmptyPreferences<tri_indeterminate, tri_true> TestEmptyPreferencesIT;
+typedef ResolverAnyTestEmptyPreferences<tri_indeterminate, tri_false> TestEmptyPreferencesIF;
+typedef ResolverAnyTestEmptyPreferences<tri_indeterminate, tri_indeterminate> TestEmptyPreferencesII;
+
+TEST_F(TestEmptyPreferencesTT, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesTF, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesTI, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesFT, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesFF, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesFI, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesIT, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesIF, Works) { common_test_code(); }
+TEST_F(TestEmptyPreferencesII, Works) { common_test_code(); }
+
+TEST_F(ResolverAnyTestCase, SelfUseFirst)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("self-use-first/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-first/dep"))
+ .change(QualifiedPackageName("self-use-first/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("self-use-neither/target"));
+TEST_F(ResolverAnyTestCase, SelfUseSecond)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("self-use-second/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-second/dep"))
+ .change(QualifiedPackageName("self-use-second/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("self-use-neither/dep"))
- .change(QualifiedPackageName("self-use-neither/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("self-use-neither/dep"))
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_self_use_neither;
+TEST_F(ResolverAnyTestCase, SelfUseNeither)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("self-use-neither/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-neither/dep"))
+ .change(QualifiedPackageName("self-use-neither/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-use-neither/dep"))
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_blockers.cc b/paludis/resolver/resolver_TEST_blockers.cc
index fe15af7..a09d85e 100644
--- a/paludis/resolver/resolver_TEST_blockers.cc
+++ b/paludis/resolver/resolver_TEST_blockers.cc
@@ -25,7 +25,9 @@
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.hh>
#include <paludis/resolver/make_uninstall_blocker.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>
@@ -34,12 +36,12 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/stringify.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -49,37 +51,53 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
- struct ResolverBlockersTestCase : ResolverTestCase
+ struct ResolverBlockersTestCase :
+ ResolverTestCase
{
- ResolverBlockersTestCase(const std::string & s, const std::string & e = "exheres-0") :
- ResolverTestCase("blockers", s, e, "exheres")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
+ {
+ data = std::make_shared<ResolverTestData>("blockers", "exheres-0", "exheres");
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
+ }
+
+ void TearDown()
{
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
+ data.reset();
}
};
-}
-namespace test_cases
-{
- struct TestHardBlocker : ResolverBlockersTestCase
+ struct ResolverBlockers0TestCase :
+ ResolverTestCase
{
- const bool transient;
+ std::shared_ptr<ResolverTestData> data;
- TestHardBlocker(const bool t) :
- ResolverBlockersTestCase("hard" + std::string(t ? " transient" : "")),
- transient(t)
+ void SetUp()
{
- install("hard", "a-pkg", "1");
- install("hard", "z-pkg", "1");
+ data = std::make_shared<ResolverTestData>("blockers", "0", "exheres");
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
}
- void run()
+ void TearDown()
+ {
+ data.reset();
+ }
+ };
+
+ template <bool transient_>
+ struct TestHardBlockerTestCase :
+ ResolverBlockersTestCase
+ {
+ void common_test_code()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("hard/target"));
+ data->install("hard", "a-pkg", "1")->behaviours_set()->insert(transient_ ? "transient" : "");
+ data->install("hard", "z-pkg", "1")->behaviours_set()->insert(transient_ ? "transient" : "");
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("hard/target"));
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName("hard/a-pkg"))
@@ -98,22 +116,26 @@ namespace test_cases
.finished())
);
}
- } test_hard_blocker(false), test_hard_blocker_transient(true);
+ };
+}
- struct TestUnfixableBlocker : ResolverBlockersTestCase
- {
- const bool transient;
+typedef TestHardBlockerTestCase<false> HardBlockerTestF;
+typedef TestHardBlockerTestCase<true> HardBlockerTestT;
- TestUnfixableBlocker(const bool t) :
- ResolverBlockersTestCase("unfixable" + std::string(t ? " transient" : "")),
- transient(t)
- {
- install("unfixable", "a-pkg", "1")->behaviours_set()->insert(transient ? "transient" : "");
- }
+TEST_F(HardBlockerTestF, Works) { common_test_code(); }
+TEST_F(HardBlockerTestT, Works) { common_test_code(); }
- void run()
+namespace
+{
+ template <bool transient_>
+ struct TestUnfixableBlockerTestCase :
+ ResolverBlockersTestCase
+ {
+ void common_test_code()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("unfixable/target"));
+ data->install("unfixable", "a-pkg", "1")->behaviours_set()->insert(transient_ ? "transient" : "");
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("unfixable/target"));
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName("unfixable/target"))
@@ -131,25 +153,29 @@ namespace test_cases
.finished())
);
}
- } test_unfixable_blocker(false), test_unfixable_blocker_transient(true);
+ };
+}
- struct TestRemoveBlocker : ResolverBlockersTestCase
- {
- const bool transient;
+typedef TestUnfixableBlockerTestCase<true> UnfixableBlockerT;
+typedef TestUnfixableBlockerTestCase<false> UnfixableBlockerF;
- TestRemoveBlocker(const bool t) :
- ResolverBlockersTestCase("remove" + std::string(t ? " transient" : "")),
- transient(t)
- {
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("remove/a-pkg", &env, { }));
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("remove/z-pkg", &env, { }));
- install("remove", "a-pkg", "1")->behaviours_set()->insert(transient ? "transient" : "");
- install("remove", "z-pkg", "1")->behaviours_set()->insert(transient ? "transient" : "");
- }
+TEST_F(UnfixableBlockerT, Works) { common_test_code(); }
+TEST_F(UnfixableBlockerF, Works) { common_test_code(); }
- void run()
+namespace
+{
+ template <bool transient_>
+ struct TestRemoveBlockerTestCase :
+ ResolverBlockersTestCase
+ {
+ void common_test_code()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("remove/target"));
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("remove/a-pkg", &data->env, UserPackageDepSpecOptions()));
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("remove/z-pkg", &data->env, UserPackageDepSpecOptions()));
+ data->install("remove", "a-pkg", "1")->behaviours_set()->insert(transient_ ? "transient" : "");
+ data->install("remove", "z-pkg", "1")->behaviours_set()->insert(transient_ ? "transient" : "");
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("remove/target"));
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
.remove(QualifiedPackageName("remove/a-pkg"))
@@ -168,29 +194,33 @@ namespace test_cases
.finished())
);
}
- } test_remove_blocker(false), test_remove_blocker_transient(true);
+ };
+}
- struct TestTargetBlocker : ResolverBlockersTestCase
- {
- const bool exists;
+typedef TestRemoveBlockerTestCase<true> RemoveBlockerT;
+typedef TestRemoveBlockerTestCase<false> RemoveBlockerF;
- TestTargetBlocker(const bool x) :
- ResolverBlockersTestCase("target" + std::string(x ? " exists" : "")),
- exists(x)
+TEST_F(RemoveBlockerT, Worsk) { common_test_code(); }
+TEST_F(RemoveBlockerF, Worsk) { common_test_code(); }
+
+namespace
+{
+ template <bool exists_>
+ struct TestTargetBlockerTestCase :
+ ResolverBlockersTestCase
+ {
+ void common_test_code()
{
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("target/target", &env, { }));
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("target/target", &data->env, UserPackageDepSpecOptions()));
- if (exists)
- install("target", "target", "1");
- }
+ if (exists_)
+ data->install("target", "target", "1");
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved(make_uninstall_blocker(
- parse_user_package_dep_spec("target/target", &env, { }))));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved(make_uninstall_blocker(
+ parse_user_package_dep_spec("target/target", &data->env, UserPackageDepSpecOptions()))));
check_resolved(resolved,
- n::taken_change_or_remove_decisions() = exists ? make_shared_copy(DecisionChecks()
+ n::taken_change_or_remove_decisions() = exists_ ? make_shared_copy(DecisionChecks()
.remove(QualifiedPackageName("target/target"))
.finished()) : make_shared_copy(DecisionChecks()
.finished()),
@@ -206,30 +236,30 @@ namespace test_cases
.finished())
);
}
- } test_target(false), test_target_exists(true);
+ };
+}
+
+typedef TestTargetBlockerTestCase<true> TestTargetT;
+typedef TestTargetBlockerTestCase<false> TestTargetF;
- struct BlockedAndDep : ResolverBlockersTestCase
+TEST_F(TestTargetT, Works) { common_test_code(); }
+TEST_F(TestTargetF, Works) { common_test_code(); }
+
+namespace
+{
+ template <bool exists_, bool allowed_>
+ struct BlockedAndDepTestCase :
+ ResolverBlockersTestCase
{
- const bool exists;
- const bool allowed;
-
- BlockedAndDep(const bool x, const bool a) :
- ResolverBlockersTestCase("blocked and dep"
- + std::string(x ? " exists" : "")
- + std::string(a ? " allowed" : "")),
- exists(x),
- allowed(a)
+ void common_test_code()
{
- if (allowed)
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("blocked-and-dep/both", &env, { }));
+ if (allowed_)
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("blocked-and-dep/both", &data->env, UserPackageDepSpecOptions()));
- if (exists)
- install("blocked-and-dep", "both", "1");
- }
+ if (exists_)
+ data->install("blocked-and-dep", "both", "1");
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("blocked-and-dep/target"));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("blocked-and-dep/target"));
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
@@ -248,102 +278,87 @@ namespace test_cases
.finished())
);
}
- } test_blocked_and_dep(false, false),
- test_blocked_and_dep_exists(true, false),
- test_blocked_and_dep_allowed(false, true),
- test_blocked_and_dep_exists_allowed(true, true);
-
- struct BlockAndDepCycle : ResolverBlockersTestCase
- {
- BlockAndDepCycle() :
- ResolverBlockersTestCase("block and dep cycle", "0")
- {
- install("block-and-dep-cycle", "target", "0");
- }
+ };
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("block-and-dep-cycle/target"));
+typedef BlockedAndDepTestCase<false, false> BlockedAndDepFF;
+typedef BlockedAndDepTestCase<false, true> BlockedAndDepFT;
+typedef BlockedAndDepTestCase<true, false> BlockedAndDepTF;
+typedef BlockedAndDepTestCase<true, true> BlockedAndDepTT;
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("block-and-dep-cycle/dep"))
- .change(QualifiedPackageName("block-and-dep-cycle/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_block_and_dep_cycle;
+TEST_F(BlockedAndDepFF, Works) { common_test_code(); }
+TEST_F(BlockedAndDepFT, Works) { common_test_code(); }
+TEST_F(BlockedAndDepTF, Works) { common_test_code(); }
+TEST_F(BlockedAndDepTT, Works) { common_test_code(); }
- struct HardBlockAndDepCycle : ResolverBlockersTestCase
- {
- HardBlockAndDepCycle() :
- ResolverBlockersTestCase("hard block and dep cycle", "0")
- {
- install("hard-block-and-dep-cycle", "target", "0");
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("hard-block-and-dep-cycle/target"));
+TEST_F(ResolverBlockers0TestCase, Cycle)
+{
+ data->install("block-and-dep-cycle", "target", "0");
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("block-and-dep-cycle/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("block-and-dep-cycle/dep"))
+ .change(QualifiedPackageName("block-and-dep-cycle/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("hard-block-and-dep-cycle/dep"))
- .change(QualifiedPackageName("hard-block-and-dep-cycle/target"))
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_hard_block_and_dep_cycle;
+TEST_F(ResolverBlockers0TestCase, HardBlockAndDepCycle)
+{
+ data->install("hard-block-and-dep-cycle", "target", "0");
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("hard-block-and-dep-cycle/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("hard-block-and-dep-cycle/dep"))
+ .change(QualifiedPackageName("hard-block-and-dep-cycle/target"))
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct SelfBlock : ResolverBlockersTestCase
+namespace
+{
+ template <int installed_version_, int dep_version_, bool strong_>
+ struct SelfBlockTestCase :
+ ResolverBlockers0TestCase
{
- const int installed_version;
- const int dep_version;
- const bool strong;
- const std::string cat;
-
- SelfBlock(int i, int d, bool s) :
- ResolverBlockersTestCase("self block " + stringify(i) + " " + stringify(d) + " " + stringify(s), "0"),
- installed_version(i),
- dep_version(d),
- strong(s),
- cat(std::string("self-block-") +
- (-1 == installed_version ? "x" : stringify(installed_version)) + "-" +
- (-1 == dep_version ? "x" : stringify(dep_version)) + "-" +
- (strong ? "s" : "w"))
+ void common_test_code()
{
- if (installed_version != -1)
- install(cat, "dep", stringify(installed_version));
+ std::string cat(std::string("self-block-") +
+ (-1 == installed_version_ ? "x" : stringify(installed_version_)) + "-" +
+ (-1 == dep_version_ ? "x" : stringify(dep_version_)) + "-" +
+ (strong_ ? "s" : "w"));
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec(stringify(cat) + "/dep", &env, { }));
- }
+ if (installed_version_ != -1)
+ data->install(cat, "dep", stringify(installed_version_));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved(cat + "/target"));
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec(stringify(cat) + "/dep", &data->env, UserPackageDepSpecOptions()));
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved(cat + "/target"));
std::shared_ptr<DecisionChecks> checks, u_checks, o_checks;
- if (dep_version != 0)
+ if (dep_version_ != 0)
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName(cat + "/target"))
@@ -354,7 +369,7 @@ namespace test_cases
o_checks = make_shared_copy(DecisionChecks()
.finished());
}
- else if (installed_version == -1)
+ else if (installed_version_ == -1)
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName(cat + "/dep"))
@@ -365,7 +380,7 @@ namespace test_cases
o_checks = make_shared_copy(DecisionChecks()
.finished());
}
- else if (installed_version == 1 || ((! strong) && installed_version == 0))
+ else if (installed_version_ == 1 || ((! strong_) && installed_version_ == 0))
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName(cat + "/dep"))
@@ -376,7 +391,7 @@ namespace test_cases
o_checks = make_shared_copy(DecisionChecks()
.finished());
}
- else if (strong && installed_version == 0 && dep_version == 0)
+ else if (strong_ && installed_version_ == 0 && dep_version_ == 0)
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName(cat + "/target"))
@@ -388,9 +403,9 @@ namespace test_cases
.finished());
}
- TEST_CHECK(bool(checks));
- TEST_CHECK(bool(u_checks));
- TEST_CHECK(bool(o_checks));
+ ASSERT_TRUE(bool(checks));
+ ASSERT_TRUE(bool(u_checks));
+ ASSERT_TRUE(bool(o_checks));
check_resolved(resolved,
n::taken_change_or_remove_decisions() = checks,
@@ -404,173 +419,164 @@ namespace test_cases
.finished())
);
}
- } test_self_block_x_x_w(-1, -1, false), test_self_block_x_x_s(-1, -1, true),
- test_self_block_0_x_w( 0, -1, false), test_self_block_0_x_s( 0, -1, true),
- test_self_block_1_x_w( 1, -1, false), test_self_block_1_x_s( 1, -1, true),
- test_self_block_x_0_w(-1, 0, false), test_self_block_x_0_s(-1, 0, true),
- test_self_block_0_0_w( 0, 0, false), test_self_block_0_0_s( 0, 0, true),
- test_self_block_1_0_w( 1, 0, false), test_self_block_1_0_s( 1, 0, true),
- test_self_block_x_1_w(-1, 1, false), test_self_block_x_1_s(-1, 1, true),
- test_self_block_0_1_w( 0, 1, false), test_self_block_0_1_s( 0, 1, true),
- test_self_block_1_1_w( 1, 1, false), test_self_block_1_1_s( 1, 1, true);
-
- struct UninstallBlockedAfter : ResolverBlockersTestCase
- {
- UninstallBlockedAfter() :
- ResolverBlockersTestCase("uninstall blocked after")
- {
- install("uninstall-blocked-after", "dep", "1");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("uninstall-blocked-after/dep", &env, { }));
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("uninstall-blocked-after/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("uninstall-blocked-after/target"))
- .remove(QualifiedPackageName("uninstall-blocked-after/dep"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_uninstall_blocked_after;
-
- struct UninstallBlockedBefore : ResolverBlockersTestCase
- {
- UninstallBlockedBefore() :
- ResolverBlockersTestCase("uninstall blocked before")
- {
- install("uninstall-blocked-before", "dep", "1");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("uninstall-blocked-before/dep", &env, { }));
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("uninstall-blocked-before/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .remove(QualifiedPackageName("uninstall-blocked-before/dep"))
- .change(QualifiedPackageName("uninstall-blocked-before/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_uninstall_blocked_before;
-
- struct UpgradeBlockedBefore : ResolverBlockersTestCase
- {
- UpgradeBlockedBefore() :
- ResolverBlockersTestCase("upgrade blocked before")
- {
- install("upgrade-blocked-before", "dep", "1");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("upgrade-blocked-before/dep", &env, { }));
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("upgrade-blocked-before/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("upgrade-blocked-before/dep"))
- .change(QualifiedPackageName("upgrade-blocked-before/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_upgrade_blocked_before;
-
- struct Manual : ResolverBlockersTestCase
- {
- Manual() :
- ResolverBlockersTestCase("manual")
- {
- install("manual", "dep", "1");
- }
+ };
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("manual/target"));
+typedef SelfBlockTestCase<-1, -1, false> TestSelfBlockXXW;
+typedef SelfBlockTestCase<-1, -1, true> TestSelfBlockXXS;
+typedef SelfBlockTestCase< 0, -1, false> TestSelfBlock0XW;
+typedef SelfBlockTestCase< 0, -1, true> TestSelfBlock0XS;
+typedef SelfBlockTestCase< 1, -1, false> TestSelfBlock1XW;
+typedef SelfBlockTestCase< 1, -1, true> TestSelfBlock1XS;
+typedef SelfBlockTestCase<-1, 0, false> TestSelfBlockX0W;
+typedef SelfBlockTestCase<-1, 0, true> TestSelfBlockX0S;
+typedef SelfBlockTestCase< 0, 0, false> TestSelfBlock00W;
+typedef SelfBlockTestCase< 0, 0, true> TestSelfBlock00S;
+typedef SelfBlockTestCase< 1, 0, false> TestSelfBlock10W;
+typedef SelfBlockTestCase< 1, 0, true> TestSelfBlock10S;
+typedef SelfBlockTestCase<-1, 1, false> TestSelfBlockX1W;
+typedef SelfBlockTestCase<-1, 1, true> TestSelfBlockX1S;
+typedef SelfBlockTestCase< 0, 1, false> TestSelfBlock01W;
+typedef SelfBlockTestCase< 0, 1, true> TestSelfBlock01S;
+typedef SelfBlockTestCase< 1, 1, false> TestSelfBlock11W;
+typedef SelfBlockTestCase< 1, 1, true> TestSelfBlock11S;
+
+TEST_F(TestSelfBlockXXW, Works) { common_test_code(); }
+TEST_F(TestSelfBlockXXS, Works) { common_test_code(); }
+TEST_F(TestSelfBlock0XW, Works) { common_test_code(); }
+TEST_F(TestSelfBlock0XS, Works) { common_test_code(); }
+TEST_F(TestSelfBlock1XW, Works) { common_test_code(); }
+TEST_F(TestSelfBlock1XS, Works) { common_test_code(); }
+TEST_F(TestSelfBlockX0W, Works) { common_test_code(); }
+TEST_F(TestSelfBlockX0S, Works) { common_test_code(); }
+TEST_F(TestSelfBlock00W, Works) { common_test_code(); }
+TEST_F(TestSelfBlock00S, Works) { common_test_code(); }
+TEST_F(TestSelfBlock10W, Works) { common_test_code(); }
+TEST_F(TestSelfBlock10S, Works) { common_test_code(); }
+TEST_F(TestSelfBlockX1W, Works) { common_test_code(); }
+TEST_F(TestSelfBlockX1S, Works) { common_test_code(); }
+TEST_F(TestSelfBlock01W, Works) { common_test_code(); }
+TEST_F(TestSelfBlock01S, Works) { common_test_code(); }
+TEST_F(TestSelfBlock11W, Works) { common_test_code(); }
+TEST_F(TestSelfBlock11S, Works) { common_test_code(); }
+
+TEST_F(ResolverBlockersTestCase, UninstallBlockedAfter)
+{
+ data->install("uninstall-blocked-after", "dep", "1");
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("uninstall-blocked-after/dep", &data->env, UserPackageDepSpecOptions()));
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("uninstall-blocked-after/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("uninstall-blocked-after/target"))
+ .remove(QualifiedPackageName("uninstall-blocked-after/dep"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("manual/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .unable(QualifiedPackageName("manual/dep"))
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_manual;
+TEST_F(ResolverBlockersTestCase, UninstallBlockedBefore)
+{
+ data->install("uninstall-blocked-before", "dep", "1");
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("uninstall-blocked-before/dep", &data->env, UserPackageDepSpecOptions()));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("uninstall-blocked-before/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .remove(QualifiedPackageName("uninstall-blocked-before/dep"))
+ .change(QualifiedPackageName("uninstall-blocked-before/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct UpgradeOtherSlotFirst : ResolverBlockersTestCase
- {
- UpgradeOtherSlotFirst() :
- ResolverBlockersTestCase("other-slot-first")
- {
- install("other-slot-first", "dep", "1")->set_slot(SlotName("1"));
- }
+TEST_F(ResolverBlockersTestCase, UpgradeBlockedBefore)
+{
+ data->install("upgrade-blocked-before", "dep", "1");
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("upgrade-blocked-before/dep", &data->env, UserPackageDepSpecOptions()));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("upgrade-blocked-before/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("upgrade-blocked-before/dep"))
+ .change(QualifiedPackageName("upgrade-blocked-before/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("other-slot-first/target"));
+TEST_F(ResolverBlockersTestCase, Manual)
+{
+ data->install("manual", "dep", "1");
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("manual/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("manual/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .unable(QualifiedPackageName("manual/dep"))
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change_slot(QualifiedPackageName("other-slot-first/dep"), SlotName("1"))
- .change_slot(QualifiedPackageName("other-slot-first/dep"), SlotName("2"))
- .change(QualifiedPackageName("other-slot-first/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_upgrade_other_slot_first;
+TEST_F(ResolverBlockersTestCase, OtherSlotFirst)
+{
+ data->install("other-slot-first", "dep", "1")->set_slot(SlotName("1"));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("other-slot-first/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change_slot(QualifiedPackageName("other-slot-first/dep"), SlotName("1"))
+ .change_slot(QualifiedPackageName("other-slot-first/dep"), SlotName("2"))
+ .change(QualifiedPackageName("other-slot-first/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_continue_on_failure.cc b/paludis/resolver/resolver_TEST_continue_on_failure.cc
index f4b490b..b5254cf 100644
--- a/paludis/resolver/resolver_TEST_continue_on_failure.cc
+++ b/paludis/resolver/resolver_TEST_continue_on_failure.cc
@@ -29,7 +29,9 @@
#include <paludis/resolver/job.hh>
#include <paludis/resolver/job_requirements.hh>
#include <paludis/resolver/make_uninstall_blocker.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>
@@ -41,12 +43,11 @@
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/join.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -56,15 +57,22 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
- struct ResolverContinueOnFailureTestCase : ResolverTestCase
+ struct ResolverContinueOnFailureTestCase :
+ ResolverTestCase
{
- ResolverContinueOnFailureTestCase(const std::string & s) :
- ResolverTestCase("continue_on_failure", s, "exheres-0", "exheres")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
{
+ data = std::make_shared<ResolverTestData>("continue_on_failure", "exheres-0", "exheres");
+ }
+
+ void TearDown()
+ {
+ data.reset();
}
};
@@ -83,27 +91,22 @@ namespace
}
}
-namespace test_cases
+namespace
{
- struct TestContinueOnFailure : ResolverContinueOnFailureTestCase
+ template <bool direct_dep_installed_>
+ struct TestContinueOnFailure :
+ ResolverContinueOnFailureTestCase
{
- const bool direct_dep_installed;
-
- TestContinueOnFailure(const bool d) :
- ResolverContinueOnFailureTestCase("continue on failure " + stringify(d)),
- direct_dep_installed(d)
+ void common_test_code()
{
- if (d)
- install("continue-on-failure", "direct-dep", "0");
- install("continue-on-failure", "unchanged-dep", "1")->build_dependencies_key()->set_from_string("continue-on-failure/indirect-dep");
+ if (direct_dep_installed_)
+ data->install("continue-on-failure", "direct-dep", "0");
+ data->install("continue-on-failure", "unchanged-dep", "1")->build_dependencies_key()->set_from_string("continue-on-failure/indirect-dep");
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
- get_use_existing_nothing_helper.set_use_existing_for_targets(ue_if_same);
- }
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
+ data->get_use_existing_nothing_helper.set_use_existing_for_targets(ue_if_same);
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("continue-on-failure/target"));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("continue-on-failure/target"));
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
@@ -123,94 +126,89 @@ namespace test_cases
.finished())
);
- TEST_CHECK_EQUAL(resolved->job_lists()->execute_job_list()->length(), 6);
+ EXPECT_EQ(6, resolved->job_lists()->execute_job_list()->length());
const InstallJob * const direct_dep_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
- TEST_CHECK(direct_dep_job);
- TEST_CHECK_EQUAL(join(direct_dep_job->requirements()->begin(), direct_dep_job->requirements()->end(), ", ", stringify_req),
- "0 satisfied independent always");
+ ASSERT_TRUE(direct_dep_job);
+ EXPECT_EQ("0 satisfied independent always",
+ join(direct_dep_job->requirements()->begin(), direct_dep_job->requirements()->end(), ", ", stringify_req));
const InstallJob * const indirect_dep_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
- TEST_CHECK(indirect_dep_job);
- TEST_CHECK_EQUAL(join(indirect_dep_job->requirements()->begin(), indirect_dep_job->requirements()->end(), ", ", stringify_req),
- "2 satisfied independent always");
+ ASSERT_TRUE(indirect_dep_job);
+ EXPECT_EQ("2 satisfied independent always",
+ join(indirect_dep_job->requirements()->begin(), indirect_dep_job->requirements()->end(), ", ", stringify_req));
const InstallJob * const target_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(5)));
- TEST_CHECK(target_job);
- if (direct_dep_installed)
- TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
- "4 satisfied independent always, 3 independent, 1 independent");
+ ASSERT_TRUE(target_job);
+ if (direct_dep_installed_)
+ EXPECT_EQ("4 satisfied independent always, 3 independent, 1 independent",
+ join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req));
else
- TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
- "4 satisfied independent always, 1 satisfied, 3 independent, 1 independent");
+ EXPECT_EQ("4 satisfied independent always, 1 satisfied, 3 independent, 1 independent",
+ join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req));
}
- } test_continue_on_failure_false(false), test_continue_on_failure_true(true);
-
- struct TestUninstallContinueOnFailure : ResolverContinueOnFailureTestCase
- {
- TestUninstallContinueOnFailure() :
- ResolverContinueOnFailureTestCase("uninstall continue on failure")
- {
- install("continue-on-failure-uninstall", "dep-of-dep", "1")->build_dependencies_key()->set_from_string("");
- install("continue-on-failure-uninstall", "dep", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/dep-of-dep");
- install("continue-on-failure-uninstall", "target", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/dep");
- install("continue-on-failure-uninstall", "needs-target", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/target");
-
- get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep-of-dep", &env, { }));
- get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep", &env, { }));
- get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/target", &env, { }));
-
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &env, { }));
-
- remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &env, { }));
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved(make_uninstall_blocker(
- parse_user_package_dep_spec("continue-on-failure-uninstall/target", &env, { }))));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .remove(QualifiedPackageName("continue-on-failure-uninstall/needs-target"))
- .remove(QualifiedPackageName("continue-on-failure-uninstall/target"))
- .remove(QualifiedPackageName("continue-on-failure-uninstall/dep"))
- .remove(QualifiedPackageName("continue-on-failure-uninstall/dep-of-dep"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
-
- TEST_CHECK_EQUAL(resolved->job_lists()->execute_job_list()->length(), 4);
-
- const UninstallJob * const needs_target_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(0)));
- TEST_CHECK(needs_target_job);
- TEST_CHECK_EQUAL(join(needs_target_job->requirements()->begin(), needs_target_job->requirements()->end(), ", ", stringify_req),
- "");
+ };
+}
- const UninstallJob * const target_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
- TEST_CHECK(target_job);
- TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
- "0 satisfied");
+typedef TestContinueOnFailure<false> ContinueOnFailureF;
+typedef TestContinueOnFailure<true> ContinueOnFailureT;
- const UninstallJob * const dep_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(2)));
- TEST_CHECK(dep_job);
- TEST_CHECK_EQUAL(join(dep_job->requirements()->begin(), dep_job->requirements()->end(), ", ", stringify_req),
- "1 satisfied");
+TEST_F(ContinueOnFailureF, Works) { common_test_code(); }
+TEST_F(ContinueOnFailureT, Works) { common_test_code(); }
- const UninstallJob * const dep_of_dep_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
- TEST_CHECK(dep_of_dep_job);
- TEST_CHECK_EQUAL(join(dep_of_dep_job->requirements()->begin(), dep_of_dep_job->requirements()->end(), ", ", stringify_req),
- "2 satisfied");
- }
- } test_uninstall_continue_on_failure_uninstall;
+TEST_F(ResolverContinueOnFailureTestCase, Uninstall)
+{
+ data->install("continue-on-failure-uninstall", "dep-of-dep", "1")->build_dependencies_key()->set_from_string("");
+ data->install("continue-on-failure-uninstall", "dep", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/dep-of-dep");
+ data->install("continue-on-failure-uninstall", "target", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/dep");
+ data->install("continue-on-failure-uninstall", "needs-target", "1")->build_dependencies_key()->set_from_string("continue-on-failure-uninstall/target");
+
+ data->get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep-of-dep", &data->env, { }));
+ data->get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/dep", &data->env, { }));
+ data->get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/target", &data->env, { }));
+
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &data->env, { }));
+
+ data->remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec("continue-on-failure-uninstall/needs-target", &data->env, { }));
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved(make_uninstall_blocker(
+ parse_user_package_dep_spec("continue-on-failure-uninstall/target", &data->env, { }))));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .remove(QualifiedPackageName("continue-on-failure-uninstall/needs-target"))
+ .remove(QualifiedPackageName("continue-on-failure-uninstall/target"))
+ .remove(QualifiedPackageName("continue-on-failure-uninstall/dep"))
+ .remove(QualifiedPackageName("continue-on-failure-uninstall/dep-of-dep"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+
+ EXPECT_EQ(4, resolved->job_lists()->execute_job_list()->length());
+
+ const UninstallJob * const needs_target_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(0)));
+ ASSERT_TRUE(needs_target_job);
+ EXPECT_EQ("", join(needs_target_job->requirements()->begin(), needs_target_job->requirements()->end(), ", ", stringify_req));
+
+ const UninstallJob * const target_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
+ ASSERT_TRUE(target_job);
+ EXPECT_EQ("0 satisfied", join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req));
+
+ const UninstallJob * const dep_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(2)));
+ ASSERT_TRUE(dep_job);
+ EXPECT_EQ("1 satisfied", join(dep_job->requirements()->begin(), dep_job->requirements()->end(), ", ", stringify_req));
+
+ const UninstallJob * const dep_of_dep_job(visitor_cast<const UninstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
+ ASSERT_TRUE(dep_of_dep_job);
+ EXPECT_EQ("2 satisfied", join(dep_of_dep_job->requirements()->begin(), dep_of_dep_job->requirements()->end(), ", ", stringify_req));
}
diff --git a/paludis/resolver/resolver_TEST_cycles.cc b/paludis/resolver/resolver_TEST_cycles.cc
index d12c201..2e5db63 100644
--- a/paludis/resolver/resolver_TEST_cycles.cc
+++ b/paludis/resolver/resolver_TEST_cycles.cc
@@ -24,7 +24,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -33,12 +35,12 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
+#include <paludis/util/stringify.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -48,166 +50,140 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverCyclesTestCase : ResolverTestCase
{
- ResolverCyclesTestCase(const std::string & s) :
- ResolverTestCase("cycles", s, "exheres-0", "exheres")
- {
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
- }
- };
-}
-
-namespace test_cases
-{
- struct TestNoChanges : ResolverCyclesTestCase
- {
- 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");
-
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("no-changes/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("no-changes/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_no_changes;
+ std::shared_ptr<ResolverTestData> data;
- struct TestExistingUsable : ResolverCyclesTestCase
- {
- TestExistingUsable() :
- ResolverCyclesTestCase("existing-usable")
+ void SetUp()
{
- install("existing-usable", "dep", "1");
+ data = std::make_shared<ResolverTestData>("cycles", "exheres-0", "exheres");
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
}
- void run()
+ void TearDown()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("existing-usable/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("existing-usable/target"))
- .change(QualifiedPackageName("existing-usable/dep"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
+ data.reset();
}
- } test_existing_usable;
-
- struct TestMutualRunDeps : ResolverCyclesTestCase
- {
- TestMutualRunDeps() : ResolverCyclesTestCase("mutual-run-deps") { }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("mutual-run-deps/target"));
+ };
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("mutual-run-deps/dep-a"))
- .change(QualifiedPackageName("mutual-run-deps/dep-b"))
- .change(QualifiedPackageName("mutual-run-deps/dep-c"))
- .change(QualifiedPackageName("mutual-run-deps/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_mutual_run_deps;
+TEST_F(ResolverCyclesTestCase, NoChanges)
+{
+ data->install("no-changes", "dep-a", "1")->build_dependencies_key()->set_from_string("no-changes/dep-b");
+ data->install("no-changes", "dep-b", "1")->build_dependencies_key()->set_from_string("no-changes/dep-a");
+
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("no-changes/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("no-changes/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct TestMutualBuildDeps : ResolverCyclesTestCase
- {
- TestMutualBuildDeps() : ResolverCyclesTestCase("mutual-build-deps") { }
+TEST_F(ResolverCyclesTestCase, ExistingUsable)
+{
+ data->install("existing-usable", "dep", "1");
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("existing-usable/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("existing-usable/target"))
+ .change(QualifiedPackageName("existing-usable/dep"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("mutual-build-deps/target"));
+TEST_F(ResolverCyclesTestCase, MutualRunDeps)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("mutual-run-deps/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("mutual-run-deps/dep-a"))
+ .change(QualifiedPackageName("mutual-run-deps/dep-b"))
+ .change(QualifiedPackageName("mutual-run-deps/dep-c"))
+ .change(QualifiedPackageName("mutual-run-deps/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("mutual-build-deps/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("mutual-build-deps/dep-a"))
- .change(QualifiedPackageName("mutual-build-deps/dep-b"))
- .change(QualifiedPackageName("mutual-build-deps/dep-c"))
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_mutual_build_deps;
+TEST_F(ResolverCyclesTestCase, MutualBuildDeps)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("mutual-build-deps/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("mutual-build-deps/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("mutual-build-deps/dep-a"))
+ .change(QualifiedPackageName("mutual-build-deps/dep-b"))
+ .change(QualifiedPackageName("mutual-build-deps/dep-c"))
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct TestTriangle : ResolverCyclesTestCase
+namespace
+{
+ template <bool b_installed_, bool c_installed_>
+ struct ResolverCyclesTriangleInstalledTestCase :
+ ResolverCyclesTestCase
{
- const bool b_installed;
- const bool c_installed;
-
- TestTriangle(bool b, bool c) :
- ResolverCyclesTestCase("triangle " + stringify(b) + " " + stringify(c)),
- b_installed(b),
- c_installed(c)
+ void common_test_code()
{
- if (b_installed)
- install("triangle", "dep-b", "1");
- if (c_installed)
- install("triangle", "dep-c", "1");
- }
+ if (b_installed_)
+ data->install("triangle", "dep-b", "1");
+ if (c_installed_)
+ data->install("triangle", "dep-c", "1");
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("triangle/target"));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("triangle/target"));
std::shared_ptr<DecisionChecks> checks, u_checks;
- if (b_installed)
+ if (b_installed_)
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName("triangle/dep-c"))
@@ -218,7 +194,7 @@ namespace test_cases
u_checks = make_shared_copy(DecisionChecks()
.finished());
}
- else if (c_installed)
+ else if (c_installed_)
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName("triangle/dep-a"))
@@ -254,34 +230,38 @@ namespace test_cases
.finished())
);
}
- } test_triangle_none(false, false), test_triangle_b(true, false), test_triangle_c(false, true);
+ };
+}
+
+typedef ResolverCyclesTriangleInstalledTestCase<false, false> TriangleInstalledFF;
+typedef ResolverCyclesTriangleInstalledTestCase<false, true> TriangleInstalledFT;
+typedef ResolverCyclesTriangleInstalledTestCase<true, false> TriangleInstalledTF;
- struct TestSelf : ResolverCyclesTestCase
+TEST_F(TriangleInstalledFF, Works) { common_test_code(); }
+TEST_F(TriangleInstalledFT, Works) { common_test_code(); }
+TEST_F(TriangleInstalledTF, Works) { common_test_code(); }
+
+namespace
+{
+ template <int installed_version_, bool runtime_>
+ struct ResolverCyclesSelfTestCase :
+ ResolverCyclesTestCase
{
- const int installed_version;
- const bool runtime;
- const std::string cat;
-
- TestSelf (const int i, const bool r) :
- ResolverCyclesTestCase("self " + stringify(i) + " " + stringify(r)),
- installed_version(i),
- runtime(r),
- cat(runtime ? "self-run" : "self-build")
+ void common_test_code()
{
- if (-1 != installed_version)
- install(cat, "dep", stringify(installed_version));
+ std::string cat(runtime_ ? "self-run" : "self-build");
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
- }
+ if (-1 != installed_version_)
+ data->install(cat, "dep", stringify(installed_version_));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved(cat + "/target"));
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved(cat + "/target"));
std::shared_ptr<DecisionChecks> checks, u_checks;
- if (runtime || installed_version == 1)
+ if (runtime_ || installed_version_ == 1)
{
- if (installed_version == 1)
+ if (installed_version_ == 1)
{
checks = make_shared_copy(DecisionChecks()
.change(QualifiedPackageName(cat + "/target"))
@@ -322,78 +302,74 @@ namespace test_cases
.finished())
);
}
- }
- test_self_x_b(-1, false), test_self_x_r(-1, true),
- test_self_0_b( 0, false), test_self_0_r( 0, true),
- test_self_1_b( 1, false), test_self_1_r( 1, true);
-
- struct CycleDeps : ResolverCyclesTestCase
- {
- CycleDeps() :
- ResolverCyclesTestCase("cycle deps")
- {
- install("cycle-deps", "dep-g", "1")->build_dependencies_key()->set_from_string("cycle-deps/dep-c");
-
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
- }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("cycle-deps/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("cycle-deps/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("cycle-deps/dep-d"))
- .change(QualifiedPackageName("cycle-deps/dep-e"))
- .change(QualifiedPackageName("cycle-deps/dep-f"))
- .change(QualifiedPackageName("cycle-deps/dep-a"))
- .change(QualifiedPackageName("cycle-deps/dep-b"))
- .change(QualifiedPackageName("cycle-deps/dep-c"))
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_cycle_deps;
-
- struct TestBuildAgainstBlock : ResolverCyclesTestCase
- {
- TestBuildAgainstBlock() :
- ResolverCyclesTestCase("build against block")
- {
- }
+ };
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("build-against-block/target"));
+typedef ResolverCyclesSelfTestCase<-1, false> TriangleSelfNoneFalse;
+typedef ResolverCyclesSelfTestCase<-1, true> TriangleSelfNoneTrue;
+typedef ResolverCyclesSelfTestCase<0, false> TriangleSelf0False;
+typedef ResolverCyclesSelfTestCase<0, true> TriangleSelf0True;
+typedef ResolverCyclesSelfTestCase<1, false> TriangleSelf1False;
+typedef ResolverCyclesSelfTestCase<1, true> TriangleSelf1True;
+
+TEST_F(TriangleSelfNoneFalse, Works) { common_test_code(); }
+TEST_F(TriangleSelfNoneTrue, Works) { common_test_code(); }
+TEST_F(TriangleSelf0False, Works) { common_test_code(); }
+TEST_F(TriangleSelf0True, Works) { common_test_code(); }
+TEST_F(TriangleSelf1False, Works) { common_test_code(); }
+TEST_F(TriangleSelf1True, Works) { common_test_code(); }
+
+TEST_F(ResolverCyclesTestCase, CycleDeps)
+{
+ data->install("cycle-deps", "dep-g", "1")->build_dependencies_key()->set_from_string("cycle-deps/dep-c");
+
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_same);
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("cycle-deps/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("cycle-deps/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("cycle-deps/dep-d"))
+ .change(QualifiedPackageName("cycle-deps/dep-e"))
+ .change(QualifiedPackageName("cycle-deps/dep-f"))
+ .change(QualifiedPackageName("cycle-deps/dep-a"))
+ .change(QualifiedPackageName("cycle-deps/dep-b"))
+ .change(QualifiedPackageName("cycle-deps/dep-c"))
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("build-against-block/dep-b"))
- .change(QualifiedPackageName("build-against-block/dep-a"))
- .change(QualifiedPackageName("build-against-block/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_build_against_block;
+TEST_F(ResolverCyclesTestCase, BuildAgainstBlock)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("build-against-block/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("build-against-block/dep-b"))
+ .change(QualifiedPackageName("build-against-block/dep-a"))
+ .change(QualifiedPackageName("build-against-block/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_errors.cc b/paludis/resolver/resolver_TEST_errors.cc
index 43a50d1..d4d925a 100644
--- a/paludis/resolver/resolver_TEST_errors.cc
+++ b/paludis/resolver/resolver_TEST_errors.cc
@@ -24,7 +24,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -33,12 +35,12 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
+
#include <paludis/user_dep_spec.hh>
+
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -48,47 +50,45 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverErrorsTestCase : ResolverTestCase
{
- ResolverErrorsTestCase(const std::string & s) :
- ResolverTestCase("errors", s, "exheres-0", "exheres")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
+ {
+ data = std::make_shared<ResolverTestData>("errors", "exheres-0", "exheres");
+ }
+
+ void TearDown()
{
+ data.reset();
}
};
}
-namespace test_cases
+TEST_F(ResolverErrorsTestCase, UnableToDecideThenMore)
{
- struct TestUnableToDecideThenMore : ResolverErrorsTestCase
- {
- TestUnableToDecideThenMore() : ResolverErrorsTestCase("unable to decide then more") { }
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("unable-to-decide-then-more/target"));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("unable-to-decide-then-more/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("unable-to-decide-then-more/pkg-b"))
- .change(QualifiedPackageName("unable-to-decide-then-more/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .unable(QualifiedPackageName("unable-to-decide-then-more/pkg-a"))
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_unable_to_decide_then_more;
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("unable-to-decide-then-more/pkg-b"))
+ .change(QualifiedPackageName("unable-to-decide-then-more/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .unable(QualifiedPackageName("unable-to-decide-then-more/pkg-a"))
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_fetches.cc b/paludis/resolver/resolver_TEST_fetches.cc
index 364015f..cd25443 100644
--- a/paludis/resolver/resolver_TEST_fetches.cc
+++ b/paludis/resolver/resolver_TEST_fetches.cc
@@ -28,7 +28,9 @@
#include <paludis/resolver/job_list.hh>
#include <paludis/resolver/job.hh>
#include <paludis/resolver/job_requirements.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>
@@ -40,12 +42,11 @@
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/join.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -55,15 +56,21 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverFetchTestCase : ResolverTestCase
{
- ResolverFetchTestCase(const std::string & s) :
- ResolverTestCase("fetch", s, "exheres-0", "exheres")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
{
+ data = std::make_shared<ResolverTestData>("fetch", "exheres-0", "exheres");
+ }
+
+ void TearDown()
+ {
+ data.reset();
}
};
@@ -82,55 +89,46 @@ namespace
}
}
-namespace test_cases
+TEST_F(ResolverFetchTestCase, Fetch)
{
- struct TestFetchDeps : ResolverFetchTestCase
- {
- TestFetchDeps() : ResolverFetchTestCase("fetch") { }
-
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("fetch/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("fetch/fetch-dep"))
- .change(QualifiedPackageName("fetch/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
-
- TEST_CHECK_EQUAL(resolved->job_lists()->execute_job_list()->length(), 4);
-
- const FetchJob * const fetch_fetch_dep_job(visitor_cast<const FetchJob>(**resolved->job_lists()->execute_job_list()->fetch(0)));
- TEST_CHECK(fetch_fetch_dep_job);
- TEST_CHECK_EQUAL(join(fetch_fetch_dep_job->requirements()->begin(), fetch_fetch_dep_job->requirements()->end(), ", ", stringify_req),
- "");
-
- const InstallJob * const fetch_dep_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
- TEST_CHECK(fetch_dep_job);
- TEST_CHECK_EQUAL(join(fetch_dep_job->requirements()->begin(), fetch_dep_job->requirements()->end(), ", ", stringify_req),
- "0 satisfied independent always");
-
- const FetchJob * const fetch_target_job(visitor_cast<const FetchJob>(**resolved->job_lists()->execute_job_list()->fetch(2)));
- TEST_CHECK(fetch_target_job);
- TEST_CHECK_EQUAL(join(fetch_target_job->requirements()->begin(), fetch_target_job->requirements()->end(), ", ", stringify_req),
- "1 satisfied, 1 independent");
-
- const InstallJob * const target_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
- TEST_CHECK(target_job);
- TEST_CHECK_EQUAL(join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req),
- "2 satisfied independent always, 1 independent");
- }
- } test_fetch_dep;
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("fetch/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("fetch/fetch-dep"))
+ .change(QualifiedPackageName("fetch/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+
+ EXPECT_EQ(4, resolved->job_lists()->execute_job_list()->length());
+
+ const FetchJob * const fetch_fetch_dep_job(visitor_cast<const FetchJob>(**resolved->job_lists()->execute_job_list()->fetch(0)));
+ ASSERT_TRUE(fetch_fetch_dep_job);
+ EXPECT_EQ("", join(fetch_fetch_dep_job->requirements()->begin(), fetch_fetch_dep_job->requirements()->end(), ", ", stringify_req));
+
+ const InstallJob * const fetch_dep_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(1)));
+ ASSERT_TRUE(fetch_dep_job);
+ EXPECT_EQ("0 satisfied independent always",
+ join(fetch_dep_job->requirements()->begin(), fetch_dep_job->requirements()->end(), ", ", stringify_req));
+
+ const FetchJob * const fetch_target_job(visitor_cast<const FetchJob>(**resolved->job_lists()->execute_job_list()->fetch(2)));
+ ASSERT_TRUE(fetch_target_job);
+ EXPECT_EQ("1 satisfied, 1 independent",
+ join(fetch_target_job->requirements()->begin(), fetch_target_job->requirements()->end(), ", ", stringify_req));
+
+ const InstallJob * const target_job(visitor_cast<const InstallJob>(**resolved->job_lists()->execute_job_list()->fetch(3)));
+ ASSERT_TRUE(target_job);
+ EXPECT_EQ("2 satisfied independent always, 1 independent",
+ join(target_job->requirements()->begin(), target_job->requirements()->end(), ", ", stringify_req));
}
diff --git a/paludis/resolver/resolver_TEST_purges.cc b/paludis/resolver/resolver_TEST_purges.cc
index 071495a..0da210b 100644
--- a/paludis/resolver/resolver_TEST_purges.cc
+++ b/paludis/resolver/resolver_TEST_purges.cc
@@ -26,6 +26,7 @@
#include <paludis/resolver/suggest_restart.hh>
#include <paludis/resolver/make_uninstall_blocker.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>
@@ -35,12 +36,11 @@
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/return_literal_function.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -50,98 +50,86 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverPurgesTestCase : ResolverTestCase
{
- ResolverPurgesTestCase(const std::string & s) :
- ResolverTestCase("purges", s, "exheres-0", "exheres")
- {
- }
- };
-}
+ std::shared_ptr<ResolverTestData> data;
-namespace test_cases
-{
- struct TestPurges : ResolverPurgesTestCase
- {
- TestPurges() :
- ResolverPurgesTestCase("purges")
+ void SetUp()
{
- install("purges", "target", "0")->build_dependencies_key()->set_from_string(
- "purges/still-used-dep purges/old-dep purges/old-dep-locked purges/unrelated-dep");
- install("purges", "old-dep", "0");
- install("purges", "old-dep-locked", "0")->behaviours_set()->insert("used");
- install("purges", "still-used-dep", "0");
- install("purges", "unrelated-dep", "0");
- install("purges", "unrelated", "0")->build_dependencies_key()->set_from_string("purges/unrelated-dep");
-
- get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("purges/old-dep", &env, { }));
-
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_possible);
+ data = std::make_shared<ResolverTestData>("purges", "exheres-0", "exheres");
}
- void run()
+ void TearDown()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("purges/target"));
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("purges/new-dep"))
- .change(QualifiedPackageName("purges/target"))
- .remove(QualifiedPackageName("purges/old-dep"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
}
- } test_purges;
-
- struct TestStarSlotPurges : ResolverPurgesTestCase
- {
- TestStarSlotPurges() :
- ResolverPurgesTestCase("star slot purges")
- {
- install("star-slot-purges", "target", "1")->set_slot(SlotName("1"));
- install("star-slot-purges", "target", "2")->set_slot(SlotName("2"));
-
- install("star-slot-purges", "uses", "1")->build_dependencies_key()->set_from_string("star-slot-purges/target:*");
-
- get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("star-slot-purges/target", &env, { }));
+ };
+}
- get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_possible);
- }
+TEST_F(ResolverPurgesTestCase, Purges)
+{
+ data->install("purges", "target", "0")->build_dependencies_key()->set_from_string(
+ "purges/still-used-dep purges/old-dep purges/old-dep-locked purges/unrelated-dep");
+ data->install("purges", "old-dep", "0");
+ data->install("purges", "old-dep-locked", "0")->behaviours_set()->insert("used");
+ data->install("purges", "still-used-dep", "0");
+ data->install("purges", "unrelated-dep", "0");
+ data->install("purges", "unrelated", "0")->build_dependencies_key()->set_from_string("purges/unrelated-dep");
+
+ data->get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("purges/old-dep", &data->env, { }));
+
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_possible);
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("purges/target"));
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("purges/new-dep"))
+ .change(QualifiedPackageName("purges/target"))
+ .remove(QualifiedPackageName("purges/old-dep"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved(make_uninstall_blocker(
- parse_user_package_dep_spec("star-slot-purges/target:1", &env, { }))));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .remove(QualifiedPackageName("star-slot-purges/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_star_slot_purges;
+TEST_F(ResolverPurgesTestCase, StarSlotPurges)
+{
+ data->install("star-slot-purges", "target", "1")->set_slot(SlotName("1"));
+ data->install("star-slot-purges", "target", "2")->set_slot(SlotName("2"));
+
+ data->install("star-slot-purges", "uses", "1")->build_dependencies_key()->set_from_string("star-slot-purges/target:*");
+
+ data->get_constraints_for_purge_helper.add_purge_spec(parse_user_package_dep_spec("star-slot-purges/target", &data->env, { }));
+
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_if_possible);
+
+ std::shared_ptr<const Resolved> resolved(data->get_resolved(make_uninstall_blocker(
+ parse_user_package_dep_spec("star-slot-purges/target:1", &data->env, { }))));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .remove(QualifiedPackageName("star-slot-purges/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_serialisation.cc b/paludis/resolver/resolver_TEST_serialisation.cc
index 0962f6e..fc1b687 100644
--- a/paludis/resolver/resolver_TEST_serialisation.cc
+++ b/paludis/resolver/resolver_TEST_serialisation.cc
@@ -24,7 +24,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -34,13 +36,12 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/string_list_stream.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/serialise.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -50,59 +51,57 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverSerialisationTestCase : ResolverTestCase
{
- ResolverSerialisationTestCase(const std::string & s) :
- ResolverTestCase("serialisation", s, "exheres-0", "exheres")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
+ {
+ data = std::make_shared<ResolverTestData>("serialisation", "exheres-0", "exheres");
+ }
+
+ void TearDown()
{
+ data.reset();
}
};
}
-namespace test_cases
+TEST_F(ResolverSerialisationTestCase, Serialisation)
{
- struct TestSerialisation : ResolverSerialisationTestCase
+ std::shared_ptr<const Resolved> resolved;
{
- TestSerialisation() : ResolverSerialisationTestCase("serialisation") { }
+ std::shared_ptr<const Resolved> orig_resolved(data->get_resolved("serialisation/target"));
+ StringListStream str;
+ Serialiser ser(str);
+ orig_resolved->serialise(ser);
+ str.nothing_more_to_write();
- void run()
- {
- std::shared_ptr<const Resolved> resolved;
- {
- std::shared_ptr<const Resolved> orig_resolved(get_resolved("serialisation/target"));
- StringListStream str;
- Serialiser ser(str);
- orig_resolved->serialise(ser);
- str.nothing_more_to_write();
+ Deserialiser deser(&data->env, str);
+ Deserialisation desern("ResolverLists", deser);
+ resolved = std::make_shared<Resolved>(Resolved::deserialise(desern));
+ }
- Deserialiser deser(&env, str);
- Deserialisation desern("ResolverLists", deser);
- resolved = std::make_shared<Resolved>(Resolved::deserialise(desern));
- }
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("serialisation/dep"))
- .change(QualifiedPackageName("serialisation/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .unable(QualifiedPackageName("serialisation/error"))
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("serialisation/suggestion"))
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_serialisation;
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("serialisation/dep"))
+ .change(QualifiedPackageName("serialisation/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .unable(QualifiedPackageName("serialisation/error"))
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("serialisation/suggestion"))
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_simple.cc b/paludis/resolver/resolver_TEST_simple.cc
index 1a09da7..4bd2328 100644
--- a/paludis/resolver/resolver_TEST_simple.cc
+++ b/paludis/resolver/resolver_TEST_simple.cc
@@ -24,7 +24,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -33,11 +35,11 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
+
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -47,131 +49,114 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverSimpleTestCase : ResolverTestCase
{
- ResolverSimpleTestCase(const std::string & s) :
- ResolverTestCase("simple", s, "exheres-0", "exheres")
- {
- }
- };
-}
-
-namespace test_cases
-{
- struct TestNoDeps : ResolverSimpleTestCase
- {
- TestNoDeps() : ResolverSimpleTestCase("no-deps") { }
+ std::shared_ptr<ResolverTestData> data;
- void run()
+ void SetUp()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("no-deps/target"));
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("no-deps/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
+ data = std::make_shared<ResolverTestData>("simple", "exheres-0", "exheres");
}
- } test_no_deps;
- struct TestBuildDeps : ResolverSimpleTestCase
- {
- TestBuildDeps() : ResolverSimpleTestCase("build-deps") { }
-
- void run()
+ void TearDown()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("build-deps/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("build-deps/a-dep"))
- .change(QualifiedPackageName("build-deps/b-dep"))
- .change(QualifiedPackageName("build-deps/z-dep"))
- .change(QualifiedPackageName("build-deps/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
+ data.reset();
}
- } test_build_deps;
+ };
+}
- struct TestRunDeps : ResolverSimpleTestCase
- {
- TestRunDeps() : ResolverSimpleTestCase("run-deps") { }
+TEST_F(ResolverSimpleTestCase, NoDeps)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("no-deps/target"));
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("no-deps/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("run-deps/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("run-deps/a-dep"))
- .change(QualifiedPackageName("run-deps/b-dep"))
- .change(QualifiedPackageName("run-deps/z-dep"))
- .change(QualifiedPackageName("run-deps/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_run_deps;
+TEST_F(ResolverSimpleTestCase, BuildDeps)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("build-deps/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("build-deps/a-dep"))
+ .change(QualifiedPackageName("build-deps/b-dep"))
+ .change(QualifiedPackageName("build-deps/z-dep"))
+ .change(QualifiedPackageName("build-deps/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct TestPostDeps : ResolverSimpleTestCase
- {
- TestPostDeps() : ResolverSimpleTestCase("post-deps") { }
+TEST_F(ResolverSimpleTestCase, RunDeps)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("run-deps/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("run-deps/a-dep"))
+ .change(QualifiedPackageName("run-deps/b-dep"))
+ .change(QualifiedPackageName("run-deps/z-dep"))
+ .change(QualifiedPackageName("run-deps/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("post-deps/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("post-deps/a-dep"))
- .change(QualifiedPackageName("post-deps/b-dep"))
- .change(QualifiedPackageName("post-deps/target"))
- .change(QualifiedPackageName("post-deps/z-dep"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_post_deps;
+TEST_F(ResolverSimpleTestCase, PostDeps)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("post-deps/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("post-deps/a-dep"))
+ .change(QualifiedPackageName("post-deps/b-dep"))
+ .change(QualifiedPackageName("post-deps/target"))
+ .change(QualifiedPackageName("post-deps/z-dep"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_suggestions.cc b/paludis/resolver/resolver_TEST_suggestions.cc
index 8fadb85..9578acb 100644
--- a/paludis/resolver/resolver_TEST_suggestions.cc
+++ b/paludis/resolver/resolver_TEST_suggestions.cc
@@ -24,7 +24,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -33,12 +35,11 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -48,101 +49,89 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverSuggestionsTestCase : ResolverTestCase
{
- ResolverSuggestionsTestCase(const std::string & s) :
- ResolverTestCase("suggestions", s, "exheres-0", "exheres")
- {
- }
- };
-}
-
-namespace test_cases
-{
- struct TestSuggestion : ResolverSuggestionsTestCase
- {
- TestSuggestion() : ResolverSuggestionsTestCase("suggestion") { }
+ std::shared_ptr<ResolverTestData> data;
- void run()
+ void SetUp()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("suggestion/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("suggestion/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("suggestion/dep"))
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
+ data = std::make_shared<ResolverTestData>("suggestions", "exheres-0", "exheres");
}
- } test_suggestion;
-
- struct TestUnmeetableSuggestion : ResolverSuggestionsTestCase
- {
- TestUnmeetableSuggestion() : ResolverSuggestionsTestCase("unmeetable suggestion") { }
- void run()
+ void TearDown()
{
- std::shared_ptr<const Resolved> resolved(get_resolved("unmeetable-suggestion/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("unmeetable-suggestion/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .unable(QualifiedPackageName("unmeetable-suggestion/unmeetable-dep"))
- .finished())
- );
+ data.reset();
}
- } test_unmeetable_suggestion;
+ };
+}
- struct TestSuggestionThenDependency : ResolverSuggestionsTestCase
- {
- TestSuggestionThenDependency() : ResolverSuggestionsTestCase("suggestion then dependency") { }
+TEST_F(ResolverSuggestionsTestCase, Suggestion)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("suggestion/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("suggestion/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("suggestion/dep"))
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("suggestion-then-dependency/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("suggestion-then-dependency/a-suggested-dep"))
- .change(QualifiedPackageName("suggestion-then-dependency/hard-dep"))
- .change(QualifiedPackageName("suggestion-then-dependency/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_suggestion_then_dependency;
+TEST_F(ResolverSuggestionsTestCase, Unmeetable)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("unmeetable-suggestion/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("unmeetable-suggestion/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .unable(QualifiedPackageName("unmeetable-suggestion/unmeetable-dep"))
+ .finished())
+ );
+}
+
+TEST_F(ResolverSuggestionsTestCase, SuggestionThenDependency)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("suggestion-then-dependency/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("suggestion-then-dependency/a-suggested-dep"))
+ .change(QualifiedPackageName("suggestion-then-dependency/hard-dep"))
+ .change(QualifiedPackageName("suggestion-then-dependency/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_TEST_uninstalls.cc b/paludis/resolver/resolver_TEST_uninstalls.cc
index 37da841..e4aea10 100644
--- a/paludis/resolver/resolver_TEST_uninstalls.cc
+++ b/paludis/resolver/resolver_TEST_uninstalls.cc
@@ -26,7 +26,9 @@
#include <paludis/resolver/suggest_restart.hh>
#include <paludis/resolver/required_confirmations.hh>
#include <paludis/resolver/make_uninstall_blocker.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>
@@ -37,12 +39,11 @@
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/return_literal_function.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -52,51 +53,50 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverUninstallsTestCase : ResolverTestCase
{
- ResolverUninstallsTestCase(const std::string & s) :
- ResolverTestCase("uninstalls", s, "exheres-0", "exheres")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
+ {
+ data = std::make_shared<ResolverTestData>("uninstalls", "exheres-0", "exheres");
+ }
+
+ void TearDown()
{
+ data.reset();
}
};
}
-namespace test_cases
+namespace
{
- struct TestUninstallBreaking : ResolverUninstallsTestCase
+ template <bool allowed_to_remove_, bool confirm_>
+ struct TestUninstallBreaking :
+ ResolverUninstallsTestCase
{
- const bool allowed_to_remove;
- const bool confirm;
-
- TestUninstallBreaking(const bool ar, const bool c) :
- ResolverUninstallsTestCase("uninstall breaking " + stringify(ar) + " " + stringify(c)),
- allowed_to_remove(ar),
- confirm(c)
+ void common_test_code()
{
- install("breaking", "dep", "1")->run_dependencies_key()->set_from_string("breaking/target");
- install("breaking", "target", "1");
+ data->install("breaking", "dep", "1")->run_dependencies_key()->set_from_string("breaking/target");
+ data->install("breaking", "target", "1");
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("breaking/target", &env, { }));
- if (allowed_to_remove)
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("breaking/target", &data->env, UserPackageDepSpecOptions()));
+ if (allowed_to_remove_)
{
- remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec("breaking/dep", &env, { }));
- allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("breaking/dep", &env, { }));
+ data->remove_if_dependent_helper.add_remove_if_dependent_spec(parse_user_package_dep_spec("breaking/dep", &data->env, UserPackageDepSpecOptions()));
+ data->allowed_to_remove_helper.add_allowed_to_remove_spec(parse_user_package_dep_spec("breaking/dep", &data->env, UserPackageDepSpecOptions()));
}
- if (confirm)
- confirm_helper.add_allowed_to_break_spec(parse_user_package_dep_spec("*/*", &env, { updso_allow_wildcards }));
- }
+ if (confirm_)
+ data->confirm_helper.add_allowed_to_break_spec(parse_user_package_dep_spec("*/*", &data->env, UserPackageDepSpecOptions() + updso_allow_wildcards));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved(make_uninstall_blocker(
- parse_user_package_dep_spec("breaking/target", &env, { }))));
+ std::shared_ptr<const Resolved> resolved(data->get_resolved(make_uninstall_blocker(
+ parse_user_package_dep_spec("breaking/target", &data->env, UserPackageDepSpecOptions()))));
- if (allowed_to_remove)
+ if (allowed_to_remove_)
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
.remove(QualifiedPackageName("breaking/dep"))
@@ -113,7 +113,7 @@ namespace test_cases
n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
.finished())
);
- else if (confirm)
+ else if (confirm_)
check_resolved(resolved,
n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
.remove(QualifiedPackageName("breaking/target"))
@@ -147,9 +147,16 @@ namespace test_cases
.finished())
);
}
- } test_uninstall_breaking_f_f(false, false),
- test_uninstall_breaking_f_t(false, true),
- test_uninstall_breaking_t_f(true, false),
- test_uninstall_breaking_t_t(true, true);
+ };
}
+typedef TestUninstallBreaking<false, false> UninstallBreakingFF;
+typedef TestUninstallBreaking<false, true> UninstallBreakingFT;
+typedef TestUninstallBreaking<true, false> UninstallBreakingTF;
+typedef TestUninstallBreaking<true, true> UninstallBreakingTT;
+
+TEST_F(UninstallBreakingFF, Works) { common_test_code(); }
+TEST_F(UninstallBreakingFT, Works) { common_test_code(); }
+TEST_F(UninstallBreakingTF, Works) { common_test_code(); }
+TEST_F(UninstallBreakingTT, Works) { common_test_code(); }
+
diff --git a/paludis/resolver/resolver_TEST_virtuals.cc b/paludis/resolver/resolver_TEST_virtuals.cc
index 18cf869..5bbc7dc 100644
--- a/paludis/resolver/resolver_TEST_virtuals.cc
+++ b/paludis/resolver/resolver_TEST_virtuals.cc
@@ -24,7 +24,9 @@
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/suggest_restart.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>
@@ -33,12 +35,11 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/make_shared_copy.hh>
+
#include <paludis/user_dep_spec.hh>
#include <paludis/repository_factory.hh>
#include <paludis/resolver/resolver_test.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
#include <list>
#include <functional>
@@ -48,72 +49,65 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
namespace
{
struct ResolverVirtualsTestCase : ResolverTestCase
{
- ResolverVirtualsTestCase(const std::string & s) :
- ResolverTestCase("virtuals", s, "0", "traditional")
+ std::shared_ptr<ResolverTestData> data;
+
+ void SetUp()
{
+ data = std::make_shared<ResolverTestData>("virtuals", "0", "traditional");
+ }
+
+ void TearDown()
+ {
+ data.reset();
}
};
}
-namespace test_cases
+TEST_F(ResolverVirtualsTestCase, Virtuals)
{
- struct TestVirtuals : ResolverVirtualsTestCase
- {
- TestVirtuals() : ResolverVirtualsTestCase("virtuals") { }
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("virtuals/target"));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("virtuals/target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("cat/foo-a"))
- .change(QualifiedPackageName("virtuals/target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_virtuals;
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("cat/foo-a"))
+ .change(QualifiedPackageName("virtuals/target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
+}
- struct TestVirtualsTarget : ResolverVirtualsTestCase
- {
- TestVirtualsTarget() : ResolverVirtualsTestCase("virtuals target") { }
+TEST_F(ResolverVirtualsTestCase, VirtualsTarget)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("virtual/virtual-target"));
- void run()
- {
- std::shared_ptr<const Resolved> resolved(get_resolved("virtual/virtual-target"));
-
- check_resolved(resolved,
- n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .change(QualifiedPackageName("cat/real-target"))
- .finished()),
- n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
- .finished()),
- n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
- .finished())
- );
- }
- } test_virtuals_target;
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("cat/real-target"))
+ .finished()),
+ n::taken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unconfirmed_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::taken_unorderable_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .finished()),
+ n::untaken_unable_to_make_decisions() = make_shared_copy(DecisionChecks()
+ .finished())
+ );
}
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index d0a9a56..284ac1d 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -30,6 +30,7 @@
#include <paludis/resolver/reason.hh>
#include <paludis/resolver/change_by_resolvent.hh>
#include <paludis/resolver/labels_classifier.hh>
+
#include <paludis/util/map.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/accept_visitor.hh>
@@ -39,7 +40,12 @@
#include <paludis/util/tribool.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/join.hh>
-#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/map-impl.hh>
+#include <paludis/util/sequence-impl.hh>
+
#include <paludis/repository_factory.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/filter.hh>
@@ -49,10 +55,7 @@
#include <paludis/elike_slot_requirement.hh>
#include <paludis/partially_made_package_dep_spec.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/indirect_iterator-impl.hh>
-#include <paludis/util/map-impl.hh>
-#include <paludis/util/sequence-impl.hh>
+#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <algorithm>
#include "config.h"
@@ -60,7 +63,6 @@
using namespace paludis;
using namespace paludis::resolver;
using namespace paludis::resolver::resolver_test;
-using namespace test;
std::string
paludis::resolver::resolver_test::from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m,
@@ -98,9 +100,7 @@ namespace
#endif
}
-ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s, const std::string & e,
- const std::string & l) :
- TestCase(s),
+ResolverTestData::ResolverTestData(const std::string & t, const std::string & e, const std::string & l) :
allow_choice_changes_helper(&env),
allowed_to_remove_helper(&env),
allowed_to_restart_helper(&env),
@@ -171,7 +171,7 @@ ResolverTestCase::ResolverTestCase(const std::string & t, const std::string & s,
}
ResolverFunctions
-ResolverTestCase::get_resolver_functions()
+ResolverTestData::get_resolver_functions()
{
return make_named_values<ResolverFunctions>(
n::allow_choice_changes_fn() = std::cref(allow_choice_changes_helper),
@@ -201,7 +201,7 @@ ResolverTestCase::get_resolver_functions()
}
const std::shared_ptr<const Resolved>
-ResolverTestCase::get_resolved(const PackageOrBlockDepSpec & target)
+ResolverTestData::get_resolved(const PackageOrBlockDepSpec & target)
{
while (true)
{
@@ -220,7 +220,7 @@ ResolverTestCase::get_resolved(const PackageOrBlockDepSpec & target)
}
const std::shared_ptr<const Resolved>
-ResolverTestCase::get_resolved(const std::string & target)
+ResolverTestData::get_resolved(const std::string & target)
{
PackageDepSpec target_spec(parse_user_package_dep_spec(target, &env, { }));
return get_resolved(target_spec);
@@ -259,12 +259,12 @@ ResolverTestCase::check_resolved_one(
if (decision != decision_end)
d = get_decision(*decision++);
- TEST_CHECK_MESSAGE(decision_check->first(d), decision_check->second(d));
+ EXPECT_TRUE(decision_check->first(d)) << decision_check->second(d);
++decision_check;
}
- TEST_CHECK(decision_check == decision_check_end);
- TEST_CHECK(decision == decision_end);
+ ASSERT_TRUE(decision_check == decision_check_end);
+ ASSERT_TRUE(decision == decision_end);
}
void
@@ -278,35 +278,12 @@ ResolverTestCase::check_resolved(
const NamedValue<n::untaken_unable_to_make_decisions, const std::shared_ptr<const DecisionChecks> > & untaken_unable_to_make_decisions
)
{
- {
- TestMessageSuffix s("taken change or remove");
- check_resolved_one(resolved->taken_change_or_remove_decisions(), taken_change_or_remove_decisions());
- }
-
- {
- TestMessageSuffix s("taken unable to make");
- check_resolved_one(resolved->taken_unable_to_make_decisions(), taken_unable_to_make_decisions());
- }
-
- {
- TestMessageSuffix s("taken unconfirmed");
- check_resolved_one(resolved->taken_unconfirmed_decisions(), taken_unconfirmed_decisions());
- }
-
- {
- TestMessageSuffix s("taken unorderable");
- check_resolved_one(resolved->taken_unorderable_decisions(), taken_unorderable_decisions());
- }
-
- {
- TestMessageSuffix s("untaken change or remove");
- check_resolved_one(resolved->untaken_change_or_remove_decisions(), untaken_change_or_remove_decisions());
- }
-
- {
- TestMessageSuffix s("untaken unable to make");
- check_resolved_one(resolved->untaken_unable_to_make_decisions(), untaken_unable_to_make_decisions());
- }
+ check_resolved_one(resolved->taken_change_or_remove_decisions(), taken_change_or_remove_decisions());
+ check_resolved_one(resolved->taken_unable_to_make_decisions(), taken_unable_to_make_decisions());
+ check_resolved_one(resolved->taken_unconfirmed_decisions(), taken_unconfirmed_decisions());
+ check_resolved_one(resolved->taken_unorderable_decisions(), taken_unorderable_decisions());
+ check_resolved_one(resolved->untaken_change_or_remove_decisions(), untaken_change_or_remove_decisions());
+ check_resolved_one(resolved->untaken_unable_to_make_decisions(), untaken_unable_to_make_decisions());
}
ResolverTestCase::DecisionChecks &
@@ -503,7 +480,7 @@ ResolverTestCase::DecisionChecks::check_generic_msg(const std::string & q, const
}
const std::shared_ptr<FakePackageID>
-ResolverTestCase::install(const std::string & c, const std::string & p, const std::string & v)
+ResolverTestData::install(const std::string & c, const std::string & p, const std::string & v)
{
return fake_inst_repo->add_version(c, p, v);
}
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index 8fc380d..8b0d0e1 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -70,13 +70,13 @@
#include <paludis/filtered_generator-fwd.hh>
#include <paludis/generator-fwd.hh>
-#include <test/test_framework.hh>
-
#include <memory>
#include <string>
#include <map>
#include <list>
+#include <gtest/gtest.h>
+
namespace paludis
{
namespace resolver
@@ -86,7 +86,7 @@ namespace paludis
std::string from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m,
const std::string & k);
- struct ResolverTestCase : test::TestCase
+ struct ResolverTestData
{
TestEnvironment env;
std::shared_ptr<Repository> repo, inst_repo;
@@ -116,14 +116,21 @@ namespace paludis
PreferOrAvoidHelper prefer_or_avoid_helper;
RemoveIfDependentHelper remove_if_dependent_helper;
- ResolverTestCase(const std::string & group, const std::string & test_name, const std::string & eapi,
- const std::string & layout);
+ ResolverTestData(const std::string & group, const std::string & eapi, const std::string & layout);
+
+ ResolverFunctions get_resolver_functions();
const std::shared_ptr<const Resolved> get_resolved(const PackageOrBlockDepSpec & target);
+
const std::shared_ptr<const Resolved> get_resolved(const std::string & target);
- virtual ResolverFunctions get_resolver_functions();
+ const std::shared_ptr<FakePackageID> install(
+ const std::string & c, const std::string & p, const std::string & v);
+ };
+ struct ResolverTestCase :
+ testing::Test
+ {
struct DecisionChecks
{
typedef std::function<bool (const std::shared_ptr<const Decision> &) > CheckFunction;
@@ -173,9 +180,6 @@ namespace paludis
const NamedValue<n::untaken_change_or_remove_decisions, const std::shared_ptr<const DecisionChecks> > &,
const NamedValue<n::untaken_unable_to_make_decisions, const std::shared_ptr<const DecisionChecks> > &
);
-
- const std::shared_ptr<FakePackageID> install(
- const std::string & c, const std::string & p, const std::string & v);
};
}
}