[namcap,v2,2/3] Add test for the makedepends rule

Message ID 20181125145241.10889-2-michael.straube@posteo.de
State Accepted, archived
Headers show
Series [namcap,v2,1/3] Warn about makedepends already in depends | expand

Commit Message

Emil Velikov via arch-projects Nov. 25, 2018, 2:52 p.m. UTC
Signed-off-by: Michael Straube <michael.straube@posteo.de>
---
 Namcap/tests/pkgbuild/test_makedepends.py | 65 +++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Namcap/tests/pkgbuild/test_makedepends.py

Patch

diff --git a/Namcap/tests/pkgbuild/test_makedepends.py b/Namcap/tests/pkgbuild/test_makedepends.py
new file mode 100644
index 0000000..c8d6e97
--- /dev/null
+++ b/Namcap/tests/pkgbuild/test_makedepends.py
@@ -0,0 +1,65 @@ 
+# -*- coding: utf-8 -*-
+#
+# namcap tests - makedepends
+# Copyright (C) 2011 Rémy Oudompheng <remy@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.makedepends as module
+
+class NamcapRedundantMakedependsTest(PkgbuildTest):
+	pkgbuild1 = """
+# Maintainer: Arch Linux <archlinux@example.com>
+# Contributor: Arch Linux <archlinux@example.com>
+
+pkgname=mypackage
+pkgver=1.0
+pkgrel=1
+pkgdesc="A package"
+url="http://www.example.com/"
+arch=('i686' 'x86_64')
+depends=('lib1' 'lib2' 'lib3')
+makedepends=('lib1' 'lib2' 'lib4')
+license=('GPL')
+options=('!libtool')
+source=(ftp://ftp.example.com/pub/mypackage-0.1.tar.gz)
+md5sums=('abcdefabcdef12345678901234567890')
+
+build() {
+  true
+}
+
+package() {
+  true
+}
+"""
+
+	test_valid = PkgbuildTest.valid_tests
+
+	def preSetUp(self):
+		self.rule = module.RedundantMakedepends
+
+	def test_example1(self):
+		# Example 1
+		r = self.run_on_pkg(self.pkgbuild1)
+		self.assertEqual(r.errors, [])
+		self.assertEqual(set(r.warnings),
+			set(("redundant-makedep %s", i) for i in ["lib1" ,"lib2"]))
+		self.assertEqual(r.infos, [])
+
+# vim: set ts=4 sw=4 noet: