Include mutant string names in json representation
Hi, I’d be interested in taking this on if it’s still open.
My understanding is that you’d like the same human-readable mutant name string that cargo mutants --list prints (and that --re / --exclude-re match against) to be included as a field in the JSON representation – i.e., in the --list --json output and in mutants.out/mutants.json.
A couple of quick scoping questions:
- Do you have any preference for the field name? I’d default to something simple like
name. - Should this name string live only in the mutant definition JSON (
--list --json+mutants.json), with tools joining that tooutcomes.jsonas needed, or would you also like it duplicated in each entry inoutcomes.jsonfor convenience when post-processing results?
If this matches your intent, I’m happy to work on a PR.
Yes, that all sounds good. I'd like it in both mutants and outcomes.
WIP PR https://github.com/sourcefrog/cargo-mutants/pull/564/files is adding dynamically generated fields to the generated JSON and shows a place they could be added.
Thanks for the pointer to #564, that helps a lot.
Would you prefer that I:
- help with #564 (tests/wiring/docs) to get it over the line first, and then add the
namefield on top of that,
or - go ahead with this issue now, following the same pattern as in #564, and rebase/adjust once it’s merged?
Happy to do whichever is more useful for you. 🙂
Actually I think we could just store the name string into the object when it's constructed, and let it be serialized by serde.
Message ID: @.***>
Got it, that sounds good.
I’ll add a name: String field to Mutant and populate it when mutants are constructed, reusing the same formatting as the current --list output. That way serde will include it automatically in --list --json and mutants.json, and I can also reuse the stored name when building outcomes.json entries.
I’ll open a PR once that’s implemented and the tests are passing.