|
18 | 18 | from coverage import env
|
19 | 19 | from coverage.collector import CTracer
|
20 | 20 | from coverage.config import CoverageConfig
|
| 21 | +from coverage.control import DEFAULT_DATAFILE |
21 | 22 | from coverage.data import combinable_files, debug_data_file
|
22 | 23 | from coverage.debug import info_formatter, info_header, short_stack
|
23 | 24 | from coverage.exceptions import _BaseCoverageException, _ExceptionDuringRun, NoSource
|
@@ -123,6 +124,11 @@ class Opts:
|
123 | 124 | metavar="OUTFILE",
|
124 | 125 | help="Write the JSON report to this file. Defaults to 'coverage.json'",
|
125 | 126 | )
|
| 127 | + output_coverage = optparse.make_option( |
| 128 | + '-o', '', action='store', dest="outfile", |
| 129 | + metavar="OUTFILE", |
| 130 | + help="Write the recorded coverage information to this file. Defaults to '.coverage'" |
| 131 | + ) |
126 | 132 | json_pretty_print = optparse.make_option(
|
127 | 133 | '', '--pretty-print', action='store_true',
|
128 | 134 | help="Format the JSON for human readers.",
|
@@ -450,6 +456,7 @@ def get_prog_name(self):
|
450 | 456 | Opts.include,
|
451 | 457 | Opts.module,
|
452 | 458 | Opts.omit,
|
| 459 | + Opts.output_coverage, |
453 | 460 | Opts.pylib,
|
454 | 461 | Opts.parallel_mode,
|
455 | 462 | Opts.source,
|
@@ -572,8 +579,11 @@ def command_line(self, argv):
|
572 | 579 | else:
|
573 | 580 | concurrency = None
|
574 | 581 |
|
| 582 | + data_file = options.outfile if options.action in ["run", "combine"] \ |
| 583 | + else getattr(options, "input_coverage", None) |
575 | 584 | # Do something.
|
576 | 585 | self.coverage = Coverage(
|
| 586 | + data_file=data_file or DEFAULT_DATAFILE, |
577 | 587 | data_suffix=options.parallel_mode,
|
578 | 588 | cover_pylib=options.pylib,
|
579 | 589 | timid=options.timid,
|
|
0 commit comments