aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-09 18:22:47 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-09 18:22:47 +0000
commit2e12e47bb3b2161198798e1c4b773364ba158502 (patch)
tree41d72c056fd36fc5fe3da783eb1db5a426d8f050
parentde7bfcf80fe937d8e067b981c1c0dac0fbad0b7c (diff)
downloadpaludis-2e12e47bb3b2161198798e1c4b773364ba158502.tar.gz
paludis-2e12e47bb3b2161198798e1c4b773364ba158502.tar.xz
Resurrect the old dep_flags_check checks as part of spec_keys.
-rw-r--r--paludis/repositories/e/qa/spec_keys.cc78
-rw-r--r--paludis/repositories/e/qa/spec_keys_TEST.cc25
2 files changed, 95 insertions, 8 deletions
diff --git a/paludis/repositories/e/qa/spec_keys.cc b/paludis/repositories/e/qa/spec_keys.cc
index 7374774..e33f6bd 100644
--- a/paludis/repositories/e/qa/spec_keys.cc
+++ b/paludis/repositories/e/qa/spec_keys.cc
@@ -22,6 +22,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/qa.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/repository.hh>
#include <paludis/util/config_file.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/e_repository_id.hh>
@@ -87,9 +88,11 @@ namespace
const FSEntry entry;
QAReporter & reporter;
const tr1::shared_ptr<const PackageID> & id;
+ const std::set<UseFlagName> & iuse_flags;
const tr1::shared_ptr<const MetadataKey> & key;
const std::string name;
const tr1::shared_ptr<const QualifiedPackageNameSet> pds_blacklist;
+ bool forbid_arch_flags, forbid_inverse_arch_flags;
unsigned level;
bool child_of_any;
@@ -99,15 +102,20 @@ namespace
const FSEntry & f,
QAReporter & r,
const tr1::shared_ptr<const PackageID> & i,
+ const std::set<UseFlagName> & iuse,
const tr1::shared_ptr<const MetadataKey> & k,
const std::string & n,
- const tr1::shared_ptr<const QualifiedPackageNameSet> p) :
+ const tr1::shared_ptr<const QualifiedPackageNameSet> p,
+ bool a, bool ia) :
entry(f),
reporter(r),
id(i),
+ iuse_flags(iuse),
key(k),
name(n),
pds_blacklist(p),
+ forbid_arch_flags(a),
+ forbid_inverse_arch_flags(ia),
level(0),
child_of_any(false)
{
@@ -180,6 +188,51 @@ namespace
.with_associated_id(id)
.with_associated_key(id, key));
+ if (id->repository()->use_interface->arch_flags()->count(u.flag()))
+ {
+ if (forbid_arch_flags)
+ reporter.message(QAMessage(entry, qaml_normal, name,
+ "Arch flag '" + stringify(u.flag()) + "' in '" + stringify(key->raw_name()) + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, key));
+ else if (u.inverse() && forbid_inverse_arch_flags)
+ reporter.message(QAMessage(entry, qaml_maybe, name,
+ "Inverse arch flag '" + stringify(u.flag()) + "' in '" + stringify(key->raw_name()) + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, key));
+ }
+
+ else
+ {
+ if (iuse_flags.end() == iuse_flags.find(u.flag()))
+ {
+ std::tr1::shared_ptr<const UseFlagNameSet> c(
+ id->repository()->use_interface->use_expand_hidden_prefixes());
+ std::string flag(stringify(u.flag()));
+ bool is_hidden(false);
+
+ for (UseFlagNameSet::ConstIterator i(c->begin()), i_end(c->end()) ;
+ i != i_end ; ++i)
+ {
+ std::string prefix(stringify(*i) + id->repository()->use_interface->use_expand_separator(*id));
+ if (0 == flag.compare(0, prefix.length(), prefix))
+ {
+ is_hidden = true;
+ break;
+ }
+ }
+
+ if (! is_hidden)
+ reporter.message(QAMessage(entry, qaml_normal, name,
+ "Conditional flag '" + stringify(u.flag()) +
+ "' in '" + stringify(key->raw_name()) + "' not in '" +
+ stringify(id->iuse_key()->raw_name()) + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, key)
+ .with_associated_key(id, id->iuse_key()));
+ }
+ }
+
Save<unsigned> save_level(&level, level + 1);
Save<bool> save_child_of_any(&child_of_any, false);
Save<std::set<UseFlagName> > save_uses(&uses, uses);
@@ -242,16 +295,19 @@ namespace
QAReporter & reporter;
tr1::shared_ptr<const MetadataKey> key;
const tr1::shared_ptr<const PackageID> & id;
+ const std::set<UseFlagName> & iuse_flags;
const std::string name;
CheckForwarder(
const FSEntry & f,
QAReporter & r,
const tr1::shared_ptr<const PackageID> & i,
+ const std::set<UseFlagName> & iuse,
const std::string & n) :
entry(f),
reporter(r),
id(i),
+ iuse_flags(iuse),
name(n)
{
}
@@ -325,7 +381,7 @@ namespace
try
{
Context context("When visiting metadata key '" + k.raw_name() + "':");
- Checker c(entry, reporter, id, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>());
+ Checker c(entry, reporter, id, iuse_flags, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>(), false, false);
k.value()->accept(c);
}
catch (const Exception & e)
@@ -342,7 +398,7 @@ namespace
try
{
Context context("When visiting metadata key '" + k.raw_name() + "':");
- Checker c(entry, reporter, id, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>());
+ Checker c(entry, reporter, id, iuse_flags, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>(), true, true);
k.value()->accept(c);
}
catch (const Exception & e)
@@ -359,7 +415,7 @@ namespace
try
{
Context context("When visiting metadata key '" + k.raw_name() + "':");
- Checker c(entry, reporter, id, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>());
+ Checker c(entry, reporter, id, iuse_flags, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>(), true, true);
k.value()->accept(c);
}
catch (const Exception & e)
@@ -376,7 +432,7 @@ namespace
try
{
Context context("When visiting metadata key '" + k.raw_name() + "':");
- Checker c(entry, reporter, id, key, name, SpecKeysBlacklist::get_instance()->blacklist(k.raw_name()));
+ Checker c(entry, reporter, id, iuse_flags, key, name, SpecKeysBlacklist::get_instance()->blacklist(k.raw_name()), false, true);
k.value()->accept(c);
}
catch (const Exception & e)
@@ -393,7 +449,7 @@ namespace
try
{
Context context("When visiting metadata key '" + k.raw_name() + "':");
- Checker c(entry, reporter, id, key, name, SpecKeysBlacklist::get_instance()->blacklist(k.raw_name()));
+ Checker c(entry, reporter, id, iuse_flags, key, name, SpecKeysBlacklist::get_instance()->blacklist(k.raw_name()), true, true);
k.value()->accept(c);
}
catch (const Exception & e)
@@ -410,7 +466,7 @@ namespace
try
{
Context context("When visiting metadata key '" + k.raw_name() + "':");
- Checker c(entry, reporter, id, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>());
+ Checker c(entry, reporter, id, iuse_flags, key, name, tr1::shared_ptr<const QualifiedPackageNameSet>(), true, true);
k.value()->accept(c);
}
catch (const Exception & e)
@@ -437,7 +493,13 @@ paludis::erepository::spec_keys_check(
using namespace tr1::placeholders;
- CheckForwarder f(entry, reporter, id, name);
+ std::set<UseFlagName> iuse;
+ std::transform(id->iuse_key()->value()->begin(),
+ id->iuse_key()->value()->end(),
+ std::inserter(iuse, iuse.begin()),
+ tr1::mem_fn(&IUseFlag::flag));
+
+ CheckForwarder f(entry, reporter, id, iuse, name);
std::for_each(id->begin_metadata(), id->end_metadata(), tr1::bind(&CheckForwarder::visit_sptr, &f, _1));
return true;
diff --git a/paludis/repositories/e/qa/spec_keys_TEST.cc b/paludis/repositories/e/qa/spec_keys_TEST.cc
index 371cdce..f0f56cf 100644
--- a/paludis/repositories/e/qa/spec_keys_TEST.cc
+++ b/paludis/repositories/e/qa/spec_keys_TEST.cc
@@ -23,6 +23,7 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/package_database.hh>
#include <paludis/qa.hh>
+#include <paludis/util/options.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -97,12 +98,14 @@ namespace test_cases
tr1::shared_ptr<FakePackageID> id3(repo->add_version("cat", "pkg", "3"));
id3->build_dependencies_key()->set_from_string("x? ( )");
+ id3->iuse_key()->set_from_string("x", IUseFlagParseOptions());
TestReporter r3;
TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r3, id3, "spec keys"));
TEST_CHECK_EQUAL(r3.count, 1u);
tr1::shared_ptr<FakePackageID> id4(repo->add_version("cat", "pkg", "4"));
id4->build_dependencies_key()->set_from_string("x? ( ) ( y? ( || ( ) ) )");
+ id4->iuse_key()->set_from_string("x y", IUseFlagParseOptions());
TestReporter r4;
TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r4, id4, "spec keys"));
TEST_CHECK_EQUAL(r4.count, 2u);
@@ -120,6 +123,7 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
tr1::shared_ptr<FakePackageID> id(repo->add_version("cat", "pkg", "1"));
id->build_dependencies_key()->set_from_string("|| ( v/w x? ( x/y ) )");
+ id->iuse_key()->set_from_string("x", IUseFlagParseOptions());
TestReporter r;
TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r, id, "spec keys"));
@@ -195,6 +199,7 @@ namespace test_cases
tr1::shared_ptr<FakePackageID> id1(repo->add_version("cat", "pkg", "1"));
id1->build_dependencies_key()->set_from_string("x? ( x? ( cat/pkg ) )");
+ id1->iuse_key()->set_from_string("x", IUseFlagParseOptions());
TestReporter r1;
TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r1, id1, "spec keys"));
@@ -202,11 +207,31 @@ namespace test_cases
tr1::shared_ptr<FakePackageID> id2(repo->add_version("cat", "pkg", "2"));
id2->build_dependencies_key()->set_from_string("x? ( !x? ( cat/pkg ) )");
+ id2->iuse_key()->set_from_string("x", IUseFlagParseOptions());
TestReporter r2;
TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r2, id2, "spec keys"));
TEST_CHECK_EQUAL(r2.count, 1u);
}
} test_recursive_use;
+
+ struct MissingIUseTest : TestCase
+ {
+ MissingIUseTest() : TestCase("missing iuse") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+
+ tr1::shared_ptr<FakePackageID> id(repo->add_version("cat", "pkg", "1"));
+ id->build_dependencies_key()->set_from_string("foo? ( cat/pkg1 )");
+
+ TestReporter r;
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r, id, "spec keys"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_missing_iuse;
}