Skip to content

Commit

Permalink
Setup mutation testing
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 2, 2024
1 parent 8d485f1 commit cdb31ab
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,37 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

mutation-test:
name: Mutation Testing

if: github.event_name == 'pull_request'

needs:
- end-to-end-tests

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: pcov
extensions: none, ctype, curl, date, dom, json, libxml, mbstring, phar, simplexml, soap, tokenizer, xml, xmlwriter, zlib
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
tools: none

- name: Install dependencies with Composer
run: ./tools/composer install --no-ansi --no-interaction --no-progress

- name: Run mutation testing
run: |
git fetch origin $GITHUB_BASE_REF
php tools/infection.phar --threads=max --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --ignore-msi-with-no-mutations --only-covered
build-phar:
name: Build PHAR

Expand Down
12 changes: 12 additions & 0 deletions infection.json5.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"testFrameworkOptions": "--testsuite=unit",
"source": {
"directories": [
"src"
]
},
"mutators": {
"@default": true,
}
}
2 changes: 2 additions & 0 deletions src/TextUI/Output/Printer/DefaultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ public static function standardError(): self
private function __construct(string $out)
{
$this->isPhpStream = str_starts_with($out, 'php://');
$x = 1;

Check warning on line 73 in src/TextUI/Output/Printer/DefaultPrinter.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ private function __construct(string $out) { $this->isPhpStream = str_starts_with($out, 'php://'); - $x = 1; + $x = 2; if (str_starts_with($out, 'socket://')) { $x = 2; $tmp = explode(':', str_replace('socket://', '', $out));

if (str_starts_with($out, 'socket://')) {
$x = 2;

Check warning on line 76 in src/TextUI/Output/Printer/DefaultPrinter.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ $this->isPhpStream = str_starts_with($out, 'php://'); $x = 1; if (str_starts_with($out, 'socket://')) { - $x = 2; + $x = 1; $tmp = explode(':', str_replace('socket://', '', $out)); if (count($tmp) !== 2) { throw new InvalidSocketException(sprintf('"%s" does not match "socket://hostname:port" format', $out));

Check warning on line 76 in src/TextUI/Output/Printer/DefaultPrinter.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ $this->isPhpStream = str_starts_with($out, 'php://'); $x = 1; if (str_starts_with($out, 'socket://')) { - $x = 2; + $x = 3; $tmp = explode(':', str_replace('socket://', '', $out)); if (count($tmp) !== 2) { throw new InvalidSocketException(sprintf('"%s" does not match "socket://hostname:port" format', $out));
$tmp = explode(':', str_replace('socket://', '', $out));

if (count($tmp) !== 2) {
Expand Down
Binary file added tools/infection.phar
Binary file not shown.

0 comments on commit cdb31ab

Please sign in to comment.