Skip to content

Commit cdb31ab

Browse files
committed
Setup mutation testing
1 parent 8d485f1 commit cdb31ab

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

.github/workflows/ci.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,37 @@ jobs:
224224
with:
225225
token: ${{ secrets.CODECOV_TOKEN }}
226226

227+
mutation-test:
228+
name: Mutation Testing
229+
230+
if: github.event_name == 'pull_request'
231+
232+
needs:
233+
- end-to-end-tests
234+
235+
runs-on: ubuntu-latest
236+
237+
steps:
238+
- name: Checkout
239+
uses: actions/checkout@v4
240+
241+
- name: Install PHP with extensions
242+
uses: shivammathur/setup-php@v2
243+
with:
244+
php-version: 8.3
245+
coverage: pcov
246+
extensions: none, ctype, curl, date, dom, json, libxml, mbstring, phar, simplexml, soap, tokenizer, xml, xmlwriter, zlib
247+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
248+
tools: none
249+
250+
- name: Install dependencies with Composer
251+
run: ./tools/composer install --no-ansi --no-interaction --no-progress
252+
253+
- name: Run mutation testing
254+
run: |
255+
git fetch origin $GITHUB_BASE_REF
256+
php tools/infection.phar --threads=max --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --ignore-msi-with-no-mutations --only-covered
257+
227258
build-phar:
228259
name: Build PHAR
229260

infection.json5.dist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "vendor/infection/infection/resources/schema.json",
3+
"testFrameworkOptions": "--testsuite=unit",
4+
"source": {
5+
"directories": [
6+
"src"
7+
]
8+
},
9+
"mutators": {
10+
"@default": true,
11+
}
12+
}

src/TextUI/Output/Printer/DefaultPrinter.php

+2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ public static function standardError(): self
7070
private function __construct(string $out)
7171
{
7272
$this->isPhpStream = str_starts_with($out, 'php://');
73+
$x = 1;
7374

7475
if (str_starts_with($out, 'socket://')) {
76+
$x = 2;
7577
$tmp = explode(':', str_replace('socket://', '', $out));
7678

7779
if (count($tmp) !== 2) {

tools/infection.phar

1.01 MB
Binary file not shown.

0 commit comments

Comments
 (0)