]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Prevent detailed code coverage from accessing missing report.
authorJames Rhodes <jrhodes@redpointsoftware.com.au>
Fri, 20 Sep 2013 16:18:02 +0000 (09:18 -0700)
committerepriestley <git@epriestley.com>
Fri, 20 Sep 2013 16:18:02 +0000 (09:18 -0700)
Summary:
Fixes T3856.

Detailed code coverage iterates over all of the files with changes in the current repository, however the code coverage tool might not generate a report for all changed files in the repository, and this would result in an undefined index error.

As an additional bonus, since changes to binary files won't be reported by code coverage tools, this also prevents binary data from being outputted to the console.

Test Plan:
Change a binary file in a repository and run a code coverage tool.  The binary file should be reported as 0% code coverage, but the file contents should not be rendered to the console.

Change a code file that is not covered by a code coverage tool and run code coverage.  The file should be reported as 0% code coverage, and the file contents should not be displayed.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran
Maniphest Tasks: T3856

Differential Revision: https://secure.phabricator.com/D7051

src/workflow/ArcanistUnitWorkflow.php

index 6891a396f0ee0be30dcbe5899896eb901543ce8b..a00817c9be19c19f691f9879530d6e18dac109c6 100644 (file)
@@ -237,7 +237,8 @@ EOTEXT
         $full_path = $working_copy->getProjectRoot().'/'.$file;
         if ($this->getArgument('detailed-coverage') &&
             Filesystem::pathExists($full_path) &&
-            is_file($full_path)) {
+            is_file($full_path) &&
+            array_key_exists($file, $file_reports)) {
           $console->writeOut(
             '%s',
             $this->renderDetailedCoverageReport(