Skip to content

Commit

Permalink
Tests: test() catches GitException and dumps output & exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Apr 24, 2022
1 parent 5e82d54 commit 807e59f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/GitPhp/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,24 @@

function test($cb)
{
$cb();
try {
$cb();

} catch (CzProject\GitPhp\GitException $e) {
$result = $e->getRunnerResult();

if ($result !== NULL) {
echo $result->getCommand(), "\n";
echo 'EXIT CODE: ', $result->getExitCode(), "\n";
echo "--------------\n",
$result->getOutputAsString(), "\n";

if ($result->hasErrorOutput()) {
echo "--------------\n",
implode("\n", $result->getErrorOutput()), "\n";
}
}

throw $e;
}
}

0 comments on commit 807e59f

Please sign in to comment.