aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-04-22 11:02:08 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-04-22 11:02:08 +0000
commitf6ef28c04ac439c4b168418f1a6cb7bb9451cae2 (patch)
treeb16b96b03ba7ec86b7d466d4180712a3f3519fdc
parent7d19dd0a1b236789662c51875e343cab18f5dd0f (diff)
downloadpaludis-f6ef28c04ac439c4b168418f1a6cb7bb9451cae2.tar.gz
paludis-f6ef28c04ac439c4b168418f1a6cb7bb9451cae2.tar.xz
Add EbuildNameCheck.
-rw-r--r--TODO2
-rw-r--r--paludis/qa/ebuild_name_check.cc47
-rw-r--r--paludis/qa/ebuild_name_check.hh58
-rw-r--r--paludis/qa/ebuild_name_check_TEST.cc76
-rwxr-xr-xpaludis/qa/ebuild_name_check_TEST_cleanup.sh11
-rwxr-xr-xpaludis/qa/ebuild_name_check_TEST_setup.sh11
-rw-r--r--paludis/qa/file_check.cc2
-rw-r--r--paludis/qa/files.m41
8 files changed, 206 insertions, 2 deletions
diff --git a/TODO b/TODO
index 18c2b7c..3d8b8f6 100644
--- a/TODO
+++ b/TODO
@@ -36,8 +36,6 @@ Assigned to: <nobody>
Missing counterparts for
- * "ebuild.namenomatch":"Ebuild files that do not have the same name as their parent directory"
-
* "ebuild.output":"A simple sourcing of the ebuild produces output; this breaks ebuild policy."
* "LIVEVCS.stable":"This ebuild is a live checkout from a VCS but has stable keywords."
diff --git a/paludis/qa/ebuild_name_check.cc b/paludis/qa/ebuild_name_check.cc
new file mode 100644
index 0000000..1198c06
--- /dev/null
+++ b/paludis/qa/ebuild_name_check.cc
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Richard Brown <rbrown@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 <paludis/name.hh>
+#include <paludis/qa/ebuild_name_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+EbuildNameCheck::EbuildNameCheck()
+{
+}
+
+CheckResult
+EbuildNameCheck::operator() (const FSEntry & f) const
+{
+ CheckResult result(f, identifier());
+
+ if (stringify(f.dirname().basename()) != stringify(f.basename()).substr(0,stringify(f.dirname().basename()).length()))
+ result << Message(qal_fatal, "Ebuild name does not match directory name");
+
+ return result;
+}
+
+const std::string &
+EbuildNameCheck::identifier()
+{
+ static const std::string id("ebuild_name");
+ return id;
+}
+
diff --git a/paludis/qa/ebuild_name_check.hh b/paludis/qa/ebuild_name_check.hh
new file mode 100644
index 0000000..9035173
--- /dev/null
+++ b/paludis/qa/ebuild_name_check.hh
@@ -0,0 +1,58 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Richard Brown <rbrown@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_EBUILD_NAME_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_NAME_CHECK_HH 1
+
+#include <paludis/qa/file_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * QA check: ebuild name matches directory
+ *
+ * \ingroup grpqacheck
+ */
+ class EbuildNameCheck :
+ public FileCheck
+ {
+ public:
+ EbuildNameCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that ebuild names matches the directory name";
+ }
+
+ virtual bool is_important() const
+ {
+ return true;
+ }
+ };
+ }
+}
+
+#endif
diff --git a/paludis/qa/ebuild_name_check_TEST.cc b/paludis/qa/ebuild_name_check_TEST.cc
new file mode 100644
index 0000000..45328d3
--- /dev/null
+++ b/paludis/qa/ebuild_name_check_TEST.cc
@@ -0,0 +1,76 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Richard Brown <rbrown@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 <paludis/qa/ebuild_name_check.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+using namespace test;
+
+namespace test_cases
+{
+ struct EbuildNameCheckValidTest : TestCase
+ {
+ EbuildNameCheckValidTest() : TestCase("ebuild name check valid") { }
+
+ void run()
+ {
+ FSEntry e("ebuild_name_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "valid-cat" / "valid-pkg");
+ TEST_CHECK(f1.exists());
+ TEST_CHECK(f1.is_directory());
+
+ FSEntry f2(e / "valid-cat" / "valid-pkg" / "valid-pkg-0.ebuild");
+ TEST_CHECK(f2.exists());
+
+ CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker(
+ EbuildNameCheck::identifier()))())(f2));
+ TEST_CHECK(r1.empty());
+ }
+ } test_ebuild_name_check_valid;
+
+ struct EbuildNameCheckInvalidTest : TestCase
+ {
+ EbuildNameCheckInvalidTest() : TestCase("ebuild name check invalid") { }
+
+ void run()
+ {
+ FSEntry e("ebuild_name_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "valid-cat" / "valid-pkg");
+ TEST_CHECK(f1.exists());
+ TEST_CHECK(f1.is_directory());
+
+ FSEntry f2(e / "valid-cat" / "valid-pkg" / "invalid-pkg-0.ebuild");
+ TEST_CHECK(f2.exists());
+
+ CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker(
+ EbuildNameCheck::identifier()))())(f2));
+ TEST_CHECK(! r1.empty());
+ }
+ } test_ebuild_name_check_invalid;
+
+}
diff --git a/paludis/qa/ebuild_name_check_TEST_cleanup.sh b/paludis/qa/ebuild_name_check_TEST_cleanup.sh
new file mode 100755
index 0000000..e76d99f
--- /dev/null
+++ b/paludis/qa/ebuild_name_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d ebuild_name_check_TEST_dir ] ; then
+ rm -fr ebuild_name_check_TEST_dir
+else
+ true
+fi
+
+
+
diff --git a/paludis/qa/ebuild_name_check_TEST_setup.sh b/paludis/qa/ebuild_name_check_TEST_setup.sh
new file mode 100755
index 0000000..914809b
--- /dev/null
+++ b/paludis/qa/ebuild_name_check_TEST_setup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir ebuild_name_check_TEST_dir || exit 2
+cd ebuild_name_check_TEST_dir || exit 3
+
+mkdir "valid-cat" || exit 4
+mkdir "valid-cat/valid-pkg" || exit 5
+touch "valid-cat/valid-pkg/valid-pkg-0.ebuild" || exit 6
+touch "valid-cat/valid-pkg/invalid-pkg-0.ebuild" || exit 7
+
diff --git a/paludis/qa/file_check.cc b/paludis/qa/file_check.cc
index 87a64a9..82b1d3e 100644
--- a/paludis/qa/file_check.cc
+++ b/paludis/qa/file_check.cc
@@ -22,6 +22,7 @@
#include <paludis/qa/changelog_check.hh>
#include <paludis/qa/defaults_check.hh>
#include <paludis/qa/deprecated_functions_check.hh>
+#include <paludis/qa/ebuild_name_check.hh>
#include <paludis/qa/filename_check.hh>
#include <paludis/qa/file_permissions_check.hh>
#include <paludis/qa/function_check.hh>
@@ -56,6 +57,7 @@ FileCheckMaker::FileCheckMaker()
register_maker(ChangeLogCheck::identifier(), &MakeFileCheck<ChangeLogCheck>::make_file_check);
register_maker(DefaultsCheck::identifier(), &MakeFileCheck<DefaultsCheck>::make_file_check);
register_maker(DeprecatedFunctionsCheck::identifier(), &MakeFileCheck<DeprecatedFunctionsCheck>::make_file_check);
+ register_maker(EbuildNameCheck::identifier(), &MakeFileCheck<EbuildNameCheck>::make_file_check);
register_maker(FileNameCheck::identifier(), &MakeFileCheck<FileNameCheck>::make_file_check);
register_maker(FilePermissionsCheck::identifier(), &MakeFileCheck<FilePermissionsCheck>::make_file_check);
register_maker(FunctionCheck::identifier(), &MakeFileCheck<FunctionCheck>::make_file_check);
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 37c2596..d1536bf 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -26,6 +26,7 @@ add(`description_check', `hh', `cc')
add(`digest_collisions_check', `hh', `cc')
add(`ebuild_check', `hh', `cc', `sr')
add(`ebuild_count_check', `hh', `cc')
+add(`ebuild_name_check', `hh', `cc', `test', `testscript')
add(`extract_check', `hh', `cc')
add(`file_check', `hh', `cc')
add(`filename_check', `hh', `cc')