Skip to content

Commit

Permalink
Throw an exception if code coverage fails to write to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan3dc committed Sep 19, 2019
1 parent aa0d179 commit 23c3be9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"require": {
"php": "^7.2",
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
"phpunit/php-file-iterator": "^2.0.2",
"phpunit/php-token-stream": "^3.1.1",
Expand Down
16 changes: 15 additions & 1 deletion src/Report/Xml/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,21 @@ private function saveDocument(\DOMDocument $document, string $name): void
$document->preserveWhiteSpace = false;
$this->initTargetDirectory(\dirname($filename));

$document->save($filename);
$original = \libxml_use_internal_errors(true);
$result = $document->save($filename);

if ($result === false) {
$message = 'Unable to save the XML';

foreach (\libxml_get_errors() as $error) {
$message .= "\n" . $error->message;
}

throw new RuntimeException($message);
}

\libxml_clear_errors();
\libxml_use_internal_errors($original);
}

private function createDirectory(string $directory): bool
Expand Down

0 comments on commit 23c3be9

Please sign in to comment.