aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-07 00:21:06 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-07 00:21:06 +0000
commit7fe40a48a19863835dc932b747e4c1bb80970510 (patch)
treee23161da0e4e9184e95422f109107be52f3361d6
parentdf86259eedbe962f522a4a3fd5b60c91d52db170 (diff)
downloadpaludis-7fe40a48a19863835dc932b747e4c1bb80970510.tar.gz
paludis-7fe40a48a19863835dc932b747e4c1bb80970510.tar.xz
More deps QA checks
-rw-r--r--paludis/repositories/e/qa/dependency_keys.cc24
-rw-r--r--paludis/repositories/e/qa/dependency_keys_TEST.cc54
2 files changed, 76 insertions, 2 deletions
diff --git a/paludis/repositories/e/qa/dependency_keys.cc b/paludis/repositories/e/qa/dependency_keys.cc
index 6adf553..fec7ea4 100644
--- a/paludis/repositories/e/qa/dependency_keys.cc
+++ b/paludis/repositories/e/qa/dependency_keys.cc
@@ -21,6 +21,7 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/qa.hh>
+#include <paludis/dep_spec.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/e_repository_id.hh>
#include <paludis/util/stringify.hh>
@@ -40,6 +41,7 @@ namespace
const MetadataSpecTreeKey<DependencySpecTree> & key;
const std::string name;
unsigned level;
+ bool child_of_any;
Checker(QAReporter & r,
const tr1::shared_ptr<const PackageID> & i,
@@ -49,7 +51,8 @@ namespace
id(i),
key(k),
name(n),
- level(0)
+ level(0),
+ child_of_any(false)
{
}
@@ -57,15 +60,24 @@ namespace
{
}
- void visit_leaf(const BlockDepSpec &)
+ void visit_leaf(const BlockDepSpec & b)
{
+ if (child_of_any)
+ reporter.message(qaml_normal, name, "'|| ( )' block with block child '!"
+ + stringify(*b.blocked_spec()) + "' in dependency key '" + stringify(key.raw_name())
+ + "' for ID '" + stringify(*id) + "'");
}
void visit_sequence(const UseDepSpec &,
DependencySpecTree::ConstSequenceIterator cur,
DependencySpecTree::ConstSequenceIterator end)
{
+ if (child_of_any)
+ reporter.message(qaml_normal, name, "'|| ( )' block with use? ( ) child in dependency key '" + stringify(key.raw_name())
+ + "' for ID '" + stringify(*id) + "'");
+
Save<unsigned> save_level(&level, level + 1);
+ Save<bool> save_child_of_any(&child_of_any, false);
if (cur == end)
reporter.message(qaml_normal, name, "Empty 'use? ( )' block in dependency key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
@@ -78,6 +90,7 @@ namespace
DependencySpecTree::ConstSequenceIterator end)
{
Save<unsigned> save_level(&level, level + 1);
+ Save<bool> save_child_of_any(&child_of_any, false);
if (cur == end)
{
if (level > 1)
@@ -93,9 +106,16 @@ namespace
DependencySpecTree::ConstSequenceIterator end)
{
Save<unsigned> save_level(&level, level + 1);
+ Save<bool> save_child_of_any(&child_of_any, true);
if (cur == end)
reporter.message(qaml_normal, name, "Empty '|| ( )' block in dependency key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
+ else if (next(cur) == end)
+ {
+ cur->accept(*this);
+ reporter.message(qaml_normal, name, "'|| ( )' block with only one child in dependency key '" + stringify(key.raw_name())
+ + "' for ID '" + stringify(*id) + "'");
+ }
else
std::for_each(cur, end, accept_visitor(*this));
}
diff --git a/paludis/repositories/e/qa/dependency_keys_TEST.cc b/paludis/repositories/e/qa/dependency_keys_TEST.cc
index dd6ce13..e795329 100644
--- a/paludis/repositories/e/qa/dependency_keys_TEST.cc
+++ b/paludis/repositories/e/qa/dependency_keys_TEST.cc
@@ -104,5 +104,59 @@ namespace test_cases
TEST_CHECK_EQUAL(r4.count, 2u);
}
} test_empty_block;
+
+ struct AnyUseTest : TestCase
+ {
+ AnyUseTest() : TestCase("|| ( use? ( ) )") { }
+
+ 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("|| ( v/w x? ( x/y ) )");
+
+ TestReporter r;
+ TEST_CHECK(dependency_keys_check(r, id, "dependency keys"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_any_use;
+
+ struct AnyOneTest : TestCase
+ {
+ AnyOneTest() : TestCase("|| ( one )") { }
+
+ 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("|| ( x/x )");
+
+ TestReporter r;
+ TEST_CHECK(dependency_keys_check(r, id, "dependency keys"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_any_one;
+
+ struct AnyBlockTest : TestCase
+ {
+ AnyBlockTest() : TestCase("|| ( !block )") { }
+
+ 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("|| ( x/x !y/y z/z )");
+
+ TestReporter r;
+ TEST_CHECK(dependency_keys_check(r, id, "dependency keys"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_any_block;
}