Skip to content

Commit

Permalink
updates to handle "complex" exceptions, and capture code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Mar 4, 2021
1 parent d54d9cc commit 1ba7872
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/spawn_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ jobs:
- name: Install dependencies
run: composer install
- name: Test with phpunit
run: vendor/bin/phpunit -d zend.enable_gc=0 --coverage-clover=coverage/phpunit/clover.xml
run: vendor/bin/phpunit -d zend.enable_gc=0 --coverage-clover=coverage.xml
- name: Submit code coverage
if: ${{ success() }} || ${{ failure() }}
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml # optional
11 changes: 8 additions & 3 deletions Spawn/SerializableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ public function __construct(Throwable $exception)

public function asThrowable(): Throwable
{
/** @var Throwable $throwable */
$throwable = new $this->class($this->message . "\n\n" . $this->trace);

try {
/** @var Throwable $throwable */
$throwable = new $this->class($this->message . "\n\n" . $this->trace);
} catch (Throwable $exception) {
// @codeCoverageIgnoreStart
$throwable = new \Exception($this->message . "\n\n" . $this->trace, 0, $exception);
// @codeCoverageIgnoreEnd
}
return $throwable;
}
}
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
</exclude>
</whitelist>
</filter>

<php>
<env name="XDEBUG_MODE" value="coverage"/>
<ini name="xdebug.mode" value="coverage"/>
</php>
</phpunit>

0 comments on commit 1ba7872

Please sign in to comment.