diff options
-rwxr-xr-x | build/android/generate_emma_html.py | 39 | ||||
-rwxr-xr-x | build/android/gyp/emma_instr.py | 34 | ||||
-rw-r--r-- | build/android/instr_action.gypi | 7 | ||||
-rw-r--r-- | third_party/cacheinvalidation/cacheinvalidation.gyp | 4 |
4 files changed, 42 insertions, 42 deletions
diff --git a/build/android/generate_emma_html.py b/build/android/generate_emma_html.py index 1b00a329..463a836 100755 --- a/build/android/generate_emma_html.py +++ b/build/android/generate_emma_html.py @@ -46,7 +46,8 @@ def main(argv): help=('Root of the directory in which to search for ' 'coverage metadata (.em) files.')) option_parser.add_option('--cleanup', action='store_true', - help='If set, removes coverage/metadata files.') + help=('If set, removes coverage files generated at ' + 'runtime.')) options, args = option_parser.parse_args() if not (options.coverage_dir and options.metadata_dir and options.output): @@ -56,33 +57,22 @@ def main(argv): metadata_files = _GetFilesWithExt(options.metadata_dir, 'em') print 'Found coverage files: %s' % str(coverage_files) print 'Found metadata files: %s' % str(metadata_files) - sources_files = [] - final_metadata_files = [] - err = None + + sources = [] for f in metadata_files: sources_file = os.path.splitext(f)[0] + '_sources.txt' - # TODO(gkanwar): Remove this once old coverage.em files have been cleaned - # from all bots. - # Warn if we have old metadata files lying around that don't correspond - # to a *_sources.txt (these should be manually cleaned). - try: - with open(sources_file, 'r') as sf: - sources_files.extend(json.load(sf)) - except IOError as e: - traceback.print_exc() - err = e - else: - final_metadata_files.append(f) - sources_files = [os.path.join(constants.DIR_SOURCE_ROOT, s) - for s in sources_files] + with open(sources_file, 'r') as sf: + sources.extend(json.load(sf)) + sources = [os.path.join(constants.DIR_SOURCE_ROOT, s) for s in sources] + print 'Sources: %s' % sources input_args = [] - for f in coverage_files + final_metadata_files: + for f in coverage_files + metadata_files: input_args.append('-in') input_args.append(f) output_args = ['-Dreport.html.out.file', options.output] - source_args = ['-sp', ','.join(sources_files)] + source_args = ['-sp', ','.join(sources)] exit_code = cmd_helper.RunCmd( ['java', '-cp', @@ -91,15 +81,10 @@ def main(argv): + input_args + output_args + source_args) if options.cleanup: - for f in coverage_files + metadata_files: + for f in coverage_files: os.remove(f) - if exit_code > 0: - return exit_code - elif err: - return constants.WARNING_EXIT_CODE - else: - return 0 + return exit_code if __name__ == '__main__': diff --git a/build/android/gyp/emma_instr.py b/build/android/gyp/emma_instr.py index 8e69f39..ae20cac 100755 --- a/build/android/gyp/emma_instr.py +++ b/build/android/gyp/emma_instr.py @@ -12,11 +12,11 @@ call one of the instrument commands, or the copy command. Possible commands are: - instrument_jar: Accepts a jar and instruments it using emma.jar. -- instrument_classes: Accepts a directory contains java classes and instruments - it using emma.jar. -- copy: Triggered instead of an instrumentation command when we don't have EMMA - coverage enabled. This allows us to make this a required step without - necessarily instrumenting on every build. +- instrument_classes: Accepts a directory containing java classes and + instruments it using emma.jar. +- copy: Called when EMMA coverage is not enabled. This allows us to make + this a required step without necessarily instrumenting on every build. + Also removes any stale coverage files. """ import collections @@ -42,15 +42,15 @@ def _AddCommonOptions(option_parser): 'final classes directory, or the directory in ' 'which to place the instrumented/copied jar.')) option_parser.add_option('--stamp', help='Path to touch when done.') + option_parser.add_option('--coverage-file', + help='File to create with coverage metadata.') + option_parser.add_option('--sources-file', + help='File to create with the list of sources.') def _AddInstrumentOptions(option_parser): """Adds options related to instrumentation to |option_parser|.""" _AddCommonOptions(option_parser) - option_parser.add_option('--coverage-file', - help='File to create with coverage metadata.') - option_parser.add_option('--sources-file', - help='File to create with the list of sources.') option_parser.add_option('--sources', help='Space separated list of sources.') option_parser.add_option('--src-root', @@ -60,7 +60,9 @@ def _AddInstrumentOptions(option_parser): def _RunCopyCommand(command, options, args, option_parser): - """Just copies the jar from input to output locations. + """Copies the jar from input to output locations. + + Also removes any old coverage/sources file. Args: command: String indicating the command that was received to trigger @@ -72,9 +74,19 @@ def _RunCopyCommand(command, options, args, option_parser): Returns: An exit code. """ - if not (options.input_path and options.output_path): + if not (options.input_path and options.output_path and + options.coverage_file and options.sources_file): option_parser.error('All arguments are required.') + coverage_file = os.path.join(os.path.dirname(options.output_path), + options.coverage_file) + sources_file = os.path.join(os.path.dirname(options.output_path), + options.sources_file) + if os.path.exists(coverage_file): + os.remove(coverage_file) + if os.path.exists(sources_file): + os.remove(sources_file) + if os.path.isdir(options.input_path): shutil.rmtree(options.output_path, ignore_errors=True) shutil.copytree(options.input_path, options.output_path) diff --git a/build/android/instr_action.gypi b/build/android/instr_action.gypi index b4164f6..7b15998 100644 --- a/build/android/instr_action.gypi +++ b/build/android/instr_action.gypi @@ -11,13 +11,14 @@ 'input_path%': '', 'output_path%': '', 'stamp_path%': '', - 'extra_instr_args': [], + 'extra_instr_args': [ + '--coverage-file=<(_target_name).em', + '--sources-file=<(_target_name)_sources.txt', + ], 'emma_jar': '<(android_sdk_root)/tools/lib/emma.jar', 'conditions': [ ['emma_instrument != 0', { 'extra_instr_args': [ - '--coverage-file=<(_target_name).em', - '--sources-file=<(_target_name)_sources.txt', '--sources=<(java_in_dir)/src >(additional_src_dirs) >(generated_src_dirs)', '--src-root=<(DEPTH)', '--emma-jar=<(emma_jar)', diff --git a/third_party/cacheinvalidation/cacheinvalidation.gyp b/third_party/cacheinvalidation/cacheinvalidation.gyp index 166dbef..5a38bb2 100644 --- a/third_party/cacheinvalidation/cacheinvalidation.gyp +++ b/third_party/cacheinvalidation/cacheinvalidation.gyp @@ -7,7 +7,6 @@ # This library should build cleanly with the extra warnings turned on # for Chromium. 'chromium_code': 1, - 'emma_never_instrument': 1, }, 'targets': [ # The C++ files generated from the cache invalidation protocol buffers. @@ -179,6 +178,9 @@ ], }], ['OS == "android"', { + 'variables': { + 'emma_never_instrument': 1, + }, 'targets': [ { 'target_name': 'cacheinvalidation_proto_java', |