aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 20:38:41 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 20:38:41 +0000
commit0811663a6653bb9fcf3c94bc43cf0a104cfeaf02 (patch)
tree23fd27c3a2dfd42b14bb4399e676d337484a57ef
parent741ba7d4c1150ab8cb05b37234908834eff0f487 (diff)
downloadpaludis-0811663a6653bb9fcf3c94bc43cf0a104cfeaf02.tar.gz
paludis-0811663a6653bb9fcf3c94bc43cf0a104cfeaf02.tar.xz
More QA checks
-rw-r--r--paludis/qa/file_check.hh2
-rw-r--r--paludis/qa/files.m42
-rw-r--r--paludis/qa/package_dir_check.cc33
-rw-r--r--paludis/qa/package_dir_check.hh76
-rw-r--r--paludis/qa/package_name_check.cc62
-rw-r--r--paludis/qa/package_name_check.hh46
-rwxr-xr-xpaludis/qa/package_name_check_TEST_cleanup.sh11
-rwxr-xr-xpaludis/qa/package_name_check_TEST_setup.sh14
8 files changed, 245 insertions, 1 deletions
diff --git a/paludis/qa/file_check.hh b/paludis/qa/file_check.hh
index a2faaa9..f1a9dac 100644
--- a/paludis/qa/file_check.hh
+++ b/paludis/qa/file_check.hh
@@ -28,7 +28,7 @@
#include <paludis/qa/check_result.hh>
/** \file
- * Declarations for the FIleCheck class.
+ * Declarations for the FileCheck class.
*
* \ingroup QA
*/
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index e96fd3e..57fb5c8 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -14,3 +14,5 @@ add(`environment', `hh', `cc')
add(`file_check', `hh', `cc')
add(`file_permissions_check', `hh', `cc', `test', `testscript')
add(`message', `hh', `cc', `test')
+add(`package_dir_check', `hh', `cc')
+add(`package_name_check', `hh', `cc', `test', `testscript')
diff --git a/paludis/qa/package_dir_check.cc b/paludis/qa/package_dir_check.cc
new file mode 100644
index 0000000..5c0c179
--- /dev/null
+++ b/paludis/qa/package_dir_check.cc
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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 "package_dir_check.hh"
+
+using namespace paludis;
+using namespace paludis::qa;
+
+PackageDirCheck::PackageDirCheck()
+{
+}
+
+NoSuchPackageDirCheckTypeError::NoSuchPackageDirCheckTypeError(const std::string & s) throw () :
+ Exception("No such file check type: '" + s + "'")
+{
+}
+
diff --git a/paludis/qa/package_dir_check.hh b/paludis/qa/package_dir_check.hh
new file mode 100644
index 0000000..8baacef
--- /dev/null
+++ b/paludis/qa/package_dir_check.hh
@@ -0,0 +1,76 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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_QA_PACKAGE_DIR_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_PACKAGE_DIR_CHECK_HH 1
+
+#include <paludis/exception.hh>
+#include <paludis/fs_entry.hh>
+#include <paludis/counted_ptr.hh>
+#include <paludis/virtual_constructor.hh>
+#include <paludis/qa/check.hh>
+#include <paludis/qa/check_result.hh>
+
+/** \file
+ * Declarations for the PackageDirCheck class.
+ *
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * A QA check that operates upon a package directory.
+ *
+ * \ingroup QA
+ */
+ class PackageDirCheck :
+ public Check,
+ public InternalCounted<PackageDirCheck>
+ {
+ protected:
+ PackageDirCheck();
+
+ public:
+ virtual CheckResult operator() (const FSEntry &) const = 0;
+ };
+
+ class NoSuchPackageDirCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchPackageDirCheckTypeError(const std::string &) throw ();
+ };
+
+ template <typename T_>
+ PackageDirCheck::Pointer
+ make_package_dir_check()
+ {
+ return PackageDirCheck::Pointer(new T_);
+ }
+
+ typedef VirtualConstructor<
+ std::string,
+ PackageDirCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> > PackageDirCheckMaker;
+ }
+}
+#endif
diff --git a/paludis/qa/package_name_check.cc b/paludis/qa/package_name_check.cc
new file mode 100644
index 0000000..9d0c272
--- /dev/null
+++ b/paludis/qa/package_name_check.cc
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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 "package_name_check.hh"
+#include <paludis/qualified_package_name.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+PackageNameCheck::PackageNameCheck()
+{
+}
+
+CheckResult
+PackageNameCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ try
+ {
+ CategoryNamePart c(d.dirname().basename());
+ }
+ catch (const NameError &)
+ {
+ result << Message(qal_fatal, "Invalid category");
+ }
+
+ try
+ {
+ PackageNamePart p(d.basename());
+ }
+ catch (const NameError &)
+ {
+ result << Message(qal_fatal, "Invalid package");
+ }
+
+ return result;
+}
+
+const std::string &
+PackageNameCheck::identifier()
+{
+ static const std::string id("package name");
+ return id;
+}
+
diff --git a/paludis/qa/package_name_check.hh b/paludis/qa/package_name_check.hh
new file mode 100644
index 0000000..d74fa56
--- /dev/null
+++ b/paludis/qa/package_name_check.hh
@@ -0,0 +1,46 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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_QA_PACKAGE_NAME_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_PACKAGE_NAME_CHECK_HH 1
+
+#include <paludis/qa/package_dir_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class PackageNameCheck :
+ public PackageDirCheck
+ {
+ public:
+ PackageNameCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_package_name_check(
+ PackageNameCheck::identifier(), &make_package_dir_check<PackageNameCheck>);
+ }
+}
+
+#endif
diff --git a/paludis/qa/package_name_check_TEST_cleanup.sh b/paludis/qa/package_name_check_TEST_cleanup.sh
new file mode 100755
index 0000000..4da131e
--- /dev/null
+++ b/paludis/qa/package_name_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d package_name_check_TEST_dir ] ; then
+ rm -fr package_name_check_TEST_dir
+else
+ true
+fi
+
+
+
diff --git a/paludis/qa/package_name_check_TEST_setup.sh b/paludis/qa/package_name_check_TEST_setup.sh
new file mode 100755
index 0000000..1fd3df7
--- /dev/null
+++ b/paludis/qa/package_name_check_TEST_setup.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir package_name_check_TEST_dir || exit 2
+cd package_name_check_TEST_dir || exit 3
+
+mkdir "valid-cat" || exit 4
+mkdir "valid-cat/valid-pkg" || exit 5
+mkdir "valid-cat/invalid-pkg..." || exit 6
+
+mkdir "invalid-cat..." || exit 7
+mkdir "invalid-cat.../valid-pkg" || exit 8
+mkdir "invalid-cat.../invalid-pkg..." || exit 9
+