From: Mukunda Modell Date: Wed, 5 Oct 2016 20:19:15 +0000 (-0500) Subject: Fix an DOMDocument error with NoseTestEngine running on PHP 7 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2962504855413be1dce6f4bcffd6283bc657fb6f;p=arcanist.git Fix an DOMDocument error with NoseTestEngine running on PHP 7 Summary: In php 7, DOMDocument::loadXML emits an error when supplied with an empty string as input. For example, I got this error: ERROR 2: DOMDocument::loadXML(): Empty string supplied as input This change simply checks for empty and returns an empty array rather than attempting to parse an empty xml document. Test Plan: ran `arc diff` on a repo that uses nosetestengine Reviewers: #blessed_reviewers! Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D16672 --- diff --git a/src/unit/engine/NoseTestEngine.php b/src/unit/engine/NoseTestEngine.php index 1391d135..f642dbf3 100644 --- a/src/unit/engine/NoseTestEngine.php +++ b/src/unit/engine/NoseTestEngine.php @@ -126,8 +126,12 @@ final class NoseTestEngine extends ArcanistUnitTestEngine { } public function readCoverage($cover_file, $source_path) { + $coverage_xml = Filesystem::readFile($cover_file); + if (strlen($coverage_xml) < 1) { + return array(); + } $coverage_dom = new DOMDocument(); - $coverage_dom->loadXML(Filesystem::readFile($cover_file)); + $coverage_dom->loadXML($coverage_xml); $reports = array(); $classes = $coverage_dom->getElementsByTagName('class');