Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON logger, useful for CI and analyzing results of Infection programmatically #1278

Merged
merged 1 commit into from Jul 5, 2020

Conversation

maks-rafalko
Copy link
Member

@maks-rafalko maks-rafalko commented Jul 3, 2020

This PR:

Example of report JSON file
{
    "stats": {
        "totalMutantsCount": 10,
        "killedCount": 2,
        "notTestedCount": 2,
        "escapedCount": 2,
        "errorCount": 2,
        "timeOutCount": 2,
        "msi": 60,
        "mutationCodeCoverage": 80,
        "coveredCodeMsi": 75
    },
    "escaped": [
        {
            "mutator": {
                "mutatorName": "PregQuote",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 9
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'escaped#1';",
            "processOutput": "process output"
        },
        {
            "mutator": {
                "mutatorName": "For_",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 10
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'escaped#0';",
            "processOutput": "process output"
        }
    ],
    "timeouted": [
        {
            "mutator": {
                "mutatorName": "PregQuote",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 9
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'timedOut#1';",
            "processOutput": "process output"
        },
        {
            "mutator": {
                "mutatorName": "For_",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 10
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'timedOut#0';",
            "processOutput": "process output"
        }
    ],
    "killed": [
        {
            "mutator": {
                "mutatorName": "PregQuote",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 9
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'killed#1';",
            "processOutput": "process output"
        },
        {
            "mutator": {
                "mutatorName": "For_",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 10
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'killed#0';",
            "processOutput": "process output"
        }
    ],
    "errored": [
        {
            "mutator": {
                "mutatorName": "PregQuote",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 9
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'error#1';",
            "processOutput": "process output"
        },
        {
            "mutator": {
                "mutatorName": "For_",
                "originalSourceCode": "<?php $a = 1;",
                "mutatedSourceCode": "<?php $a = 2;",
                "originalFilePath": "foo\/bar",
                "originalStartLine": 10
            },
            "diff": "--- Original\n+++ New\n@@ @@\n\n- echo 'original';\n+ echo 'error#0';",
            "processOutput": "process output"
        }
    ],
    "uncovered": []
}x

Can be useful for CI and any other place where results of Mutation Testing need to be analyzed programmatically.

Personally, I'm building something new for Infection, so this report covers 100% of my needs. This report is used to build such UI

example

@maks-rafalko maks-rafalko added this to the 0.17.0 milestone Jul 3, 2020
@sanmai sanmai self-requested a review July 4, 2020 03:31
@maks-rafalko maks-rafalko force-pushed the feature/json-logger branch 2 times, most recently from dd2d5d7 to 9bee64b Compare July 4, 2020 19:26
@maks-rafalko
Copy link
Member Author

Added docs.

Thank you, @sanmai.

@maks-rafalko maks-rafalko merged commit 33ba2d3 into master Jul 5, 2020
@maks-rafalko maks-rafalko deleted the feature/json-logger branch July 5, 2020 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants