support/testing: test check-package ignore list
Extend test_check_package to also check the ignore list functionality. Check: - the entries in the ignore list use relative path; - an entry in the ignore list actually ignores the warning; - an outdated entry in the ignore list generates a warning by its own, preventing the ignoring list to grow indefinitely. For this to work, add 3 test fixtures, listing entries for an pre-existing file in the br2-external used in the test. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
parent
ddf4586b00
commit
d631615eb1
@ -0,0 +1 @@
|
||||
package/external/external.mk PackageHeader
|
@ -0,0 +1 @@
|
||||
external/external.mk PackageHeader
|
@ -0,0 +1 @@
|
||||
external/external.mk Indent NewlineAtEof PackageHeader
|
@ -75,6 +75,12 @@ class TestCheckPackage(unittest.TestCase):
|
||||
generated = int(stderr[1].split()[0])
|
||||
self.assertGreater(generated, 0)
|
||||
|
||||
def assert_no_warnings_generated_for_file(self, stderr):
|
||||
"""Infer from check-package stderr if no warning was generated and fail otherwise."""
|
||||
self.assertIn("warnings generated", stderr[1], stderr)
|
||||
generated = int(stderr[1].split()[0])
|
||||
self.assertEqual(generated, 0)
|
||||
|
||||
def test_run(self):
|
||||
"""Test the various ways the script can be called in a simple top to
|
||||
bottom sequence."""
|
||||
@ -201,3 +207,28 @@ class TestCheckPackage(unittest.TestCase):
|
||||
self.assert_file_was_processed(m)
|
||||
self.assert_warnings_generated_for_file(m)
|
||||
self.assertIn("{}:1: should be 80 hashes (http://nightly.buildroot.org/#writing-rules-mk)".format(abs_file), w)
|
||||
|
||||
# br2-external with ignore list
|
||||
topdir_path = infra.filepath("tests/utils/br2-external")
|
||||
topdir_file = os.path.join(topdir_path, "package/external/external.mk")
|
||||
subdir_path = infra.filepath("tests/utils/br2-external/package")
|
||||
subdir_file = os.path.join(subdir_path, "external/external.mk")
|
||||
|
||||
w, m = call_script(["check-package", "--ignore-list=.checkpackageignore", "-b", topdir_file],
|
||||
self.WITH_UTILS_IN_PATH, topdir_path)
|
||||
self.assert_file_was_processed(m)
|
||||
self.assert_no_warnings_generated_for_file(m)
|
||||
|
||||
w, m = call_script(["check-package", "--ignore-list=.checkpackageignore", "-b", subdir_file],
|
||||
self.WITH_UTILS_IN_PATH, subdir_path)
|
||||
self.assert_file_was_processed(m)
|
||||
self.assert_no_warnings_generated_for_file(m)
|
||||
|
||||
w, m = call_script(["check-package", "--ignore-list=.checkpackageignore_outdated", "-b", subdir_file],
|
||||
self.WITH_UTILS_IN_PATH, subdir_path)
|
||||
self.assert_file_was_processed(m)
|
||||
self.assert_warnings_generated_for_file(m)
|
||||
self.assertIn("{}:0: Indent was expected to fail, did you fixed the file and forgot to update .checkpackageignore_outdated?"
|
||||
.format(subdir_file), w)
|
||||
self.assertIn("{}:0: NewlineAtEof was expected to fail, did you fixed the file and forgot to update .checkpackageignore_outdated?"
|
||||
.format(subdir_file), w)
|
||||
|
Loading…
Reference in New Issue
Block a user