Coverage: Add merge output in verbose mode.

Merge output is important to see any counter overflow warnings.
On coverage bot, this is already captured. So, support similar
functionality in verbose mode.

[email protected],[email protected]

Bug: 844432
Change-Id: I5bffb5c8d1c5b0748c66ebed3e4becca7619a3eb
Reviewed-on: https://chromium-review.googlesource.com/1070997
Reviewed-by: Max Moroz <[email protected]>
Commit-Queue: Abhishek Arya <[email protected]>
Cr-Commit-Position: refs/heads/master@{#561381}
diff --git a/tools/code_coverage/coverage.py b/tools/code_coverage/coverage.py
index bb292b09..3cac5f32 100755
--- a/tools/code_coverage/coverage.py
+++ b/tools/code_coverage/coverage.py
@@ -1184,7 +1184,9 @@
         LLVM_PROFDATA_PATH, 'merge', '-o', profdata_file_path, '-sparse=true'
     ]
     subprocess_cmd.extend(profdata_file_paths)
-    subprocess.check_call(subprocess_cmd)
+
+    output = subprocess.check_output(subprocess_cmd)
+    logging.debug('Merge output: %s' % output)
   except subprocess.CalledProcessError as error:
     logging.error(
         'Failed to merge target profdata files to create coverage profdata. %s',
@@ -1220,7 +1222,9 @@
         LLVM_PROFDATA_PATH, 'merge', '-o', profdata_file_path, '-sparse=true'
     ]
     subprocess_cmd.extend(profraw_file_paths)
-    subprocess.check_call(subprocess_cmd)
+
+    output = subprocess.check_output(subprocess_cmd)
+    logging.debug('Merge output: %s' % output)
   except subprocess.CalledProcessError as error:
     logging.error(
         'Failed to merge target profraw files to create target profdata.')
@@ -1496,6 +1500,15 @@
     assert False, 'This platform is not supported for web tests.'
 
 
+def _SetupOutputDir():
+  """Setup output directory."""
+  if os.path.exists(OUTPUT_DIR):
+    shutil.rmtree(OUTPUT_DIR)
+
+  # Creates |OUTPUT_DIR| and its platform sub-directory.
+  os.makedirs(_GetCoverageReportRootDirPath())
+
+
 def _ParseCommandArguments():
   """Adds and parses relevant arguments for tool comands.
 
@@ -1630,6 +1643,7 @@
 
   global BUILD_DIR
   BUILD_DIR = _GetFullPath(args.build_dir)
+
   global OUTPUT_DIR
   OUTPUT_DIR = _GetFullPath(args.output_dir)
 
@@ -1652,8 +1666,7 @@
   if args.filters:
     absolute_filter_paths = _VerifyPathsAndReturnAbsolutes(args.filters)
 
-  if not os.path.exists(_GetCoverageReportRootDirPath()):
-    os.makedirs(_GetCoverageReportRootDirPath())
+  _SetupOutputDir()
 
   # Get .profdata file and list of binary paths.
   if args.web_tests: