aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 20:58:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 20:58:08 +0000
commite277ec331fd127f4d48ed04f8bda2a2a3cb3d3ef (patch)
treec64cf1122b3d7368eb009b5cd6ae12fc00dd4236
parent0811663a6653bb9fcf3c94bc43cf0a104cfeaf02 (diff)
downloadpaludis-e277ec331fd127f4d48ed04f8bda2a2a3cb3d3ef.tar.gz
paludis-e277ec331fd127f4d48ed04f8bda2a2a3cb3d3ef.tar.xz
More QA checks
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/has_ebuilds_check.cc50
-rw-r--r--paludis/qa/has_ebuilds_check.hh46
-rw-r--r--paludis/qa/has_ebuilds_check_TEST.cc66
-rwxr-xr-xpaludis/qa/has_ebuilds_check_TEST_cleanup.sh11
-rwxr-xr-xpaludis/qa/has_ebuilds_check_TEST_setup.sh12
6 files changed, 186 insertions, 0 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 57fb5c8..e264b87 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -13,6 +13,7 @@ add(`check_result', `hh', `cc', `test')
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(`message', `hh', `cc', `test')
add(`package_dir_check', `hh', `cc')
add(`package_name_check', `hh', `cc', `test', `testscript')
diff --git a/paludis/qa/has_ebuilds_check.cc b/paludis/qa/has_ebuilds_check.cc
new file mode 100644
index 0000000..ec899a6
--- /dev/null
+++ b/paludis/qa/has_ebuilds_check.cc
@@ -0,0 +1,50 @@
+/* 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_ebuilds_check.hh"
+#include <paludis/is_file_with_extension.hh>
+#include <paludis/dir_iterator.hh>
+#include <algorithm>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+HasEbuildsCheck::HasEbuildsCheck()
+{
+}
+
+CheckResult
+HasEbuildsCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ if (DirIterator() == std::find_if(DirIterator(d), DirIterator(),
+ IsFileWithExtension(d.basename() + "-", ".ebuild")))
+ result << Message(qal_fatal, "No ebuilds found");
+
+ return result;
+}
+
+const std::string &
+HasEbuildsCheck::identifier()
+{
+ static const std::string id("has ebuilds");
+ return id;
+}
+
diff --git a/paludis/qa/has_ebuilds_check.hh b/paludis/qa/has_ebuilds_check.hh
new file mode 100644
index 0000000..e32d6c3
--- /dev/null
+++ b/paludis/qa/has_ebuilds_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_EBUILDS_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_HAS_EBUILDS_CHECK_HH 1
+
+#include <paludis/qa/package_dir_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class HasEbuildsCheck :
+ public PackageDirCheck
+ {
+ public:
+ HasEbuildsCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_has_ebuilds_check(
+ HasEbuildsCheck::identifier(), &make_package_dir_check<HasEbuildsCheck>);
+ }
+}
+
+#endif
diff --git a/paludis/qa/has_ebuilds_check_TEST.cc b/paludis/qa/has_ebuilds_check_TEST.cc
new file mode 100644
index 0000000..e38bc45
--- /dev/null
+++ b/paludis/qa/has_ebuilds_check_TEST.cc
@@ -0,0 +1,66 @@
+/* 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_ebuilds_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 HasEbuildsCheckTest : TestCase
+ {
+ HasEbuildsCheckTest() : TestCase("has ebuilds") { }
+
+ void run()
+ {
+ FSEntry e("has_ebuilds_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(
+ HasEbuildsCheck::identifier()))())(f1));
+ TEST_CHECK(r1.empty());
+ }
+ } test_has_ebuilds_check;
+
+ struct HasNoEbuildsCheckTest : TestCase
+ {
+ HasNoEbuildsCheckTest() : TestCase("has no ebuilds") { }
+
+ void run()
+ {
+ FSEntry e("has_ebuilds_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "cat" / "no");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker(
+ HasEbuildsCheck::identifier()))())(f1));
+ TEST_CHECK(! r1.empty());
+ }
+ } test_has_no_ebuilds_check;
+}
+
diff --git a/paludis/qa/has_ebuilds_check_TEST_cleanup.sh b/paludis/qa/has_ebuilds_check_TEST_cleanup.sh
new file mode 100755
index 0000000..c32937f
--- /dev/null
+++ b/paludis/qa/has_ebuilds_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d has_ebuilds_check_TEST_dir ] ; then
+ rm -fr has_ebuilds_check_TEST_dir
+else
+ true
+fi
+
+
+
diff --git a/paludis/qa/has_ebuilds_check_TEST_setup.sh b/paludis/qa/has_ebuilds_check_TEST_setup.sh
new file mode 100755
index 0000000..3f4c6a3
--- /dev/null
+++ b/paludis/qa/has_ebuilds_check_TEST_setup.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir has_ebuilds_check_TEST_dir || exit 2
+cd has_ebuilds_check_TEST_dir || exit 3
+
+mkdir "cat" || exit 4
+mkdir "cat/yes" || exit 5
+mkdir "cat/no" || exit 6
+
+touch "cat/yes/yes-1.ebuild" || exit 7
+