Skip to content

Commit

Permalink
Instead of using an option default for --coverage-processor, explain …
Browse files Browse the repository at this point in the history
…the defaulting in the option help.
  • Loading branch information
jsirois committed Jan 10, 2018
1 parent 303256c commit 7041d52
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/python/pants/backend/jvm/tasks/coverage/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ def subsystem_dependencies(cls):
def register_junit_options(register, register_jvm_tool):
register('--coverage', type=bool, fingerprint=True, help='Collect code coverage data.')
register('--coverage-processor', advanced=True, fingerprint=True,
choices=['cobertura', 'jacoco'], default='cobertura',
help='Which coverage processor to use if --coverage is enabled. If this option is'
'explicitly set, implies --coverage.')
register('--coverage-jvm-options', advanced=True, type=list, fingerprint=True,
help='JVM flags to be added when running the coverage processor. For example: '
'{flag}=-Xmx4g {flag}=-XX:MaxPermSize=1g'.format(flag='--coverage-jvm-options'))

choices=['cobertura', 'jacoco'], default=None,
help="Which coverage processor to use if --coverage is enabled. If this option is "
"unset but coverage is enabled implicitly or explicitly, defaults to 'cobertura'."
"If this option is explicitly set, implies --coverage.")
# We need to fingerprint this even though it nominally UI-only affecting option since the
# presence of this option alone can implicitly flag on `--coverage`.
register('--coverage-open', type=bool, fingerprint=True,
help='Open the generated HTML coverage report in a browser. Implies --coverage.')

register('--coverage-jvm-options', advanced=True, type=list, fingerprint=True,
help='JVM flags to be added when running the coverage processor. For example: '
'{flag}=-Xmx4g {flag}=-XX:MaxPermSize=1g'.format(flag='--coverage-jvm-options'))
register('--coverage-force', advanced=True, type=bool,
help='Attempt to run the reporting phase of coverage even if tests failed '
'(defaults to False, as otherwise the coverage results would be unreliable).')
Expand All @@ -94,11 +94,9 @@ class InvalidCoverageEngine(Exception):

def get_coverage_engine(self, task, output_dir, all_targets, execute_java):
options = task.get_options()
if (options.coverage or
options.is_flagged('coverage_processor') or
options.is_flagged('coverage_open')):
if options.coverage or options.coverage_processor or options.is_flagged('coverage_open'):
settings = CodeCoverageSettings.from_task(task, workdir=output_dir)
if options.coverage_processor == 'cobertura':
if options.coverage_processor in ('cobertura', None):
return Cobertura.Factory.global_instance().create(settings, all_targets, execute_java)
elif options.coverage_processor == 'jacoco':
return Jacoco.Factory.global_instance().create(settings, all_targets, execute_java)
Expand Down

0 comments on commit 7041d52

Please sign in to comment.