[Buildroot] [PATCH 03/16] utils/check-package: add option to run the test-suite

Yann E. MORIN yann.morin.1998 at free.fr
Sun Jun 2 20:39:39 UTC 2024


Currently, how to run the check-package test-suite is thoroughly under-
documented. There is one hint in the commit log for commit fc254881e6df
(utils/checkpackagelib: add unit tests), and another in commit
242e9d72e7d2 (utils/docker-run: new script); the former is hard to find,
and the latter is about an unrelated script, so harder yet to find...

Add a new option to check-package, that will make it run its test-suite.
Since pytest is only needed for the test-suite, only import it in that
case.

pytest will be default create a cache of the tests (not sure what it is
about, though), so instruct it not to (esp. since the tree can be
read-only).

Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
Cc: Ricardo Martincoski <ricardo.martincoski at datacom.com.br>
---
 utils/check-package              | 10 ++++++++++
 utils/checkpackagelib/readme.txt |  1 +
 2 files changed, 11 insertions(+)

diff --git a/utils/check-package b/utils/check-package
index cbb3613e19..f759d88a89 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -85,6 +85,9 @@ def parse_args():
     parser.add_argument("--failed-only", action="store_true", help="print only"
                         " the name of the functions that failed (debug)")
 
+    parser.add_argument("--test-suite", action="store_true", help="Run the"
+                        " test-suite")
+
     flags = parser.parse_args()
 
     flags.ignore_list = get_ignored_parsers_per_file(flags.intree_only, flags.ignore_filename)
@@ -287,6 +290,13 @@ def __main__():
     global flags
     flags = parse_args()
 
+    if flags.test_suite:
+        import pytest
+        return pytest.main(
+            # Disable writing/loading a cache with: -p no:cacheprovider
+            ["-v", "-p", "no:cacheprovider", os.path.dirname(__file__)]
+        )
+
     if flags.intree_only:
         # change all paths received to be relative to the base dir
         base_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
diff --git a/utils/checkpackagelib/readme.txt b/utils/checkpackagelib/readme.txt
index 3bfe289607..b3e8c67100 100644
--- a/utils/checkpackagelib/readme.txt
+++ b/utils/checkpackagelib/readme.txt
@@ -23,6 +23,7 @@ How the scripts are structured:
 - lib_type.py contains check functions specific to files of this type.
 
 Some hints when changing this code:
+- test your changes: utils/check-package --test-suite
 - prefer O(n) algorithms, where n is the total number of lines in the files
   processed.
 - when there is no other reason for ordering, use alphabetical order (e.g. keep
-- 
2.45.1



More information about the buildroot mailing list