aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 23:04:06 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 23:04:06 +0000
commit131b967adc985fb3c961fbd21f9f555172630f3f (patch)
treef3319ac275e89127af5b4ce02693b0da82fa4def
parent204660b4ce24c236f92e911c61e7ff557af29852 (diff)
downloadpaludis-131b967adc985fb3c961fbd21f9f555172630f3f.tar.gz
paludis-131b967adc985fb3c961fbd21f9f555172630f3f.tar.xz
QA checks: ChangeLog, files, metadata.xml should exist
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/has_misc_files_check.cc75
-rw-r--r--paludis/qa/has_misc_files_check.hh46
-rw-r--r--paludis/qa/has_misc_files_check_TEST.cc102
-rwxr-xr-xpaludis/qa/has_misc_files_check_TEST_cleanup.sh12
-rwxr-xr-xpaludis/qa/has_misc_files_check_TEST_setup.sh23
6 files changed, 259 insertions, 0 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index e264b87..d5987a8 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -14,6 +14,7 @@ add(`environment', `hh', `cc')
add(`file_check', `hh', `cc')
add(`file_permissions_check', `hh', `cc', `test', `testscript')
add(`has_ebuilds_check', `hh', `cc', `test', `testscript')
+add(`has_misc_files_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/has_misc_files_check.cc b/paludis/qa/has_misc_files_check.cc
new file mode 100644
index 0000000..a6e0de0
--- /dev/null
+++ b/paludis/qa/has_misc_files_check.cc
@@ -0,0 +1,75 @@
+/* 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 "has_misc_files_check.hh"
+#include <paludis/is_file_with_extension.hh>
+#include <paludis/dir_iterator.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+HasMiscFilesCheck::HasMiscFilesCheck()
+{
+}
+
+struct IsNamed :
+ std::unary_function<bool, FSEntry>
+{
+ const std::string name;
+
+ IsNamed(const std::string & n) :
+ name(n)
+ {
+ }
+
+ bool operator() (const FSEntry & f) const
+ {
+ return f.basename() == name;
+ }
+};
+
+CheckResult
+HasMiscFilesCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ if (DirIterator() == std::find_if(DirIterator(d), DirIterator(),
+ IsNamed("ChangeLog")))
+ result << Message(qal_major, "No ChangeLog found");
+
+ if (DirIterator() == std::find_if(DirIterator(d), DirIterator(),
+ IsNamed("files")))
+ result << Message(qal_major, "No files/ found");
+
+ if (DirIterator() == std::find_if(DirIterator(d), DirIterator(),
+ IsNamed("metadata.xml")))
+ result << Message(qal_major, "No metadata.xml found");
+
+ return result;
+}
+
+const std::string &
+HasMiscFilesCheck::identifier()
+{
+ static const std::string id("has misc files");
+ return id;
+}
+
+
diff --git a/paludis/qa/has_misc_files_check.hh b/paludis/qa/has_misc_files_check.hh
new file mode 100644
index 0000000..62d0f06
--- /dev/null
+++ b/paludis/qa/has_misc_files_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_HAS_MISC_FILES_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_HAS_MISC_FILES_CHECK_HH 1
+
+#include <paludis/qa/package_dir_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class HasMiscFilesCheck :
+ public PackageDirCheck
+ {
+ public:
+ HasMiscFilesCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_misc_files_check(
+ HasMiscFilesCheck::identifier(), &make_package_dir_check<HasMiscFilesCheck>);
+ }
+}
+
+#endif
diff --git a/paludis/qa/has_misc_files_check_TEST.cc b/paludis/qa/has_misc_files_check_TEST.cc
new file mode 100644
index 0000000..be8cac4
--- /dev/null
+++ b/paludis/qa/has_misc_files_check_TEST.cc
@@ -0,0 +1,102 @@
+/* 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 "has_misc_files_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 HasMiscFilesCheckTest : TestCase
+ {
+ HasMiscFilesCheckTest() : TestCase("has misc files") { }
+
+ void run()
+ {
+ FSEntry e("has_misc_files_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "yes");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker(
+ HasMiscFilesCheck::identifier()))())(f1));
+ TEST_CHECK(r1.empty());
+ }
+ } test_has_misc_files_check;
+
+ struct HasMiscFilesCheckNoChangeLogTest : TestCase
+ {
+ HasMiscFilesCheckNoChangeLogTest() : TestCase("has misc files no ChangeLog") { }
+
+ void run()
+ {
+ FSEntry e("has_misc_files_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "no-changelog");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker(
+ HasMiscFilesCheck::identifier()))())(f1));
+ TEST_CHECK(! r1.empty());
+ }
+ } test_has_misc_files_check_no_changelog;
+
+ struct HasMiscFilesCheckNoMetadataTest : TestCase
+ {
+ HasMiscFilesCheckNoMetadataTest() : TestCase("has misc files no metadata.xml") { }
+
+ void run()
+ {
+ FSEntry e("has_misc_files_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "no-metadata");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker(
+ HasMiscFilesCheck::identifier()))())(f1));
+ TEST_CHECK(! r1.empty());
+ }
+ } test_has_misc_files_check_no_metadata;
+
+ struct HasMiscFilesCheckNoFilesTest : TestCase
+ {
+ HasMiscFilesCheckNoFilesTest() : TestCase("has misc files no files/") { }
+
+ void run()
+ {
+ FSEntry e("has_misc_files_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "no-files");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker(
+ HasMiscFilesCheck::identifier()))())(f1));
+ TEST_CHECK(! r1.empty());
+ }
+ } test_has_misc_files_check_no_files;
+}
+
diff --git a/paludis/qa/has_misc_files_check_TEST_cleanup.sh b/paludis/qa/has_misc_files_check_TEST_cleanup.sh
new file mode 100755
index 0000000..d7655cc
--- /dev/null
+++ b/paludis/qa/has_misc_files_check_TEST_cleanup.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d has_misc_files_check_TEST_dir ] ; then
+ rm -fr has_misc_files_check_TEST_dir
+else
+ true
+fi
+
+
+
+
diff --git a/paludis/qa/has_misc_files_check_TEST_setup.sh b/paludis/qa/has_misc_files_check_TEST_setup.sh
new file mode 100755
index 0000000..b51a6b9
--- /dev/null
+++ b/paludis/qa/has_misc_files_check_TEST_setup.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir has_misc_files_check_TEST_dir || exit 2
+cd has_misc_files_check_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/no-files" || exit 11
+touch "cat/no-files/metadata.xml" "cat/no-files/ChangeLog" || exit 12
+