aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-08 16:50:03 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-08-08 16:50:03 +0000
commit0eb34d3a8c272ed1c750b8c1a741d441ec5437cd (patch)
tree9daf1a6711dea63186ab72a9dddc20180ead1721
parenta73dfc3085bcd62ffabd0e7324169bae1b555960 (diff)
downloadpaludis-0eb34d3a8c272ed1c750b8c1a741d441ec5437cd.tar.gz
paludis-0eb34d3a8c272ed1c750b8c1a741d441ec5437cd.tar.xz
More QA work
-rw-r--r--paludis/repositories/e/qa/Makefile.am10
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc8
-rw-r--r--paludis/repositories/e/qa/spec_keys.cc (renamed from paludis/repositories/e/qa/dependency_keys.cc)172
-rw-r--r--paludis/repositories/e/qa/spec_keys.hh (renamed from paludis/repositories/e/qa/dependency_keys.hh)6
-rw-r--r--paludis/repositories/e/qa/spec_keys_TEST.cc (renamed from paludis/repositories/e/qa/dependency_keys_TEST.cc)18
5 files changed, 145 insertions, 69 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 2b8aaba..07d799a 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -14,9 +14,9 @@ if ENABLE_QA
paludis_repositories_e_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/paludis/repositories/e/
paludis_repositories_e_include_HEADERS = \
- dependency_keys.hh \
eapi_supported.hh \
homepage_key.hh \
+ spec_keys.hh \
qa_checks.hh \
qa_checks_group.hh \
qa_controller.hh \
@@ -26,13 +26,13 @@ paludis_repositories_e_include_HEADERS = \
noinst_LTLIBRARIES = libpaludiserepositoryqa.la
libpaludiserepositoryqa_la_SOURCES = \
- dependency_keys.cc \
eapi_supported.cc \
homepage_key.cc \
qa_checks.cc \
qa_checks_group.cc \
qa_controller.cc \
short_description_key.cc \
+ spec_keys.cc \
stray_files.cc \
$(paludis_repositories_e_include_HEADERS)
@@ -61,13 +61,13 @@ TESTS_ENVIRONMENT = env \
if ENABLE_QA
TESTS = \
- dependency_keys_TEST \
+ spec_keys_TEST \
stray_files_TEST
check_PROGRAMS = $(TESTS)
-dependency_keys_TEST_SOURCES = dependency_keys_TEST.cc
-dependency_keys_TEST_LDFLAGS = \
+spec_keys_TEST_SOURCES = spec_keys_TEST.cc
+spec_keys_TEST_LDFLAGS = \
libpaludiserepositoryqa.la \
$(top_builddir)/paludis/repositories/e/libpaludiserepository.la \
$(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index 1dd2845..85d0869 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -25,7 +25,7 @@
#include <paludis/repositories/e/qa/eapi_supported.hh>
#include <paludis/repositories/e/qa/short_description_key.hh>
#include <paludis/repositories/e/qa/homepage_key.hh>
-#include <paludis/repositories/e/qa/dependency_keys.hh>
+#include <paludis/repositories/e/qa/spec_keys.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -72,9 +72,9 @@ QAChecks::QAChecks() :
tr1::bind(homepage_key_check, _1, _2, _5, "homepage_key"));
_imp->package_id_checks_group->add_prerequirement("homepage_key", "eapi_supported");
- _imp->package_id_checks_group->add_check("dependency_keys",
- tr1::bind(dependency_keys_check, _1, _2, _5, "dependency_keys"));
- _imp->package_id_checks_group->add_prerequirement("dependency_keys", "eapi_supported");
+ _imp->package_id_checks_group->add_check("spec_keys",
+ tr1::bind(spec_keys_check, _1, _2, _5, "spec_keys"));
+ _imp->package_id_checks_group->add_prerequirement("spec_keys", "eapi_supported");
}
QAChecks::~QAChecks()
diff --git a/paludis/repositories/e/qa/dependency_keys.cc b/paludis/repositories/e/qa/spec_keys.cc
index 1123ba6..a17d2cf 100644
--- a/paludis/repositories/e/qa/dependency_keys.cc
+++ b/paludis/repositories/e/qa/spec_keys.cc
@@ -17,7 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "dependency_keys.hh"
+#include "spec_keys.hh"
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/qa.hh>
@@ -28,6 +28,9 @@
#include <paludis/util/save.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/parallel_for_each.hh>
+#include <algorithm>
using namespace paludis;
using namespace paludis::erepository;
@@ -35,12 +38,12 @@ using namespace paludis::erepository;
namespace
{
struct Checker :
- ConstVisitor<DependencySpecTree>
+ ConstVisitor<GenericSpecTree>
{
const FSEntry entry;
QAReporter & reporter;
const tr1::shared_ptr<const PackageID> & id;
- const MetadataSpecTreeKey<DependencySpecTree> & key;
+ const MetadataKey & key;
const std::string name;
unsigned level;
bool child_of_any;
@@ -49,7 +52,7 @@ namespace
const FSEntry & f,
QAReporter & r,
const tr1::shared_ptr<const PackageID> & i,
- const MetadataSpecTreeKey<DependencySpecTree> & k,
+ const MetadataKey & k,
const std::string & n) :
entry(f),
reporter(r),
@@ -69,37 +72,49 @@ namespace
{
if (child_of_any)
reporter.message(entry, qaml_normal, name, "'|| ( )' block with block child '!"
- + stringify(*b.blocked_spec()) + "' in dependency key '" + stringify(key.raw_name())
+ + stringify(*b.blocked_spec()) + "' in spec key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
}
+ void visit_leaf(const URIDepSpec &)
+ {
+ }
+
+ void visit_leaf(const PlainTextDepSpec &)
+ {
+ }
+
+ void visit_leaf(const LabelsDepSpec<URILabelVisitorTypes> &)
+ {
+ }
+
void visit_sequence(const UseDepSpec &,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
+ GenericSpecTree::ConstSequenceIterator cur,
+ GenericSpecTree::ConstSequenceIterator end)
{
if (child_of_any)
- reporter.message(entry, qaml_normal, name, "'|| ( )' block with use? ( ) child in dependency key '" + stringify(key.raw_name())
+ reporter.message(entry, qaml_normal, name, "'|| ( )' block with use? ( ) child in spec 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(entry, qaml_normal, name, "Empty 'use? ( )' block in dependency key '" + stringify(key.raw_name())
+ reporter.message(entry, qaml_normal, name, "Empty 'use? ( )' block in spec key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
else
std::for_each(cur, end, accept_visitor(*this));
}
void visit_sequence(const AllDepSpec &,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
+ GenericSpecTree::ConstSequenceIterator cur,
+ GenericSpecTree::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)
- reporter.message(entry, qaml_normal, name, "Empty '( )' block in dependency key '" + stringify(key.raw_name())
+ reporter.message(entry, qaml_normal, name, "Empty '( )' block in spec key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
}
else
@@ -107,18 +122,18 @@ namespace
}
void visit_sequence(const AnyDepSpec &,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
+ GenericSpecTree::ConstSequenceIterator cur,
+ GenericSpecTree::ConstSequenceIterator end)
{
Save<unsigned> save_level(&level, level + 1);
Save<bool> save_child_of_any(&child_of_any, true);
if (cur == end)
- reporter.message(entry, qaml_normal, name, "Empty '|| ( )' block in dependency key '" + stringify(key.raw_name())
+ reporter.message(entry, qaml_normal, name, "Empty '|| ( )' block in spec key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
else if (next(cur) == end)
{
cur->accept(*this);
- reporter.message(entry, qaml_normal, name, "'|| ( )' block with only one child in dependency key '" + stringify(key.raw_name())
+ reporter.message(entry, qaml_normal, name, "'|| ( )' block with only one child in spec key '" + stringify(key.raw_name())
+ "' for ID '" + stringify(*id) + "'");
}
else
@@ -126,54 +141,115 @@ namespace
}
};
- bool dependency_key_check(
- const FSEntry & entry,
- QAReporter & reporter,
- const tr1::shared_ptr<const PackageID> & id,
- const std::string & name,
- const MetadataSpecTreeKey<DependencySpecTree> & key)
+ struct CheckForwarder :
+ ConstVisitor<MetadataKeyVisitorTypes>
{
- Context context("When checking dependency key '" + key.raw_name() + "' for check '" + name +
- "' using dependency_keys_check on ID '" + stringify(*id) + "':");
+ const FSEntry entry;
+ QAReporter & reporter;
+ const tr1::shared_ptr<const PackageID> & id;
+ const std::string name;
+
+ CheckForwarder(
+ const FSEntry & f,
+ QAReporter & r,
+ const tr1::shared_ptr<const PackageID> & i,
+ const std::string & n) :
+ entry(f),
+ reporter(r),
+ id(i),
+ name(n)
+ {
+ }
- Checker c(entry, reporter, id, key, name);
- try
+ void visit(const MetadataStringKey &)
{
- key.value()->accept(c);
}
- catch (const Exception & e)
+
+ void visit(const MetadataTimeKey &)
{
- reporter.message(entry, qaml_severe, name, "Caught exception '" + stringify(e.message())
- + "' (" + e.what() + "') when handling key '" + key.raw_name() + "'");
}
- return true;
- }
+ void visit(const MetadataContentsKey &)
+ {
+ }
+
+ void visit(const MetadataPackageIDKey &)
+ {
+ }
+
+ void visit(const MetadataRepositoryMaskInfoKey &)
+ {
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<InheritedSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<PackageIDSequence> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> & k)
+ {
+ Context context("When visiting metadata key '" + k.raw_name() + "':");
+ Checker c(entry, reporter, id, k, name);
+ k.value()->accept(c);
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
+ {
+ Context context("When visiting metadata key '" + k.raw_name() + "':");
+ Checker c(entry, reporter, id, k, name);
+ k.value()->accept(c);
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
+ {
+ Context context("When visiting metadata key '" + k.raw_name() + "':");
+ Checker c(entry, reporter, id, k, name);
+ k.value()->accept(c);
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
+ {
+ Context context("When visiting metadata key '" + k.raw_name() + "':");
+ Checker c(entry, reporter, id, k, name);
+ k.value()->accept(c);
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> & k)
+ {
+ Context context("When visiting metadata key '" + k.raw_name() + "':");
+ Checker c(entry, reporter, id, k, name);
+ k.value()->accept(c);
+ }
+ };
}
bool
-paludis::erepository::dependency_keys_check(
+paludis::erepository::spec_keys_check(
const FSEntry & entry,
QAReporter & reporter,
const tr1::shared_ptr<const PackageID> & id,
const std::string & name)
{
- Context context("When performing check '" + name + "' using dependency_keys_check on ID '" + stringify(*id) + "':");
-
- bool result(true);
-
- if (id->build_dependencies_key())
- result &= dependency_key_check(entry, reporter, id, name, *id->build_dependencies_key());
-
- if (id->run_dependencies_key())
- result &= dependency_key_check(entry, reporter, id, name, *id->run_dependencies_key());
-
- if (id->post_dependencies_key())
- result &= dependency_key_check(entry, reporter, id, name, *id->post_dependencies_key());
+ Context context("When performing check '" + name + "' using spec_keys_check on ID '" + stringify(*id) + "':");
- if (id->suggested_dependencies_key())
- result &= dependency_key_check(entry, reporter, id, name, *id->suggested_dependencies_key());
+ CheckForwarder f(entry, reporter, id, name);
+ parallel_for_each(indirect_iterator(id->begin_metadata()), indirect_iterator(id->end_metadata()), accept_visitor(f));
- return result;
+ return true;
}
diff --git a/paludis/repositories/e/qa/dependency_keys.hh b/paludis/repositories/e/qa/spec_keys.hh
index 03734b1..06382ee 100644
--- a/paludis/repositories/e/qa/dependency_keys.hh
+++ b/paludis/repositories/e/qa/spec_keys.hh
@@ -17,8 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_DEPENDENCIES_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_DEPENDENCIES_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_SPEC_KEYS_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_SPEC_KEYS_HH 1
#include <paludis/qa-fwd.hh>
#include <paludis/package_id-fwd.hh>
@@ -29,7 +29,7 @@ namespace paludis
{
namespace erepository
{
- bool dependency_keys_check(
+ bool spec_keys_check(
const FSEntry &,
QAReporter &,
const tr1::shared_ptr<const PackageID> &,
diff --git a/paludis/repositories/e/qa/dependency_keys_TEST.cc b/paludis/repositories/e/qa/spec_keys_TEST.cc
index f35bf45..2ec05a0 100644
--- a/paludis/repositories/e/qa/dependency_keys_TEST.cc
+++ b/paludis/repositories/e/qa/spec_keys_TEST.cc
@@ -17,7 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "dependency_keys.hh"
+#include <paludis/repositories/e/qa/spec_keys.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/environments/test/test_environment.hh>
@@ -64,7 +64,7 @@ namespace test_cases
id->build_dependencies_key()->set_from_string("cat/other");
TestReporter r;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r, id, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r, id, "spec keys"));
TEST_CHECK_EQUAL(r.count, 0u);
}
} test_good;
@@ -82,25 +82,25 @@ namespace test_cases
tr1::shared_ptr<FakePackageID> id1(repo->add_version("cat", "pkg", "1"));
id1->build_dependencies_key()->set_from_string("( ( ) )");
TestReporter r1;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r1, id1, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r1, id1, "spec keys"));
TEST_CHECK_EQUAL(r1.count, 1u);
tr1::shared_ptr<FakePackageID> id2(repo->add_version("cat", "pkg", "2"));
id2->build_dependencies_key()->set_from_string("|| ( )");
TestReporter r2;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r2, id2, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r2, id2, "spec keys"));
TEST_CHECK_EQUAL(r2.count, 1u);
tr1::shared_ptr<FakePackageID> id3(repo->add_version("cat", "pkg", "3"));
id3->build_dependencies_key()->set_from_string("x? ( )");
TestReporter r3;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r3, id3, "dependency keys"));
+ 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? ( || ( ) ) )");
TestReporter r4;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r4, id4, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r4, id4, "spec keys"));
TEST_CHECK_EQUAL(r4.count, 2u);
}
} test_empty_block;
@@ -118,7 +118,7 @@ namespace test_cases
id->build_dependencies_key()->set_from_string("|| ( v/w x? ( x/y ) )");
TestReporter r;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r, id, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r, id, "spec keys"));
TEST_CHECK_EQUAL(r.count, 1u);
}
} test_any_use;
@@ -136,7 +136,7 @@ namespace test_cases
id->build_dependencies_key()->set_from_string("|| ( x/x )");
TestReporter r;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r, id, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r, id, "spec keys"));
TEST_CHECK_EQUAL(r.count, 1u);
}
} test_any_one;
@@ -154,7 +154,7 @@ namespace test_cases
id->build_dependencies_key()->set_from_string("|| ( x/x !y/y z/z )");
TestReporter r;
- TEST_CHECK(dependency_keys_check(FSEntry("/var/empty"), r, id, "dependency keys"));
+ TEST_CHECK(spec_keys_check(FSEntry("/var/empty"), r, id, "spec keys"));
TEST_CHECK_EQUAL(r.count, 1u);
}
} test_any_block;