From 85083db929f384dee0d40f5ea8938348d7907326 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 1 Feb 2012 17:36:25 -0800 Subject: [PATCH] Minor "arc unit" coverage display updates Summary: - Show coverage for all files, not just files that have some coverage information. - Read file data off disk, under git the "current" data is the data at HEAD, not the (possibly unstaged/uncommitted) file in the working copy which we actually ran. Test Plan: Ran "arc unit --detailed-coverage" on various files. Reviewers: tuomaspelkonen, btrahan Reviewed By: tuomaspelkonen CC: aran, epriestley Maniphest Tasks: T818 Differential Revision: https://secure.phabricator.com/D1542 --- src/workflow/unit/ArcanistUnitWorkflow.php | 14 +++++++++----- src/workflow/unit/__init__.php | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/workflow/unit/ArcanistUnitWorkflow.php b/src/workflow/unit/ArcanistUnitWorkflow.php index 3a2cda6a..bd2e08e6 100644 --- a/src/workflow/unit/ArcanistUnitWorkflow.php +++ b/src/workflow/unit/ArcanistUnitWorkflow.php @@ -193,7 +193,9 @@ EOTEXT } if ($coverage) { - $file_coverage = array(); + $file_coverage = array_fill_keys( + $paths, + 0); $file_reports = array(); foreach ($coverage as $file => $reports) { $report = ArcanistUnitTestResult::mergeCoverage($reports); @@ -218,9 +220,12 @@ EOTEXT sprintf('% 3d', (int)(100 * $coverage)), $file); - if ($this->getArgument('detailed-coverage')) { + $full_path = $working_copy->getProjectRoot().'/'.$file; + if ($this->getArgument('detailed-coverage') && + Filesystem::pathExists($full_path) && + is_file($full_path)) { echo $this->renderDetailedCoverageReport( - $file, + Filesystem::readFile($full_path), $file_reports[$file]); } } @@ -298,8 +303,7 @@ EOTEXT return ' <1ms'; } - private function renderDetailedCoverageReport($file, $report) { - $data = $this->getRepositoryAPI()->getCurrentFileData($file); + private function renderDetailedCoverageReport($data, $report) { $data = explode("\n", $data); $out = ''; diff --git a/src/workflow/unit/__init__.php b/src/workflow/unit/__init__.php index bc9e52a6..b337be76 100644 --- a/src/workflow/unit/__init__.php +++ b/src/workflow/unit/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('arcanist', 'unit/result'); phutil_require_module('arcanist', 'workflow/base'); phutil_require_module('phutil', 'console'); +phutil_require_module('phutil', 'filesystem'); phutil_require_module('phutil', 'symbols'); phutil_require_module('phutil', 'utils');