@@ -190,6 +190,15 @@ class Opts:
190
190
"'pyproject.toml' are tried. [env: COVERAGE_RCFILE]"
191
191
),
192
192
)
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
+ )
193
202
show_contexts = optparse .make_option (
194
203
"--show-contexts" , action = "store_true" ,
195
204
help = "Show contexts for covered lines." ,
@@ -229,15 +238,6 @@ class Opts:
229
238
"" , "--version" , action = "store_true" ,
230
239
help = "Display version information and exit." ,
231
240
)
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
- )
241
241
242
242
class CoverageOptionParser (optparse .OptionParser ):
243
243
"""Base OptionParser for coverage.py.
@@ -261,7 +261,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
261
261
data_file = None ,
262
262
debug = None ,
263
263
directory = None ,
264
- dump_signal = None ,
265
264
fail_under = None ,
266
265
format = None ,
267
266
help = None ,
@@ -275,6 +274,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
275
274
pylib = None ,
276
275
quiet = None ,
277
276
rcfile = True ,
277
+ save_signal = None ,
278
278
show_contexts = None ,
279
279
show_missing = None ,
280
280
skip_covered = None ,
@@ -534,9 +534,9 @@ def get_prog_name(self) -> str:
534
534
Opts .omit ,
535
535
Opts .pylib ,
536
536
Opts .parallel_mode ,
537
+ Opts .save_signal ,
537
538
Opts .source ,
538
539
Opts .timid ,
539
- Opts .dump_signal ,
540
540
] + GLOBAL_ARGS ,
541
541
usage = "[options] <pyfile> [program options]" ,
542
542
description = "Run a Python program, measuring code execution." ,
@@ -819,9 +819,9 @@ def do_help(
819
819
820
820
return False
821
821
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 ..." )
825
825
self .coverage .save ()
826
826
827
827
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:
868
868
if options .append :
869
869
self .coverage .load ()
870
870
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 )
876
876
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 } " )
878
878
return ERR
879
879
880
880
# Run the script.
0 commit comments