فهرست منبع

utils/check-package: check ignored files exist

When an ignored file is removed (e.g. a package patch is no longer
needed after a version bump), the corresponding entry in the ignore list
is no longer needed.

However, we currently only validate that an ignored *test* still fails,
not that a ignore files is now missing.

Add a new test to check-package that does that check, and add a
test-case for that check.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
(cherry picked from commit 5eac4f81eb1cfaf6bd8d07a5d78a48de28ae8e4c)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Yann E. MORIN 2 سال پیش
والد
کامیت
a23eee38f7
3فایلهای تغییر یافته به همراه36 افزوده شده و 0 حذف شده
  1. 4 0
      utils/check-package
  2. 14 0
      utils/checkpackagelib/lib_ignore.py
  3. 18 0
      utils/checkpackagelib/test_lib_ignore.py

+ 4 - 0
utils/check-package

@@ -11,6 +11,7 @@ import sys
 import checkpackagelib.base
 import checkpackagelib.lib_config
 import checkpackagelib.lib_hash
+import checkpackagelib.lib_ignore
 import checkpackagelib.lib_mk
 import checkpackagelib.lib_patch
 import checkpackagelib.lib_shellscript
@@ -104,6 +105,7 @@ def get_lib_from_filetype(fname):
 
 CONFIG_IN_FILENAME = re.compile(r"Config\.\S*$")
 DO_CHECK_INTREE = re.compile(r"|".join([
+    r".checkpackageignore",
     r"Config.in",
     r"arch/",
     r"boot/",
@@ -136,6 +138,8 @@ def get_lib_from_filename(fname):
         if os.path.basename(fname) == "external.mk" and \
            os.path.exists(fname[:-2] + "desc"):
             return None
+    if fname == ".checkpackageignore":
+        return checkpackagelib.lib_ignore
     if CONFIG_IN_FILENAME.search(fname):
         return checkpackagelib.lib_config
     if fname.endswith(".hash"):

+ 14 - 0
utils/checkpackagelib/lib_ignore.py

@@ -0,0 +1,14 @@
+# See utils/checkpackagelib/readme.txt before editing this file.
+
+import os
+
+from checkpackagelib.base import _CheckFunction
+
+
+class IgnoreMissingFile(_CheckFunction):
+    def check_line(self, lineno, text):
+        fields = text.split()
+        if not os.path.exists(fields[0]):
+            return ["{}:{}: ignored file {} is missing"
+                    .format(self.filename, lineno, fields[0]),
+                    text]

+ 18 - 0
utils/checkpackagelib/test_lib_ignore.py

@@ -0,0 +1,18 @@
+import pytest
+import checkpackagelib.test_util as util
+import checkpackagelib.lib_ignore as m
+
+
+IgnoreMissingFile = [
+    ('missing ignored file',
+     '.checkpackageignore',
+     'this-file-does-not-exist SomeTest',
+     [['.checkpackageignore:1: ignored file this-file-does-not-exist is missing',
+       'this-file-does-not-exist SomeTest']]),
+    ]
+
+
+@pytest.mark.parametrize('testname,filename,string,expected', IgnoreMissingFile)
+def test_IgnoreMissingFile(testname, filename, string, expected):
+    warnings = util.check_file(m.IgnoreMissingFile, filename, string)
+    assert warnings == expected