Skip to content

Commit cd2a914

Browse files
committed
misc: Changes per pull request
* Set options in alphabetical order * Rename "dump-signal" to "save-signal" Signed-off-by: Arkady Gilinsky <[email protected]>
1 parent 35233a5 commit cd2a914

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

coverage/cmdline.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ class Opts:
190190
"'pyproject.toml' are tried. [env: COVERAGE_RCFILE]"
191191
),
192192
)
193+
save_signal = optparse.make_option(
194+
'', '--save-signal', action='store', metavar='SAVE_SIGNAL',
195+
choices = ['USR1', 'USR2'],
196+
help=(
197+
"Define a system signal that will trigger coverage report save operation. " +
198+
"It is important that target script do not intercept this signal. " +
199+
"Currently supported options are: USR1, USR2."
200+
),
201+
)
193202
show_contexts = optparse.make_option(
194203
"--show-contexts", action="store_true",
195204
help="Show contexts for covered lines.",
@@ -229,15 +238,6 @@ class Opts:
229238
"", "--version", action="store_true",
230239
help="Display version information and exit.",
231240
)
232-
dump_signal = optparse.make_option(
233-
'', '--dump_signal', action='store', metavar='DUMP_SIGNAL',
234-
choices = ['USR1', 'USR2'],
235-
help=(
236-
"Define a system signal that will trigger coverage report dump. " +
237-
"It is important that target script do not intercept this signal. " +
238-
"Currently supported options are: USR1, USR2."
239-
),
240-
)
241241

242242
class CoverageOptionParser(optparse.OptionParser):
243243
"""Base OptionParser for coverage.py.
@@ -261,7 +261,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
261261
data_file=None,
262262
debug=None,
263263
directory=None,
264-
dump_signal=None,
265264
fail_under=None,
266265
format=None,
267266
help=None,
@@ -275,6 +274,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
275274
pylib=None,
276275
quiet=None,
277276
rcfile=True,
277+
save_signal=None,
278278
show_contexts=None,
279279
show_missing=None,
280280
skip_covered=None,
@@ -534,9 +534,9 @@ def get_prog_name(self) -> str:
534534
Opts.omit,
535535
Opts.pylib,
536536
Opts.parallel_mode,
537+
Opts.save_signal,
537538
Opts.source,
538539
Opts.timid,
539-
Opts.dump_signal,
540540
] + GLOBAL_ARGS,
541541
usage="[options] <pyfile> [program options]",
542542
description="Run a Python program, measuring code execution.",
@@ -819,9 +819,9 @@ def do_help(
819819

820820
return False
821821

822-
def do_dump(self, _signum: int, _frame: types.FrameType | None) -> None:
823-
""" Signal handler to dump coverage report """
824-
print("Dumping coverage data ...")
822+
def do_signal_save(self, _signum: int, _frame: types.FrameType | None) -> None:
823+
""" Signal handler to save coverage report """
824+
print("Saving coverage data ...")
825825
self.coverage.save()
826826

827827
def do_run(self, options: optparse.Values, args: list[str]) -> int:
@@ -868,13 +868,13 @@ def do_run(self, options: optparse.Values, args: list[str]) -> int:
868868
if options.append:
869869
self.coverage.load()
870870

871-
if options.dump_signal:
872-
if options.dump_signal.upper() == 'USR1':
873-
signal.signal(signal.SIGUSR1, self.do_dump)
874-
elif options.dump_signal.upper() == 'USR2':
875-
signal.signal(signal.SIGUSR2, self.do_dump)
871+
if options.save_signal:
872+
if options.save_signal.upper() == 'USR1':
873+
signal.signal(signal.SIGUSR1, self.do_signal_save)
874+
elif options.save_signal.upper() == 'USR2':
875+
signal.signal(signal.SIGUSR2, self.do_signal_save)
876876
else:
877-
show_help(f"Unsupported signal for dump coverage report: {options.dump_signal}")
877+
show_help(f"Unsupported signal for save coverage report: {options.save_signal}")
878878
return ERR
879879

880880
# Run the script.

doc/cmd.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ There are many options:
133133
-p, --parallel-mode Append the machine name, process id and random number
134134
to the data file name to simplify collecting data from
135135
many processes.
136+
--save-signal=SAVE_SIGNAL
137+
Define a system signal that will trigger coverage
138+
report save operation. It is important that target
139+
script do not intercept this signal. Currently
140+
supported options are: USR1, USR2.
136141
--source=SRC1,SRC2,...
137142
A list of directories or importable names of code to
138143
measure.
139144
--timid Use the slower Python trace function core.
140-
--dump_signal=DUMP_SIGNAL
141-
Define a system signal that will trigger coverage
142-
report dump. It is important that target script do not
143-
intercept this signal. Currently supported options
144-
are: USR1, USR2.
145145
--debug=OPTS Debug options, separated by commas. [env:
146146
COVERAGE_DEBUG]
147147
-h, --help Get help on this command.
148148
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
149149
'setup.cfg', 'tox.ini', and 'pyproject.toml' are
150150
tried. [env: COVERAGE_RCFILE]
151-
.. [[[end]]] (sum: kxkJi2xQZv)
151+
.. [[[end]]] (sum: 1+s3B5JO5I)
152152
153153
If you want :ref:`branch coverage <branch>` measurement, use the ``--branch``
154154
flag. Otherwise only statement coverage is measured.

0 commit comments

Comments
 (0)