diff options
author | 2012-05-06 22:10:56 +0100 | |
---|---|---|
committer | 2012-05-12 11:33:35 +0100 | |
commit | a7865e3c6ae5e21e474a47ffa87be6e7ef3e7667 (patch) | |
tree | 6eed5a2554863ca688949982cf08f378675529c0 | |
parent | 57208caa313878d8128d4c723a675d2c7553757f (diff) | |
download | paludis-a7865e3c6ae5e21e474a47ffa87be6e7ef3e7667.tar.gz paludis-a7865e3c6ae5e21e474a47ffa87be6e7ef3e7667.tar.xz |
EAPI 5 has ?? ( ) in REQUIRED_USE
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | paludis/repositories/e/Makefile.am | 49 | ||||
-rw-r--r-- | paludis/repositories/e/dep_parser.cc | 5 | ||||
-rw-r--r-- | paludis/repositories/e/dep_parser.se | 1 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository_TEST_5.cc | 169 | ||||
-rwxr-xr-x | paludis/repositories/e/e_repository_TEST_5_cleanup.sh | 9 | ||||
-rwxr-xr-x | paludis/repositories/e/e_repository_TEST_5_setup.sh | 79 | ||||
-rw-r--r-- | paludis/repositories/e/eapis/5.conf | 1 |
8 files changed, 297 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore index f17dfc9c1..8b816aaf4 100644 --- a/.gitignore +++ b/.gitignore @@ -272,6 +272,7 @@ paludis-*.*.*.tar.bz2 /paludis/repositories/e/e_repository_TEST_2 /paludis/repositories/e/e_repository_TEST_3 /paludis/repositories/e/e_repository_TEST_4 +/paludis/repositories/e/e_repository_TEST_5 /paludis/repositories/e/e_repository_TEST_dependencies_rewriter /paludis/repositories/e/e_repository_TEST_ever /paludis/repositories/e/e_repository_TEST_exheres_0 diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index c3ecc8599..9ffaa8760 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -235,29 +235,29 @@ e_repository_TEST_exheres_0_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_C e_repository_TEST_exheres_0_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ -e_repository_TEST_3_SOURCES = e_repository_TEST_3.cc +e_repository_TEST_0_SOURCES = e_repository_TEST_0.cc -e_repository_TEST_3_LDADD = \ +e_repository_TEST_0_LDADD = \ $(top_builddir)/paludis/util/gtest_runner.o \ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ $(DYNAMIC_LD_LIBS) -e_repository_TEST_3_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ +e_repository_TEST_0_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ -e_repository_TEST_3_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ +e_repository_TEST_0_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ -e_repository_TEST_4_SOURCES = e_repository_TEST_4.cc +e_repository_TEST_1_SOURCES = e_repository_TEST_1.cc -e_repository_TEST_4_LDADD = \ +e_repository_TEST_1_LDADD = \ $(top_builddir)/paludis/util/gtest_runner.o \ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ $(DYNAMIC_LD_LIBS) -e_repository_TEST_4_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ +e_repository_TEST_1_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ -e_repository_TEST_4_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ +e_repository_TEST_1_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ e_repository_TEST_2_SOURCES = e_repository_TEST_2.cc @@ -271,29 +271,41 @@ e_repository_TEST_2_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_ e_repository_TEST_2_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ -e_repository_TEST_1_SOURCES = e_repository_TEST_1.cc +e_repository_TEST_3_SOURCES = e_repository_TEST_3.cc -e_repository_TEST_1_LDADD = \ +e_repository_TEST_3_LDADD = \ $(top_builddir)/paludis/util/gtest_runner.o \ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ $(DYNAMIC_LD_LIBS) -e_repository_TEST_1_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ +e_repository_TEST_3_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ -e_repository_TEST_1_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ +e_repository_TEST_3_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ -e_repository_TEST_0_SOURCES = e_repository_TEST_0.cc +e_repository_TEST_4_SOURCES = e_repository_TEST_4.cc -e_repository_TEST_0_LDADD = \ +e_repository_TEST_4_LDADD = \ $(top_builddir)/paludis/util/gtest_runner.o \ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ $(DYNAMIC_LD_LIBS) -e_repository_TEST_0_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ +e_repository_TEST_4_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ -e_repository_TEST_0_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ +e_repository_TEST_4_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ + +e_repository_TEST_5_SOURCES = e_repository_TEST_5.cc + +e_repository_TEST_5_LDADD = \ + $(top_builddir)/paludis/util/gtest_runner.o \ + $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ + $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ + $(DYNAMIC_LD_LIBS) + +e_repository_TEST_5_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@ + +e_repository_TEST_5_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ e_repository_TEST_phases_SOURCES = e_repository_TEST_phases.cc @@ -532,6 +544,9 @@ EXTRA_DIST = \ e_repository_TEST_4.cc \ e_repository_TEST_4_setup.sh \ e_repository_TEST_4_cleanup.sh \ + e_repository_TEST_5.cc \ + e_repository_TEST_5_setup.sh \ + e_repository_TEST_5_cleanup.sh \ e_repository_TEST_pbin.cc \ e_repository_TEST_pbin_setup.sh \ e_repository_TEST_pbin_cleanup.sh \ @@ -604,6 +619,7 @@ check_SCRIPTS = \ e_repository_TEST_2_setup.sh e_repository_TEST_2_cleanup.sh \ e_repository_TEST_3_setup.sh e_repository_TEST_3_cleanup.sh \ e_repository_TEST_4_setup.sh e_repository_TEST_4_cleanup.sh \ + e_repository_TEST_5_setup.sh e_repository_TEST_5_cleanup.sh \ e_repository_TEST_pbin_setup.sh e_repository_TEST_pbin_cleanup.sh \ e_repository_TEST_phases_setup.sh e_repository_TEST_phases_cleanup.sh \ e_repository_TEST_exlibs_setup.sh e_repository_TEST_exlibs_cleanup.sh \ @@ -692,6 +708,7 @@ TESTS = \ e_repository_TEST_2 \ e_repository_TEST_3 \ e_repository_TEST_4 \ + e_repository_TEST_5 \ e_repository_TEST_ever \ e_repository_TEST_exheres_0 \ e_repository_TEST_exlibs \ diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index 0cd6c8570..2688821df 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -871,7 +871,10 @@ paludis::erepository::parse_required_use(const std::string & s, const Environmen n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_all_handler<RequiredUseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), - n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), + n::on_at_most_one() = + eapi.supported()->dependency_spec_tree_parse_options()[dstpo_allow_at_most_one] ? + ELikeDepParserAtMostOneFunction(std::bind(&any_all_handler<RequiredUseSpecTree, AtMostOneDepSpec>, std::ref(stack))) : + ELikeDepParserAtMostOneFunction(std::bind(&at_most_one_not_allowed_handler, s)), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&any_all_handler<RequiredUseSpecTree, ExactlyOneDepSpec>, std::ref(stack)), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), diff --git a/paludis/repositories/e/dep_parser.se b/paludis/repositories/e/dep_parser.se index 132aa7cd6..ba39c300f 100644 --- a/paludis/repositories/e/dep_parser.se +++ b/paludis/repositories/e/dep_parser.se @@ -12,5 +12,6 @@ make_enum_DependencySpecTreeParseOption() key dstpo_double_bang_blocks "Allow both !block and !!block" key dstpo_single_bang_block_is_hard "!block is a hard block" key dstpo_no_self_block "Blockers never block the containing package" + key dstpo_allow_at_most_one "Allow ?? ( )" } diff --git a/paludis/repositories/e/e_repository_TEST_5.cc b/paludis/repositories/e/e_repository_TEST_5.cc new file mode 100644 index 000000000..07532b7cf --- /dev/null +++ b/paludis/repositories/e/e_repository_TEST_5.cc @@ -0,0 +1,169 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2006, 2007, 2008, 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/repositories/e/e_repository.hh> +#include <paludis/repositories/e/e_repository_exceptions.hh> +#include <paludis/repositories/e/e_repository_id.hh> +#include <paludis/repositories/e/vdb_repository.hh> +#include <paludis/repositories/e/eapi.hh> +#include <paludis/repositories/e/spec_tree_pretty_printer.hh> + +#include <paludis/repositories/fake/fake_installed_repository.hh> +#include <paludis/repositories/fake/fake_package_id.hh> + +#include <paludis/environments/test/test_environment.hh> + +#include <paludis/util/system.hh> +#include <paludis/util/visitor_cast.hh> +#include <paludis/util/map.hh> +#include <paludis/util/make_named_values.hh> +#include <paludis/util/set.hh> +#include <paludis/util/make_null_shared_ptr.hh> +#include <paludis/util/safe_ifstream.hh> +#include <paludis/util/stringify.hh> + +#include <paludis/standard_output_manager.hh> +#include <paludis/package_id.hh> +#include <paludis/metadata_key.hh> +#include <paludis/action.hh> +#include <paludis/user_dep_spec.hh> +#include <paludis/generator.hh> +#include <paludis/filter.hh> +#include <paludis/filtered_generator.hh> +#include <paludis/selection.hh> +#include <paludis/repository_factory.hh> +#include <paludis/choice.hh> + +#include <functional> +#include <set> +#include <string> + +#include "config.h" + +#include <gtest/gtest.h> + +using namespace paludis; + +namespace +{ + void cannot_uninstall(const std::shared_ptr<const PackageID> & id, const UninstallActionOptions &) + { + if (id) + throw InternalError(PALUDIS_HERE, "cannot uninstall"); + } + + std::shared_ptr<OutputManager> make_standard_output_manager(const Action &) + { + return std::make_shared<StandardOutputManager>(); + } + + std::string from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m, + const std::string & k) + { + Map<std::string, std::string>::ConstIterator mm(m->find(k)); + if (m->end() == mm) + return ""; + else + return mm->second; + } + + WantPhase want_all_phases(const std::string &) + { + return wp_yes; + } +} + +TEST(ERepository, RequiredUse) +{ + FSPath root(FSPath::cwd() / "e_repository_TEST_5_dir" / "root"); + + TestEnvironment env; + 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() / "e_repository_TEST_5_dir" / "repo")); + keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "repo/profiles/profile")); + keys->insert("layout", "traditional"); + keys->insert("eapi_when_unknown", "0"); + keys->insert("eapi_when_unspecified", "0"); + keys->insert("profile_eapi", "0"); + keys->insert("distdir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "distdir")); + keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_5_dir" / "build")); + std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env, + std::bind(from_keys, keys, std::placeholders::_1))); + env.add_repository(1, repo); + + std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>( + make_named_values<FakeInstalledRepositoryParams>( + n::environment() = &env, + n::name() = RepositoryName("installed"), + n::suitable_destination() = true, + n::supports_uninstall() = true + ))); + env.add_repository(2, installed_repo); + + { + PretendAction pretend_action(make_named_values<PretendActionOptions>( + n::destination() = installed_repo, + n::make_output_manager() = &make_standard_output_manager, + n::replacing() = std::make_shared<PackageIDSequence>() + )); + + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-none-5::test-repo", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value()); + id->perform_action(pretend_action); + ASSERT_TRUE(! pretend_action.failed()); + } + + { + PretendAction pretend_action(make_named_values<PretendActionOptions>( + n::destination() = installed_repo, + n::make_output_manager() = &make_standard_output_manager, + n::replacing() = std::make_shared<PackageIDSequence>() + )); + + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-one-5::test-repo", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value()); + id->perform_action(pretend_action); + ASSERT_TRUE(! pretend_action.failed()); + } + + { + PretendAction pretend_action(make_named_values<PretendActionOptions>( + n::destination() = installed_repo, + n::make_output_manager() = &make_standard_output_manager, + n::replacing() = std::make_shared<PackageIDSequence>() + )); + + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/required-use-at-most-one-two-5::test-repo", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value()); + id->perform_action(pretend_action); + ASSERT_TRUE(pretend_action.failed()); + } +} + diff --git a/paludis/repositories/e/e_repository_TEST_5_cleanup.sh b/paludis/repositories/e/e_repository_TEST_5_cleanup.sh new file mode 100755 index 000000000..96274e78d --- /dev/null +++ b/paludis/repositories/e/e_repository_TEST_5_cleanup.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# vim: set ft=sh sw=4 sts=4 et : + +if [ -d e_repository_TEST_5_dir ] ; then + rm -fr e_repository_TEST_5_dir +else + true +fi + diff --git a/paludis/repositories/e/e_repository_TEST_5_setup.sh b/paludis/repositories/e/e_repository_TEST_5_setup.sh new file mode 100755 index 000000000..021540e6d --- /dev/null +++ b/paludis/repositories/e/e_repository_TEST_5_setup.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +# vim: set ft=sh sw=4 sts=4 et : + +mkdir e_repository_TEST_5_dir || exit 1 +cd e_repository_TEST_5_dir || exit 1 + +mkdir -p root/etc + +mkdir -p vdb +touch vdb/THISISTHEVDB + +mkdir -p build +ln -s build symlinked_build + +mkdir -p distdir + +mkdir -p repo/{profiles/profile,metadata,eclass} || exit 1 +cd repo || exit 1 +echo "test-repo" >> profiles/repo_name || exit 1 +echo "cat" >> profiles/categories || exit 1 +cat <<END > profiles/profile/make.defaults +ARCH="cheese" +USERLAND="GNU" +KERNEL="linux" +LIBC="glibc" +CHOST="i286-badger-linux-gnu" +LINGUAS="enabled_en enabled_en_GB enabled_en_GB@UTF-8" +USE_EXPAND="LINGUAS USERLAND" +USE_EXPAND_UNPREFIXED="ARCH" +USE_EXPAND_IMPLICIT="USERLAND ARCH" +USE_EXPAND_VALUES_USERLAND="GNU" +USE_EXPAND_VALUES_ARCH="cheese otherarch" +IUSE_IMPLICIT="build" +END + +mkdir -p "cat/required-use-at-most-one-none" || exit 1 +cat << 'END' > cat/required-use-at-most-one-none/required-use-at-most-one-none-5.ebuild || exit 1 +DESCRIPTION="The Description" +HOMEPAGE="http://example.com/" +SRC_URI="" +SLOT="0" +LICENSE="GPL-2" +KEYWORDS="test" +EAPI="5" +IUSE="disabled1 disabled2 disabled3 enabled1 enabled2 enabled3" +REQUIRED_USE="?? ( disabled1 disabled2 disabled3 )" +S="${WORKDIR}" +END + +mkdir -p "cat/required-use-at-most-one-one" || exit 1 +cat << 'END' > cat/required-use-at-most-one-one/required-use-at-most-one-one-5.ebuild || exit 1 +DESCRIPTION="The Description" +HOMEPAGE="http://example.com/" +SRC_URI="" +SLOT="0" +LICENSE="GPL-2" +KEYWORDS="test" +EAPI="5" +IUSE="disabled1 disabled2 disabled3 enabled1 enabled2 enabled3" +REQUIRED_USE="?? ( disabled1 enabled2 disabled3 )" +S="${WORKDIR}" +END + +mkdir -p "cat/required-use-at-most-one-two" || exit 1 +cat << 'END' > cat/required-use-at-most-one-two/required-use-at-most-one-two-5.ebuild || exit 1 +DESCRIPTION="The Description" +HOMEPAGE="http://example.com/" +SRC_URI="" +SLOT="0" +LICENSE="GPL-2" +KEYWORDS="test" +EAPI="5" +IUSE="disabled1 disabled2 disabled3 enabled1 enabled2 enabled3" +REQUIRED_USE="?? ( disabled1 enabled2 enabled3 )" +S="${WORKDIR}" +END + +cd .. +cd .. diff --git a/paludis/repositories/e/eapis/5.conf b/paludis/repositories/e/eapis/5.conf index 5ebc30bde..3947268b9 100644 --- a/paludis/repositories/e/eapis/5.conf +++ b/paludis/repositories/e/eapis/5.conf @@ -9,3 +9,4 @@ is_pbin = false ebuild_module_suffixes = 5 4 3 2 1 0 utility_path_suffixes = 5 4 3 2 1 0 +dependency_spec_tree_parse_options = ${dependency_spec_tree_parse_options} allow_at_most_one |