eric7/DebugClients/Python/coverage/control.py

branch
eric7-maintenance
changeset 9111
4ac66b6c33a4
parent 8991
2fc945191992
equal deleted inserted replaced
9049:2b9bd8f97576 9111:4ac66b6c33a4
248 data_file=data_file, cover_pylib=cover_pylib, timid=timid, 248 data_file=data_file, cover_pylib=cover_pylib, timid=timid,
249 branch=branch, parallel=bool_or_none(data_suffix), 249 branch=branch, parallel=bool_or_none(data_suffix),
250 source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug, 250 source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug,
251 report_omit=omit, report_include=include, 251 report_omit=omit, report_include=include,
252 concurrency=concurrency, context=context, 252 concurrency=concurrency, context=context,
253 ) 253 )
254 254
255 # If we have sub-process measurement happening automatically, then we 255 # If we have sub-process measurement happening automatically, then we
256 # want any explicit creation of a Coverage object to mean, this process 256 # want any explicit creation of a Coverage object to mean, this process
257 # is already coverage-aware, so don't auto-measure it. By now, the 257 # is already coverage-aware, so don't auto-measure it. By now, the
258 # auto-creation of a Coverage object has already happened. But we can 258 # auto-creation of a Coverage object has already happened. But we can
487 file_mapper=self._file_mapper, 487 file_mapper=self._file_mapper,
488 timid=self.config.timid, 488 timid=self.config.timid,
489 branch=self.config.branch, 489 branch=self.config.branch,
490 warn=self._warn, 490 warn=self._warn,
491 concurrency=concurrency, 491 concurrency=concurrency,
492 ) 492 )
493 493
494 suffix = self._data_suffix_specified 494 suffix = self._data_suffix_specified
495 if suffix: 495 if suffix:
496 if not isinstance(suffix, str): 496 if not isinstance(suffix, str):
497 # if data_suffix=True, use .machinename.pid.random 497 # if data_suffix=True, use .machinename.pid.random
513 self._warn( 513 self._warn(
514 "Plugin file tracers ({}) aren't supported with {}".format( 514 "Plugin file tracers ({}) aren't supported with {}".format(
515 ", ".join( 515 ", ".join(
516 plugin._coverage_plugin_name 516 plugin._coverage_plugin_name
517 for plugin in self._plugins.file_tracers 517 for plugin in self._plugins.file_tracers
518 ), 518 ),
519 self._collector.tracer_name(), 519 self._collector.tracer_name(),
520 )
521 ) 520 )
521 )
522 for plugin in self._plugins.file_tracers: 522 for plugin in self._plugins.file_tracers:
523 plugin._coverage_enabled = False 523 plugin._coverage_enabled = False
524 524
525 # Create the file classifying substructure. 525 # Create the file classifying substructure.
526 self._inorout = InOrOut( 526 self._inorout = InOrOut(
534 # It's useful to write debug info after initing for start. 534 # It's useful to write debug info after initing for start.
535 self._should_write_debug = True 535 self._should_write_debug = True
536 536
537 # Register our clean-up handlers. 537 # Register our clean-up handlers.
538 atexit.register(self._atexit) 538 atexit.register(self._atexit)
539 is_main = (threading.current_thread() == threading.main_thread()) 539 if self.config.sigterm:
540 if is_main and not env.WINDOWS: 540 is_main = (threading.current_thread() == threading.main_thread())
541 # The Python docs seem to imply that SIGTERM works uniformly even 541 if is_main and not env.WINDOWS:
542 # on Windows, but that's not my experience, and this agrees: 542 # The Python docs seem to imply that SIGTERM works uniformly even
543 # https://stackoverflow.com/questions/35772001/x/35792192#35792192 543 # on Windows, but that's not my experience, and this agrees:
544 self._old_sigterm = signal.signal(signal.SIGTERM, self._on_sigterm) 544 # https://stackoverflow.com/questions/35772001/x/35792192#35792192
545 self._old_sigterm = signal.signal(signal.SIGTERM, self._on_sigterm)
545 546
546 def _init_data(self, suffix): 547 def _init_data(self, suffix):
547 """Create a data file if we don't have one yet.""" 548 """Create a data file if we don't have one yet."""
548 if self._data is None: 549 if self._data is None:
549 # Create the data file. We do this at construction time so that the 550 # Create the data file. We do this at construction time so that the
833 analysis.filename, 834 analysis.filename,
834 sorted(analysis.statements), 835 sorted(analysis.statements),
835 sorted(analysis.excluded), 836 sorted(analysis.excluded),
836 sorted(analysis.missing), 837 sorted(analysis.missing),
837 analysis.missing_formatted(), 838 analysis.missing_formatted(),
838 ) 839 )
839 840
840 def _analyze(self, it): 841 def _analyze(self, it):
841 """Analyze a single morf or code unit. 842 """Analyze a single morf or code unit.
842 843
843 Returns an `Analysis` object. 844 Returns an `Analysis` object.
1144 any(slug in k for slug in ("COV", "PY")) or 1145 any(slug in k for slug in ("COV", "PY")) or
1145 (k in ("HOME", "TEMP", "TMP")) 1146 (k in ("HOME", "TEMP", "TMP"))
1146 ) 1147 )
1147 )), 1148 )),
1148 ('command_line', " ".join(getattr(sys, 'argv', ['-none-']))), 1149 ('command_line', " ".join(getattr(sys, 'argv', ['-none-']))),
1149 ] 1150 ]
1150 1151
1151 if self._inorout: 1152 if self._inorout:
1152 info.extend(self._inorout.sys_info()) 1153 info.extend(self._inorout.sys_info())
1153 1154
1154 info.extend(CoverageData.sys_info()) 1155 info.extend(CoverageData.sys_info())

eric ide

mercurial