--- a/eric7/DebugClients/Python/coverage/cmdline.py Sun Jan 16 20:28:42 2022 +0100 +++ b/eric7/DebugClients/Python/coverage/cmdline.py Sat Jan 22 14:44:56 2022 +0100 @@ -17,11 +17,11 @@ from coverage import Coverage from coverage import env from coverage.collector import CTracer -from coverage.data import line_counts +from coverage.config import CoverageConfig +from coverage.data import combinable_files, debug_data_file from coverage.debug import info_formatter, info_header, short_stack -from coverage.exceptions import BaseCoverageException, ExceptionDuringRun, NoSource +from coverage.exceptions import _BaseCoverageException, _ExceptionDuringRun, NoSource from coverage.execfile import PyRunner -from coverage.misc import human_sorted from coverage.results import Numbers, should_fail_under @@ -40,16 +40,12 @@ '', '--branch', action='store_true', help="Measure branch coverage in addition to statement coverage.", ) - CONCURRENCY_CHOICES = [ - "thread", "gevent", "greenlet", "eventlet", "multiprocessing", - ] concurrency = optparse.make_option( - '', '--concurrency', action='store', metavar="LIB", - choices=CONCURRENCY_CHOICES, + '', '--concurrency', action='store', metavar="LIBS", help=( "Properly measure code using a concurrency library. " + - "Valid values are: {}." - ).format(", ".join(CONCURRENCY_CHOICES)), + "Valid values are: {}, or a comma-list of them." + ).format(", ".join(sorted(CoverageConfig.CONCURRENCY_CHOICES))), ) context = optparse.make_option( '', '--context', action='store', metavar="LABEL", @@ -571,6 +567,11 @@ debug = unshell_list(options.debug) contexts = unshell_list(options.contexts) + if options.concurrency is not None: + concurrency = options.concurrency.split(",") + else: + concurrency = None + # Do something. self.coverage = Coverage( data_suffix=options.parallel_mode, @@ -582,7 +583,7 @@ omit=omit, include=include, debug=debug, - concurrency=options.concurrency, + concurrency=concurrency, check_preimported=True, context=options.context, messages=not options.quiet, @@ -601,8 +602,8 @@ elif options.action == "combine": if options.append: self.coverage.load() - data_dirs = args or None - self.coverage.combine(data_dirs, strict=True, keep=bool(options.keep)) + data_paths = args or None + self.coverage.combine(data_paths, strict=True, keep=bool(options.keep)) self.coverage.save() return OK @@ -778,42 +779,33 @@ if not args: show_help("What information would you like: config, data, sys, premain?") return ERR + if args[1:]: + show_help("Only one topic at a time, please") + return ERR - for info in args: - if info == 'sys': - sys_info = self.coverage.sys_info() - print(info_header("sys")) - for line in info_formatter(sys_info): - print(f" {line}") - elif info == 'data': - self.coverage.load() - data = self.coverage.get_data() - print(info_header("data")) - print(f"path: {data.data_filename()}") - if data: - print(f"has_arcs: {data.has_arcs()!r}") - summary = line_counts(data, fullpath=True) - filenames = human_sorted(summary.keys()) - print(f"\n{len(filenames)} files:") - for f in filenames: - line = f"{f}: {summary[f]} lines" - plugin = data.file_tracer(f) - if plugin: - line += f" [{plugin}]" - print(line) - else: - print("No data collected") - elif info == 'config': - print(info_header("config")) - config_info = self.coverage.config.__dict__.items() - for line in info_formatter(config_info): - print(f" {line}") - elif info == "premain": - print(info_header("premain")) - print(short_stack()) - else: - show_help(f"Don't know what you mean by {info!r}") - return ERR + if args[0] == 'sys': + sys_info = self.coverage.sys_info() + print(info_header("sys")) + for line in info_formatter(sys_info): + print(f" {line}") + elif args[0] == 'data': + print(info_header("data")) + data_file = self.coverage.config.data_file + debug_data_file(data_file) + for filename in combinable_files(data_file): + print("-----") + debug_data_file(filename) + elif args[0] == 'config': + print(info_header("config")) + config_info = sorted(self.coverage.config.__dict__.items()) + for line in info_formatter(config_info): + print(f" {line}") + elif args[0] == "premain": + print(info_header("premain")) + print(short_stack()) + else: + show_help(f"Don't know what you mean by {args[0]!r}") + return ERR return OK @@ -887,13 +879,13 @@ argv = sys.argv[1:] try: status = CoverageScript().command_line(argv) - except ExceptionDuringRun as err: + except _ExceptionDuringRun as err: # An exception was caught while running the product code. The - # sys.exc_info() return tuple is packed into an ExceptionDuringRun + # sys.exc_info() return tuple is packed into an _ExceptionDuringRun # exception. traceback.print_exception(*err.args) # pylint: disable=no-value-for-parameter status = ERR - except BaseCoverageException as err: + except _BaseCoverageException as err: # A controlled error inside coverage.py: print the message to the user. msg = err.args[0] print(msg)