]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Minor "arc unit" coverage display updates
authorepriestley <git@epriestley.com>
Thu, 2 Feb 2012 01:36:25 +0000 (17:36 -0800)
committerepriestley <git@epriestley.com>
Thu, 2 Feb 2012 01:36:25 +0000 (17:36 -0800)
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
src/workflow/unit/__init__.php

index 3a2cda6ae0253f13a37f0722b3a1b2a60431d169..bd2e08e69fad5a6e58d4ce58f3a8ad61ba8cc714 100644 (file)
@@ -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 = '';
index bc9e52a61cdb2651fbf2fff94098360052055550..b337be76a3378ced44138cddbd72ce728124e514 100644 (file)
@@ -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');