diff --git a/utils/check-package b/utils/check-package index 3741a2ccdc..872e66c126 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) @@ -288,6 +291,9 @@ def __main__(): global flags flags = parse_args() + if flags.test_suite: + return checkpackagelib.base.run_test_suite() + 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/base.py b/utils/checkpackagelib/base.py index f666e4110b..0ab6eba9f6 100644 --- a/utils/checkpackagelib/base.py +++ b/utils/checkpackagelib/base.py @@ -1,5 +1,6 @@ # See utils/checkpackagelib/readme.txt before editing this file. import re +import os class _CheckFunction(object): @@ -27,3 +28,11 @@ class _Tool(object): def hint(self): return "" + + +def run_test_suite(): + import pytest + return pytest.main( + # Disable writing/loading a cache with: -p no:cacheprovider + ["-v", "-p", "no:cacheprovider", os.path.dirname(__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