aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-03 22:21:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-03 22:21:20 +0100
commitb57878f111aa8000e9a3400494025d5e47b44f9d (patch)
tree5d21f06189780efeeae54199197756f1eecbf1af
parentf568e5a5c47db29bd6f1eb0072e279530be1e146 (diff)
downloadpaludis-b57878f111aa8000e9a3400494025d5e47b44f9d.tar.gz
paludis-b57878f111aa8000e9a3400494025d5e47b44f9d.tar.xz
Test binaries
-rw-r--r--.gitignore1
-rw-r--r--paludis/resolver/Makefile.am20
-rw-r--r--paludis/resolver/resolver_TEST_binaries.cc96
-rwxr-xr-xpaludis/resolver/resolver_TEST_binaries_cleanup.sh9
-rwxr-xr-xpaludis/resolver/resolver_TEST_binaries_setup.sh45
-rw-r--r--paludis/resolver/resolver_test.cc21
-rw-r--r--paludis/resolver/resolver_test.hh8
7 files changed, 198 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 44081ed..47f6365 100644
--- a/.gitignore
+++ b/.gitignore
@@ -348,6 +348,7 @@ paludis-*.*.*.tar.bz2
/paludis/repositories/unwritten/unwritten_repository_TEST
/paludis/repository_name_cache_TEST
/paludis/resolver/resolver_TEST_any
+/paludis/resolver/resolver_TEST_binaries
/paludis/resolver/resolver_TEST_blockers
/paludis/resolver/resolver_TEST_continue_on_failure
/paludis/resolver/resolver_TEST_cycles
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 1e7e144..1208db1 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -189,7 +189,8 @@ TESTS = \
resolver_TEST_continue_on_failure \
resolver_TEST_uninstalls \
resolver_TEST_fetches \
- resolver_TEST_purges
+ resolver_TEST_purges \
+ resolver_TEST_binaries
check_PROGRAMS = $(TESTS)
@@ -204,7 +205,8 @@ check_SCRIPTS = \
resolver_TEST_continue_on_failure_setup.sh resolver_TEST_continue_on_failure_cleanup.sh \
resolver_TEST_uninstalls_setup.sh resolver_TEST_uninstalls_cleanup.sh \
resolver_TEST_fetches_setup.sh resolver_TEST_fetches_cleanup.sh \
- resolver_TEST_purges_setup.sh resolver_TEST_purges_cleanup.sh
+ resolver_TEST_purges_setup.sh resolver_TEST_purges_cleanup.sh \
+ resolver_TEST_binaries_setup.sh resolver_TEST_binaries_cleanup.sh
check_LIBRARIES = libpaludisresolvertest.a
@@ -366,6 +368,20 @@ resolver_TEST_purges_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @
resolver_TEST_purges_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+resolver_TEST_binaries_SOURCES = resolver_TEST_binaries.cc
+
+resolver_TEST_binaries_LDADD = \
+ libpaludisresolvertest.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_binaries_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@
+
+resolver_TEST_binaries_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_binaries.cc b/paludis/resolver/resolver_TEST_binaries.cc
new file mode 100644
index 0000000..c402692
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_binaries.cc
@@ -0,0 +1,96 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/resolver/resolver.hh>
+#include <paludis/resolver/resolver_functions.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/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>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/accept_visitor.hh>
+#include <paludis/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 <list>
+#include <functional>
+#include <algorithm>
+#include <map>
+
+using namespace paludis;
+using namespace paludis::resolver;
+using namespace paludis::resolver::resolver_test;
+
+namespace
+{
+ struct ResolverBinariesTestCase : ResolverTestCase
+ {
+ std::shared_ptr<ResolverWithBinaryTestData> data;
+
+ void SetUp()
+ {
+ data = std::make_shared<ResolverWithBinaryTestData>("binaries", "exheres-0", "exheres");
+ data->get_use_existing_nothing_helper.set_use_existing_for_dependencies(ue_never);
+ data->get_resolvents_for_helper.set_target_destination_type(dt_create_binary);
+ }
+
+ void TearDown()
+ {
+ data.reset();
+ }
+ };
+}
+
+TEST_F(ResolverBinariesTestCase, SelfRunBinary)
+{
+ std::shared_ptr<const Resolved> resolved(data->get_resolved("self-run-binary/target"));
+
+ check_resolved(resolved,
+ n::taken_change_or_remove_decisions() = make_shared_copy(DecisionChecks()
+ .change(QualifiedPackageName("self-run-binary/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("self-run-binary/dep"))
+ .change(QualifiedPackageName("self-run-binary/dep"))
+ .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_binaries_cleanup.sh b/paludis/resolver/resolver_TEST_binaries_cleanup.sh
new file mode 100755
index 0000000..b783e9e
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_binaries_cleanup.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d resolver_TEST_binaries_dir ] ; then
+ rm -fr resolver_TEST_binaries_dir
+else
+ true
+fi
+
diff --git a/paludis/resolver/resolver_TEST_binaries_setup.sh b/paludis/resolver/resolver_TEST_binaries_setup.sh
new file mode 100755
index 0000000..017ca1e
--- /dev/null
+++ b/paludis/resolver/resolver_TEST_binaries_setup.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir resolver_TEST_binaries_dir || exit 1
+cd resolver_TEST_binaries_dir || exit 1
+
+mkdir -p build
+mkdir -p distdir
+mkdir -p installed
+
+mkdir -p binrepo/{profiles/profile,metadata}
+
+cd binrepo
+echo "binrepo" > profiles/repo_name
+: > metadata/categories.conf
+
+cd ..
+
+mkdir -p repo/{profiles/profile,metadata}
+
+cd repo
+echo "repo" > profiles/repo_name
+: > metadata/categories.conf
+
+# self-run-binary
+echo 'self-run-binary' >> metadata/categories.conf
+
+mkdir -p 'packages/self-run-binary/target'
+cat <<END > packages/self-run-binary/target/target-1.exheres-0
+SUMMARY="target"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="build+run: self-run-binary/dep"
+END
+
+mkdir -p 'packages/self-run-binary/dep'
+cat <<END > packages/self-run-binary/dep/dep-1.exheres-0
+SUMMARY="dep"
+PLATFORMS="test"
+SLOT="0"
+DEPENDENCIES="run: self-run-binary/dep"
+END
+
+cd ..
+
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 81151a1..11cdc46 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -140,6 +140,27 @@ ResolverTestData::ResolverTestData(const std::string & t, const std::string & e,
make_unmaskable_filter_helper.set_override_masks(false);
}
+ResolverWithBinaryTestData::ResolverWithBinaryTestData(const std::string & t, const std::string & e, const std::string & l) :
+ ResolverTestData(t, e, l)
+{
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / ("resolver_TEST_" + t + "_dir") / "binrepo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / ("resolver_TEST_" + t + "_dir") / "repo/profiles/profile"));
+ keys->insert("layout", l);
+ keys->insert("eapi_when_unknown", e);
+ keys->insert("eapi_when_unspecified", e);
+ keys->insert("profile_eapi", e);
+ keys->insert("binary_destination", "true");
+ keys->insert("binary_keywords_filter", "test ~test");
+ keys->insert("distdir", stringify(FSPath::cwd() / ("resolver_TEST_" + t + "_dir") / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / ("resolver_TEST_" + t + "_dir") / "build"));
+ bin_repo = RepositoryFactory::get_instance()->create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1));
+ env.add_repository(2, bin_repo);
+}
+
ResolverFunctions
ResolverTestData::get_resolver_functions()
{
diff --git a/paludis/resolver/resolver_test.hh b/paludis/resolver/resolver_test.hh
index fae6b67..766eb44 100644
--- a/paludis/resolver/resolver_test.hh
+++ b/paludis/resolver/resolver_test.hh
@@ -130,6 +130,14 @@ namespace paludis
const std::string & c, const std::string & p, const std::string & v);
};
+ struct ResolverWithBinaryTestData :
+ ResolverTestData
+ {
+ std::shared_ptr<Repository> bin_repo;
+
+ ResolverWithBinaryTestData(const std::string & group, const std::string & eapi, const std::string & layout);
+ };
+
struct ResolverTestCase :
testing::Test
{