Discussion:
[arch-projects] [namcap] [PATCH] Add test for makepkgfunctions rule
Michael Straube via arch-projects
2018-11-02 19:04:22 UTC
Permalink
Signed-off-by: Michael Straube <***@posteo.de>
---
.../tests/pkgbuild/test_makepkgfunctions.py | 67 +++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 Namcap/tests/pkgbuild/test_makepkgfunctions.py

diff --git a/Namcap/tests/pkgbuild/test_makepkgfunctions.py b/Namcap/tests/pkgbuild/test_makepkgfunctions.py
new file mode 100644
index 0000000..ac2601c
--- /dev/null
+++ b/Namcap/tests/pkgbuild/test_makepkgfunctions.py
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+#
+# namcap tests - makepkgfunctions
+# Copyright (C) 2011 Rémy Oudompheng <***@archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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
+#
+
+from Namcap.tests.pkgbuild_test import PkgbuildTest
+import Namcap.rules.makepkgfunctions as module
+
+class NamcapMakepkgfunctionsTest(PkgbuildTest):
+ pkgbuild1 = """
+# Maintainer: Arch Linux <***@example.com>
+# Contributor: Arch Linux <***@example.com>
+
+pkgname=mypackage
+pkgver=1.0
+pkgrel=1
+pkgdesc="A package"
+arch=('i686' 'x86_64')
+url="http://www.example.com/"
+license=('GPL')
+depends=('glibc')
+options=('!libtool')
+source=(ftp://ftp.example.com/pub/mypackage-0.1.tar.gz)
+md5sums=('abcdefabcdef12345678901234567890')
+
+build() {
+ msg "some text"
+ msg2 "some text"
+ warning "some text"
+ error "some text"
+ plain "some text"
+}
+
+package() {
+ true
+}
+"""
+ test_valid = PkgbuildTest.valid_tests
+
+ def preSetUp(self):
+ self.rule = module.package
+
+ def test_example1(self):
+ bad_calls = ['msg', 'msg2', 'warning', 'error', 'plain']
+ r = self.run_on_pkg(self.pkgbuild1)
+ self.assertEqual(r.errors, [])
+ self.assertEqual(set(r.warnings),
+ set(("makepkg-function-used %s", i) for i in bad_calls))
+ self.assertEqual(r.infos, [])
+
+# vim: set ts=4 sw=4 noet:
--
2.19.1
Loading...