[namcap,4/4] nonuniquesources: Add test for common filenames

Message ID 20190527034922.27316-5-jamespharvey20@gmail.com
State New
Headers show
Series
  • Add a rule against common filenames in source() without overridden name
Related show

Commit Message

Eli Schwartz via arch-projects May 27, 2019, 3:49 a.m. UTC
Signed-off-by: James P. Harvey <jamespharvey20@gmail.com>
---
 .../tests/pkgbuild/test_nonuniquesources.py   | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

Patch

diff --git a/Namcap/tests/pkgbuild/test_nonuniquesources.py b/Namcap/tests/pkgbuild/test_nonuniquesources.py
index 1c6d75c..b8f3542 100644
--- a/Namcap/tests/pkgbuild/test_nonuniquesources.py
+++ b/Namcap/tests/pkgbuild/test_nonuniquesources.py
@@ -55,4 +55,40 @@  package() {
 		self.assertEqual(r.warnings, [("non-unique-source-name %s", "v1.2.3.tar.gz")])
 		self.assertEqual(r.infos, [])
 
+	def test_common_unique(self):
+		r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' '${pkgname}-LICENSE::LICENSE.txt')")
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings, [])
+		self.assertEqual(r.infos, [])
+
+	def test_common_repo_non_unique(self):
+		r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'LICENSE')")
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings, [("non-unique-source-name %s", "LICENSE")])
+		self.assertEqual(r.infos, [])
+
+	def test_common_repo_part_unique(self):
+		r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'LICENSE-pkgname.txt')")
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings, [])
+		self.assertEqual(r.infos, [])
+
+	def test_common_repo_part_non_unique(self):
+		r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'LICENSE.txt')")
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings, [("non-unique-source-name %s", "LICENSE.txt")])
+		self.assertEqual(r.infos, [])
+
+	def test_common_external_non_unique(self):
+		r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'ftp://example.com/LICENSE.txt')")
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings, [("non-unique-source-name %s", "LICENSE.txt")])
+		self.assertEqual(r.infos, [])
+
+	def test_common_case_insensitive(self):
+		r = self.run_on_pkg(self.pkgbuild_no_source + "source=('pkgname.tar.xz' 'ftp://example.com/license.txt')")
+		self.assertEqual(r.errors, [])
+		self.assertEqual(r.warnings, [("non-unique-source-name %s", "license.txt")])
+		self.assertEqual(r.infos, [])
+
 # vim: set ts=4 sw=4 noet: