aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-15 15:51:45 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-15 15:51:45 +0000
commitdf29e5f6466db32b96f5fe2c9312afc27c7ccf82 (patch)
tree69c3b31f1f2539dee230f8bb3d01d05561cb2658
parent0f4b222ba36512285078de42fcddd00cac00764a (diff)
downloadpaludis-df29e5f6466db32b96f5fe2c9312afc27c7ccf82.tar.gz
paludis-df29e5f6466db32b96f5fe2c9312afc27c7ccf82.tar.xz
Resurrect misc_files check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am21
-rw-r--r--paludis/repositories/e/qa/misc_files.cc51
-rw-r--r--paludis/repositories/e/qa/misc_files.hh37
-rw-r--r--paludis/repositories/e/qa/misc_files_TEST.cc130
-rwxr-xr-xpaludis/repositories/e/qa/misc_files_TEST_cleanup.sh12
-rwxr-xr-xpaludis/repositories/e/qa/misc_files_TEST_setup.sh23
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc4
7 files changed, 276 insertions, 2 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 0f61f70..18c5b11 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -43,6 +43,7 @@ paludis_repositories_e_include_HEADERS = \
visibility.hh \
whitespace.hh \
header.hh \
+ misc_files.hh \
files_dir_size.hh \
repo_name.hh
@@ -66,6 +67,7 @@ libpaludiserepositoryqa_la_SOURCES = \
visibility.cc \
whitespace.cc \
header.cc \
+ misc_files.cc \
files_dir_size.cc \
repo_name.cc \
$(paludis_repositories_e_include_HEADERS)
@@ -81,7 +83,9 @@ libpaludiserepositoryqa_la_LIBADD = \
dist_check_SCRIPTS = \
visibility_TEST_setup.sh \
- visibility_TEST_cleanup.sh
+ visibility_TEST_cleanup.sh \
+ misc_files_TEST_setup.sh \
+ misc_files_TEST_cleanup.sh
endif
@@ -115,7 +119,8 @@ TESTS = \
stray_files_TEST \
default_functions_TEST \
kv_variables_TEST \
- visibility_TEST
+ visibility_TEST \
+ misc_files_TEST
check_PROGRAMS = $(TESTS)
@@ -203,6 +208,18 @@ kv_variables_TEST_LDADD = \
$(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
$(top_builddir)/test/libtest.a
+misc_files_TEST_SOURCES = misc_files_TEST.cc
+misc_files_TEST_LDADD = \
+ libpaludiserepositoryqa.la \
+ test_extras.o \
+ $(top_builddir)/paludis/repositories/e/libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/test/libtest.a
+
endif
built-sources : $(BUILT_SOURCES)
diff --git a/paludis/repositories/e/qa/misc_files.cc b/paludis/repositories/e/qa/misc_files.cc
new file mode 100644
index 0000000..60b7857
--- /dev/null
+++ b/paludis/repositories/e/qa/misc_files.cc
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 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/qa/misc_files.hh>
+#include <paludis/qa.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+bool
+paludis::erepository::misc_files_check(
+ QAReporter & reporter,
+ const FSEntry & dir,
+ const std::string & name
+ )
+{
+ Context context("When performing check '" + name + "' using misc_files_check on directory '" + stringify(dir) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "misc_files_check '"
+ << dir << "', " << name << "'";
+
+ if (! (dir / "ChangeLog").is_regular_file())
+ reporter.message(QAMessage(dir / "ChangeLog", qaml_normal, name, "ChangeLog is missing or not a regular file"));
+
+ if (! (dir / "metadata.xml").is_regular_file())
+ reporter.message(QAMessage(dir / "metadata.xml", qaml_normal, name, "metadata.xml is missing or not a regular file"));
+
+ if ((dir / "files").exists() && ! (dir / "files").is_directory())
+ reporter.message(QAMessage(dir / "files", qaml_normal, name, "files/ exists but is not a directory"));
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/misc_files.hh b/paludis/repositories/e/qa/misc_files.hh
new file mode 100644
index 0000000..89ebf90
--- /dev/null
+++ b/paludis/repositories/e/qa/misc_files.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_MISC_FILES_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_MISC_FILES_HH 1
+
+#include <paludis/repositories/e/qa/qa_controller.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool misc_files_check(
+ QAReporter &,
+ const FSEntry & dir,
+ const std::string & s
+ ) PALUDIS_VISIBLE;
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/misc_files_TEST.cc b/paludis/repositories/e/qa/misc_files_TEST.cc
new file mode 100644
index 0000000..2df3086
--- /dev/null
+++ b/paludis/repositories/e/qa/misc_files_TEST.cc
@@ -0,0 +1,130 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006
+ *
+ * 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/qa/misc_files.hh>
+#include <paludis/qa.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+using namespace test;
+
+namespace
+{
+ struct TestReporter :
+ QAReporter
+ {
+ unsigned count;
+
+ TestReporter() :
+ count(0)
+ {
+ }
+
+ void message(const QAMessage &)
+ {
+ ++count;
+ }
+
+ void status(const std::string &)
+ {
+ }
+ };
+}
+
+namespace test_cases
+{
+ struct HasMiscFilesCheckTest : TestCase
+ {
+ HasMiscFilesCheckTest() : TestCase("has misc files") { }
+
+ void run()
+ {
+ FSEntry e("misc_files_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "yes");
+ TEST_CHECK(f1.exists());
+
+ TestReporter r;
+ TEST_CHECK(misc_files_check(r, f1, "misc_files"));
+ TEST_CHECK_EQUAL(r.count, 0u);
+ }
+ } test_has_misc_files_check;
+
+ struct HasMiscFilesCheckNoChangeLogTest : TestCase
+ {
+ HasMiscFilesCheckNoChangeLogTest() : TestCase("has misc files no ChangeLog") { }
+
+ void run()
+ {
+ FSEntry e("misc_files_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "no-changelog");
+ TEST_CHECK(f1.exists());
+
+ TestReporter r;
+ TEST_CHECK(misc_files_check(r, f1, "misc_files"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_has_misc_files_check_no_changelog;
+
+ struct HasMiscFilesCheckNoMetadataTest : TestCase
+ {
+ HasMiscFilesCheckNoMetadataTest() : TestCase("has misc files no metadata.xml") { }
+
+ void run()
+ {
+ FSEntry e("misc_files_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "no-metadata");
+ TEST_CHECK(f1.exists());
+
+ TestReporter r;
+ TEST_CHECK(misc_files_check(r, f1, "misc_files"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_has_misc_files_check_no_metadata;
+
+ struct HasMiscFilesCheckBadFilesTest : TestCase
+ {
+ HasMiscFilesCheckBadFilesTest() : TestCase("has misc files bad files/") { }
+
+ void run()
+ {
+ FSEntry e("misc_files_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "bad-files");
+ TEST_CHECK(f1.exists());
+
+ TestReporter r;
+ TEST_CHECK(misc_files_check(r, f1, "misc_files"));
+ TEST_CHECK_EQUAL(r.count, 1u);
+ }
+ } test_has_misc_files_check_bad_files;
+}
+
diff --git a/paludis/repositories/e/qa/misc_files_TEST_cleanup.sh b/paludis/repositories/e/qa/misc_files_TEST_cleanup.sh
new file mode 100755
index 0000000..41afeac
--- /dev/null
+++ b/paludis/repositories/e/qa/misc_files_TEST_cleanup.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d misc_files_TEST_dir ] ; then
+ rm -fr misc_files_TEST_dir
+else
+ true
+fi
+
+
+
+
diff --git a/paludis/repositories/e/qa/misc_files_TEST_setup.sh b/paludis/repositories/e/qa/misc_files_TEST_setup.sh
new file mode 100755
index 0000000..4a5486a
--- /dev/null
+++ b/paludis/repositories/e/qa/misc_files_TEST_setup.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir misc_files_TEST_dir || exit 2
+cd misc_files_TEST_dir || exit 3
+
+mkdir "cat" || exit 4
+
+mkdir "cat/yes" || exit 5
+touch "cat/yes/ChangeLog" "cat/yes/metadata.xml" || exit 6
+mkdir "cat/yes/files" || exit 7
+
+mkdir "cat/no-changelog" || exit 8
+touch "cat/no-changelog/metadata.xml" || exit 9
+mkdir "cat/no-changelog/files" || exit 10
+
+mkdir "cat/no-metadata" || exit 8
+touch "cat/no-metadata/ChangeLog" || exit 9
+mkdir "cat/no-metadata/files" || exit 10
+
+mkdir "cat/bad-files" || exit 11
+touch "cat/bad-files/metadata.xml" "cat/bad-files/ChangeLog" "cat/bad-files/files"|| exit 12
+
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index 1c4cd14..94fe17b 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -22,6 +22,7 @@
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/repositories/e/qa/stray_files.hh>
+#include <paludis/repositories/e/qa/misc_files.hh>
#include <paludis/repositories/e/qa/files_dir_size.hh>
#include <paludis/repositories/e/qa/eapi_supported.hh>
#include <paludis/repositories/e/qa/metadata_keys.hh>
@@ -78,6 +79,9 @@ QAChecks::QAChecks() :
_imp->category_dir_checks_group->add_check("stray_category_dir_files",
tr1::bind(stray_files_check, _2, _4, _1, is_stray_at_category_dir, "stray_category_dir_files"));
+ _imp->package_dir_checks_group->add_check("misc_files",
+ tr1::bind(misc_files_check, _2, _1, "misc_files"));
+
_imp->package_dir_checks_group->add_check("files_dir_size",
tr1::bind(files_dir_size_check, _2, _1, "files_dir_size"));