diff options
author | 2011-06-18 15:18:13 +0100 | |
---|---|---|
committer | 2011-06-19 16:47:01 +0100 | |
commit | 726d87775ad381f4c38bf336e02437a9f3bed037 (patch) | |
tree | 60ca8a4160de31c8c60bde3e9468a9966a320e86 /paludis/repositories | |
parent | 14cf12a2f28dec2a3f7b8b883838f4a801e1a4ce (diff) | |
download | paludis-726d87775ad381f4c38bf336e02437a9f3bed037.tar.gz paludis-726d87775ad381f4c38bf336e02437a9f3bed037.tar.xz |
expecting_tests
Diffstat (limited to 'paludis/repositories')
4 files changed, 155 insertions, 1 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_exheres_0.cc b/paludis/repositories/e/e_repository_TEST_exheres_0.cc index 77f22574c..b170394ad 100644 --- a/paludis/repositories/e/e_repository_TEST_exheres_0.cc +++ b/paludis/repositories/e/e_repository_TEST_exheres_0.cc @@ -564,5 +564,29 @@ TEST(ERepository, InstallExheres0) ASSERT_TRUE(bool(id)); EXPECT_THROW(id->perform_action(action), ActionFailedError); } + + { + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/expecting-tests-enabled-1", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + id->perform_action(action); + } + + { + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/expecting-tests-disabled-1", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + id->perform_action(action); + } + + { + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/expecting-tests-none-1", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_THROW(id->perform_action(action), ActionFailedError); + } } diff --git a/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh b/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh index 03d93ae47..489fc6c45 100755 --- a/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh +++ b/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh @@ -1077,6 +1077,61 @@ WORK="${WORKBASE}" optionq spork END +mkdir -p "packages/cat/expecting-tests-enabled" +cat <<'END' > packages/cat/expecting-tests-enabled/expecting-tests-enabled-1.ebuild || exit 1 +DESCRIPTION="The Long Description" +SUMMARY="The Short Description" +HOMEPAGE="http://example.com/" +DOWNLOADS="" +SLOT="0" +MYOPTIONS="spork" +LICENCES="GPL-2" +PLATFORMS="test" +WORK="${WORKBASE}" + +pkg_setup() { + expecting_tests || die "expecting_tests" + expecting_tests --any || die "expecting_tests --any" + expecting_tests --recommended || die "expecting_tests --recommended" +} +END +mkdir -p "packages/cat/expecting-tests-disabled" +cat <<'END' > packages/cat/expecting-tests-disabled/expecting-tests-disabled-1.ebuild || exit 1 +DESCRIPTION="The Long Description" +SUMMARY="The Short Description" +HOMEPAGE="http://example.com/" +DOWNLOADS="" +SLOT="0" +MYOPTIONS="spork" +LICENCES="GPL-2" +PLATFORMS="test" +WORK="${WORKBASE}" + +pkg_setup() { + expecting_tests --expensive && die "expecting_tests --expensive" +} + +src_test_expensive() { + echo monkeys +} +END +mkdir -p "packages/cat/expecting-tests-none" +cat <<'END' > packages/cat/expecting-tests-none/expecting-tests-none-1.ebuild || exit 1 +DESCRIPTION="The Long Description" +SUMMARY="The Short Description" +HOMEPAGE="http://example.com/" +DOWNLOADS="" +SLOT="0" +MYOPTIONS="spork" +LICENCES="GPL-2" +PLATFORMS="test" +WORK="${WORKBASE}" + +pkg_setup() { + expecting_tests --expensive +} +END + cd .. cd .. diff --git a/paludis/repositories/e/ebuild/exheres-0/list_functions.bash b/paludis/repositories/e/ebuild/exheres-0/list_functions.bash index e7d0dfdaa..ae8316e76 100644 --- a/paludis/repositories/e/ebuild/exheres-0/list_functions.bash +++ b/paludis/repositories/e/ebuild/exheres-0/list_functions.bash @@ -1,7 +1,7 @@ #!/usr/bin/env bash # vim: set sw=4 sts=4 et : -# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh +# Copyright (c) 2006, 2007, 2008, 2011 Ciaran McCreesh # # Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 # Gentoo Foundation and distributed under the terms of the GNU General @@ -93,3 +93,9 @@ hasq() return 1 } +expecting_tests() +{ + local r=$(paludis_pipe_command EXPECTING_TESTS "$EAPI" "${1:---any}" ) + return ${r%%;*} +} + diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc index bd3949f49..77f69018a 100644 --- a/paludis/repositories/e/pipe_command_handler.cc +++ b/paludis/repositories/e/pipe_command_handler.cc @@ -52,6 +52,7 @@ #include <paludis/unformatted_pretty_printer.hh> #include <paludis/version_spec.hh> #include <paludis/repository.hh> +#include <paludis/elike_choices.hh> #include <vector> #include <limits> @@ -452,6 +453,74 @@ paludis::erepository::pipe_command_handler(const Environment * const environment return "O1;"; } } + else if (tokens[0] == "EXPECTING_TESTS") + { + if (tokens.size() != 3) + { + Log::get_instance()->message("e.pipe_commands.expecting_tests.bad", ll_warning, lc_context) << "Got bad EXPECTING_TESTS pipe command"; + return "Ebad EXPECTING_TESTS command"; + } + else + { + std::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string(tokens[1])); + if (! eapi->supported()) + return "EEXPECTING_TESTS EAPI " + tokens[1] + " unsupported"; + + if (in_metadata_generation) + return "Ecannot query expecting tests during metadata generation"; + + if (! package_id->choices_key()) + return "EEXPECTING_TESTS ID " + stringify(*package_id) + " has no choices"; + + bool expensive(true), recommended(true), optional(true), any(true); + if (tokens[2].empty() || tokens[2] == "--any") + { + } + else if (tokens[2] == "--expensive") + any = recommended = optional = false; + else if (tokens[2] == "--recommended") + any = expensive = optional = false; + else if (tokens[2] == "--optional") + any = recommended = expensive = false; + + auto choices(package_id->choices_key()->parse_value()); + + if (optional) + { + const auto name(ELikeOptionalTestsChoiceValue::canonical_name_with_prefix()); + const auto value(choices->find_by_name_with_prefix(name)); + if (value && value->enabled()) + return "O0;"; + + if ((! value) && (! any) && (! choices->has_matching_contains_every_value_prefix(name))) + return "EOPTIONQ ID " + stringify(*package_id) + " has no choice named '" + stringify(name) + "'"; + } + + if (recommended) + { + const auto name(ELikeRecommendedTestsChoiceValue::canonical_name_with_prefix()); + const auto value(choices->find_by_name_with_prefix(name)); + if (value && value->enabled()) + return "O0;"; + + if ((! value) && (! any) && (! choices->has_matching_contains_every_value_prefix(name))) + return "EOPTIONQ ID " + stringify(*package_id) + " has no choice named '" + stringify(name) + "'"; + } + + if (expensive) + { + const auto name(ELikeExpensiveTestsChoiceValue::canonical_name_with_prefix()); + const auto value(choices->find_by_name_with_prefix(name)); + if (value && value->enabled()) + return "O0;"; + + if ((! value) && (! any) && (! choices->has_matching_contains_every_value_prefix(name))) + return "EOPTIONQ ID " + stringify(*package_id) + " has no choice named '" + stringify(name) + "'"; + } + + return "O1;"; + } + } else if (tokens[0] == "REWRITE_VAR") { if (tokens.size() < 4) |