Closed richardwerkman closed 4 years ago
Have you considered using Glob ?
It could be more productive and a cleaner solution.
Glob patterns specify sets of filenames with wildcard characters.
It will allow to specify files more concisely instead of specifying all files.
We could merge the 2 options --files-to-mutate
and --files-to-exclude
into one as glob support exclusion via !
example:
--files-to-mutate ["/services/**/*.cs", "!/services/Azure/**/*.cs"]
==> all cs file in services located under services folder except for files under services/Azure folder.
DotNet.Glob could be a solution for this purpose
This is the way it is implemented in JS stryker mutator
After digging into DotNet.Glob, it currently does not support Extended globbing which allow negate feature nativelly.
I think it can be achieve in negating match if pattern starts with an !
Great idea! I think it will be a little more complex, but also better in usage.
We should think about cases like, what if a file is both included and excluded. And what if a file is included in an excluded folder? Or the other way around.
By default it should be that all files are mutated. And when one or more globs like: "/services/**/*.cs"
are presented, all other files should be excluded.
Could this be extended to also specify which segments of the files should be included/excluded?
This could be useful in a pull request build where you only want to include mutations for the changed code to minimize the burden on the developer, since he only has to worry about his own changes. Also this would reduce the amount of mutation stryker would have to check and thus improve the performance.
Maybe something like this: /services/MyService.cs{234..238}
where 234 to 238 is the span that would be included.
That might be awkward to use with wildcards though.
Our vision for pull request builds is the option to scan git history for changed files/file spans and only mutate those lines. I don't think any user would ever do that by hand because it might take more time to add the exclusion/inclusion than the time it takes to run stryker on it :p
But since you already added it 🤷♀
My thoughts exactly. My plan was to build a script which feeds stryker the files and spans which have changed in a PR, to keep the FilePattern feature itself as generic as possible.
But if you have already envisioned a feature like that, we could also open a new Issue and make it an official feature of stryker.NET.
@anhaehne I've created an issue for the git diff feature! Feel free to think with us about how we could implement this.
Implemented by #662 and released since version 0.13.0
Introduction
Currenty it is possible to exclude files. This makes filtering possible so we can specify a few files not to mutate if these for example contain logic that aren't needed to be tested (like a
startup.cs
).Issue
We wish to expand this feature by specifying what files should be mutated. All other files should be excluded. This can be useful on large projects. When a developer made changes in only a few files he could want to do a quick run instead of a full run on all files.
Requirements
--files-to-mutate
/-ftm
should be added which expects a json array of strings.