Skip to content

Mutate the classes of a project whose path holds a comma - #35

Merged
vlsi merged 1 commit into
cribro-dev:mainfrom
vlsi:mutable-code-path-comma
Dec 1, 2026
Merged

vlsi merged 1 commit into
cribro-dev:mainfrom
vlsi:mutable-code-path-comma

Conversation

@vlsi

@vlsi vlsi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

In a project whose directory path holds a comma, pitestDiff and cribro:pitest-diff mutated nothing and reported no mutant: no changed line has bytecode PIT may mutate, because PIT splits --mutableCodePaths at commas. A { in the path made PIT fail with a PatternSyntaxException, and a ^ or a | matched nothing, since PIT turns each entry into a regular expression without escaping them.

Each path now goes to PIT as ~ followed by Pattern.quote of the path, with every comma written as \x2C and every plus as \x2B, since Glob escapes a + even in the ~ form. The entry matches the path and nothing else. Writing the comma as the glob ? was rejected: it also matches a sibling directory whose name has another character there, and the test has such a sibling.

Scope. PIT splits --sourceDirs at commas too and has no escape for them, so in such a project PIT's HTML report, which the mutation report links, shows a mutated file without its source, or with the source of a file of the same name in another directory, such as an older checkout proj beside proj,v2. Leaving such directories out was rejected: with every directory left out the value is empty, which PIT reads as its working directory, and without the option PIT fails with a NullPointerException. Reported upstream as hcoles/pitest#1516.

Fixes #30

🤖 Generated with Claude Code

In a project whose directory path held a comma, pitestDiff and
cribro:pitest-diff mutated nothing and reported

    no mutant: no changed line has bytecode PIT may mutate

PIT splits --mutableCodePaths at commas, so .../a,b/build/classes/java/main
reached it as two entries that match no classpath entry. A path with a {
made PIT fail with a PatternSyntaxException, and one with a ^ or a |
matched nothing, since PIT turns each entry into a regular expression
without escaping them.

PIT reads an entry that starts with ~ as a regular expression, so each
path now goes to PIT as ~ followed by Pattern.quote of the path, with
every comma written as \x2C and every plus as \x2B: PIT escapes a + even
in that form. The entry matches the path and nothing else. Writing the
comma as the glob ? was rejected: it also matches a sibling directory
whose name has another character there.
Leaving a source directory with a comma out of --sourceDirs was
rejected too: with every directory left out the value is empty, which
PIT reads as its working directory, and without the option PIT fails
with a NullPointerException.

User-visible:
In a project whose directory path holds a comma, a brace, a caret, or a vertical bar, pitestDiff and cribro:pitest-diff mutate the changed lines.

Not changed:
PIT splits --sourceDirs at commas too and has no escape for them, so in a project whose path holds a comma, PIT's HTML report shows a mutated file without its source, or with the source of a file of the same name in another directory.

Fixes cribro-dev#30

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vlsi
vlsi force-pushed the mutable-code-path-comma branch from a1211c5 to e84e750 Compare December 1, 2026 08:36
@vlsi vlsi added the bug Something isn't working label Dec 1, 2026
@vlsi
vlsi merged commit a0f2fb9 into cribro-dev:main Dec 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pitestDiff reports no mutant when the project directory contains a comma

1 participant