From 6b2bfd4b550642582b6b49369aac04aa73eb9748 Mon Sep 17 00:00:00 2001 From: David Vo Date: Sat, 25 Mar 2023 16:32:22 +1100 Subject: [PATCH] cli_coverage: Add --parallel-mode --- pyfrc/mains/cli_coverage.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pyfrc/mains/cli_coverage.py b/pyfrc/mains/cli_coverage.py index 7c4cf51..de309ea 100644 --- a/pyfrc/mains/cli_coverage.py +++ b/pyfrc/mains/cli_coverage.py @@ -11,7 +11,10 @@ class PyFrcCoverage: the coverage module to be installed. """ - def __init__(self, parser): + def __init__(self, parser: argparse.ArgumentParser): + parser.add_argument( + "--parallel-mode", action="store_true", help="Run coverage in parallel mode" + ) parser.add_argument( "args", nargs=argparse.REMAINDER, help="Arguments to pass to robot.py" ) @@ -45,13 +48,20 @@ def run(self, options, robot_class, **static_options): "run", "--source", dirname(file_location), - file_location, - ] + list(options.args) + ] + if options.parallel_mode: + args.append("--parallel-mode") + + args.append(file_location) + args += option_args retval = subprocess.call(args) if retval != 0: return retval + if options.parallel_mode: + subprocess.call([sys.executable, "-m", "coverage", "combine"]) + args = [sys.executable, "-m", "coverage", "report", "-m"] return subprocess.call(args)