diff --git a/support/testing/tests/utils/br2-external/.checkpackageignore b/support/testing/tests/utils/br2-external/.checkpackageignore new file mode 100644 index 0000000000..efb7680173 --- /dev/null +++ b/support/testing/tests/utils/br2-external/.checkpackageignore @@ -0,0 +1 @@ +package/external/external.mk PackageHeader diff --git a/support/testing/tests/utils/br2-external/package/.checkpackageignore b/support/testing/tests/utils/br2-external/package/.checkpackageignore new file mode 100644 index 0000000000..5f4a5e1187 --- /dev/null +++ b/support/testing/tests/utils/br2-external/package/.checkpackageignore @@ -0,0 +1 @@ +external/external.mk PackageHeader diff --git a/support/testing/tests/utils/br2-external/package/.checkpackageignore_outdated b/support/testing/tests/utils/br2-external/package/.checkpackageignore_outdated new file mode 100644 index 0000000000..1df59f3bed --- /dev/null +++ b/support/testing/tests/utils/br2-external/package/.checkpackageignore_outdated @@ -0,0 +1 @@ +external/external.mk Indent NewlineAtEof PackageHeader diff --git a/support/testing/tests/utils/test_check_package.py b/support/testing/tests/utils/test_check_package.py index c70ba02324..ce1998753c 100644 --- a/support/testing/tests/utils/test_check_package.py +++ b/support/testing/tests/utils/test_check_package.py @@ -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)