From 75737c6d891d714e1f3d38e9ec7a2bf27d21d7ed Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Fri, 20 Sep 2013 09:18:02 -0700 Subject: [PATCH] Prevent detailed code coverage from accessing missing report. 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php index 6891a396..a00817c9 100644 --- a/src/workflow/ArcanistUnitWorkflow.php +++ b/src/workflow/ArcanistUnitWorkflow.php @@ -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(