Skip to content

test: kill the obvious surviving mutants - #15

Merged
nlemoine merged 2 commits into
mainfrom
test/kill-obvious-mutants
Nov 26, 2026
Merged

nlemoine merged 2 commits into
mainfrom
test/kill-obvious-mutants

Conversation

@nlemoine

Copy link
Copy Markdown
Owner

Adds tests for behaviour that Infection showed was not checked. Only tests change, nothing in src/.

Locally, escaped mutants go from 234 to 141 and covered code MSI from 79% to 87%.

Some of the gaps were real contracts. CliResponse::getContent(), getHeaders() and toArray() must throw on 4xx and 5xx by default (Symfony HttpClient contract), and a JsonException could be dropped without any test failing. In the WordPress transport, request_multiple() could ignore each request's headers and data. The Guzzle delay test could not see a missing usleep() because starting the PHP process already takes longer than 100 ms, it now uses 500 ms.

The SEEK_CUR tests for InputStream call stream_seek() on the wrapper directly. fseek() turns SEEK_CUR into SEEK_SET before it reaches a userspace wrapper, so these branches can't be reached otherwise.

I left alone the mutants that behave like the original code: fake stream_stat values, redundant trim() calls, argument positions in InvalidArgument::create(), exception codes.

Writing these tests found two bugs that I did not fix here. Any multipart part with a filename fails with Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed, the existing upload tests catch the exception and pass anyway. And values put in $_ENV by a GlobalsHandler never reach the script, $_SERVER works.

Infection showed behaviour that no test checked: the Symfony response
contract (getContent(), getHeaders() and toArray() throw on 4xx and 5xx
by default), the per-request headers, data and options of WordPress
request_multiple(), data_format query, lowercase content-type, the
default sink rewind and Content-Length drain in the Guzzle handler, the
header and status line parsing of the runtime, and the php:// wrapper
positions. The delay test could not detect a missing usleep() because
spawning the process already took longer than the delay.

Mutants that behave like the original (fake stat values, redundant
trims, argument positions in exception helpers) are left alone. Covered
code MSI goes from 79% to 87% locally.
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.51%. Comparing base (610351e) to head (de3018a).

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #15      +/-   ##
============================================
+ Coverage     93.13%   93.51%   +0.37%     
  Complexity      575      575              
============================================
  Files            16       16              
  Lines          1341     1341              
============================================
+ Hits           1249     1254       +5     
+ Misses           92       87       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

PHP 8.6 adds the error location to json_decode() messages, so the
hard-coded 'Syntax error' failed on the 8.6 job.
@nlemoine
nlemoine merged commit 01ce431 into main Nov 26, 2026
14 checks passed
@nlemoine
nlemoine deleted the test/kill-obvious-mutants branch November 26, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant