diff options
author | Ganesh Kathiresan <ganesh3597@gmail.com> | 2021-02-22 21:46:24 +0530 |
---|---|---|
committer | Ganesh Kathiresan <ganesh3597@gmail.com> | 2021-03-07 11:18:24 +0530 |
commit | 11cfa1c942ce2ed3d0e08ab50eb1612bb51ec60e (patch) | |
tree | a061341052f84ef072f3745e4aecf0c127571baa /runtests.py | |
parent | 6464b4bfd650f6033b2933b6857075dd27e270d5 (diff) | |
download | numpy-11cfa1c942ce2ed3d0e08ab50eb1612bb51ec60e.tar.gz |
ENH, MAINT: Added runtest options | Added unified diff
Diffstat (limited to 'runtests.py')
-rwxr-xr-x | runtests.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/runtests.py b/runtests.py index 4c9493a35..68a52115b 100755 --- a/runtests.py +++ b/runtests.py @@ -28,6 +28,12 @@ Generate C code coverage listing under build/lcov/: $ python runtests.py --gcov [...other args...] $ python runtests.py --lcov-html +Run lint checks. +Provide target branch name or `uncommitted` to check before committing: + + $ python runtests.py --lint master + $ python runtests.py --lint uncommitted + """ # # This is a generic test runner script for projects using NumPy's test @@ -84,6 +90,10 @@ def main(argv): parser.add_argument("--coverage", action="store_true", default=False, help=("report coverage of project code. HTML output goes " "under build/coverage")) + parser.add_argument("--lint", default=None, + help="'<Target Branch>' or 'uncommitted', passed to " + "tools/linter.py [--branch BRANCH] " + "[--uncommitted]") parser.add_argument("--durations", action="store", default=-1, type=int, help=("Time N slowest tests, time all if 0, time none if < 0")) parser.add_argument("--gcov", action="store_true", default=False, @@ -162,6 +172,9 @@ def main(argv): print("*** Benchmarks should not be run against debug " "version; remove -g flag ***") + if args.lint: + check_lint(args.lint) + if not args.no_build: # we need the noarch path in case the package is pure python. site_dir, site_dir_noarch = build_project(args) @@ -637,6 +650,24 @@ def lcov_generate(): else: print("HTML output generated under build/lcov/") +def check_lint(lint_args): + """ + Adds ROOT_DIR to path and performs lint checks. + This functions exits the program with status code of lint check. + """ + sys.path.append(ROOT_DIR) + try: + from tools.linter import DiffLinter + except ModuleNotFoundError as e: + print(f"Error: {e.msg}. " + "Install using linter_requirements.txt.") + sys.exit(1) + + uncommitted = lint_args == "uncommitted" + branch = "master" if uncommitted else lint_args + + DiffLinter(branch).run_lint(uncommitted) + if __name__ == "__main__": main(argv=sys.argv[1:]) |