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

Error Malformed UTF-8 characters, possibly incorrectly encoded on send Stryke dashboard report with tests that contain invalid UTF-8 characters #1643

Closed
vjik opened this issue Jan 11, 2022 · 2 comments
Assignees
Labels

Comments

@vjik
Copy link

vjik commented Jan 11, 2022

Question Answer
Infection version 0.26.0
Test Framework version PHPUnit 9.5.11
PHP version 7.4.26
Platform Ubuntu
Github Repo -

See here: https://github.com/yiisoft/strings/runs/4777997532?check_suite_focus=true#step:8:198

infection.json
{
    "source": {
        "directories": [
            "src"
        ]
    },
    "logs": {
        "text": "php:\/\/stderr",
        "stryker": {
            "report": "master"
            "badge": "master"
        }
    },
    "mutators": {
        "@default": true
    }
}
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php"
        colors="true"
        verbose="true"
        failOnRisky="true"
        failOnWarning="true"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        stopOnFailure="false"
        executionOrder="random"
        resolveDependencies="true">
   <php>
       <ini name="error_reporting" value="-1"/>
   </php>

   <testsuites>
       <testsuite name="Yii Strings tests">
           <directory>./tests</directory>
       </testsuite>
   </testsuites>

   <coverage>
       <include>
           <directory>./src</directory>
       </include>
   </coverage>
</phpunit>
Output with issue
vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered

   ____      ____          __  _
  /  _/___  / __/__  _____/ /_(_)___  ____
  / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
_/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Infection - PHP Mutation Testing Framework version 0.26.0

Notice:  You are running Infection with PCOV enabled.

Running initial test suite...

PHPUnit version: 9.5.11

.: killed, M: escaped, U: uncovered, E: fatal error, X: syntax error, T: timed out, S: skipped, I: ignored


Generate mutants...

Processing source code files: 0
...................................MM.............   (   50)
.M.............M......M...MM......................   (  100)
..................................................   (  150)
..................................................   (  200)
..................................................   (  250)
..................................................   (  300)
........................M.M.......................   (  350)
....

354 mutations were generated:
    345 mutants were killed
      0 mutants were configured to be ignored
      0 mutants were not covered by tests
      9 covered mutants were not detected
      0 errors were encountered
      0 syntax errors were encountered
      0 time outs were encountered
      0 mutants required more time than configured

Metrics:
        Mutation Score Indicator (MSI): 97%
        Mutation Code Coverage: 100%
        Covered Code MSI: 97%

Please note that some mutants will inevitably be harmless (i.e. false positives).
Escaped mutants:
================

1) /home/runner/work/strings/strings/src/Inflector.php:500    [M] NotIdentical

--- Original
+++ New
Warning:  Sending dashboard report...
@@ @@
    {
        $regex = $strict ? '/(?<=\\p{L})(\\p{Lu})/u' : '/(?<=\\p{L})(?<!\\p{Lu})(\\p{Lu})/u';
        $result = preg_replace($regex, addslashes($separator) . '\\1', $input);
-        if ($separator !== '_') {
+        if ($separator === '_') {
            $result = str_replace('_', $separator, $result);
        }
        return mb_strtolower(trim($result, $separator));


2) /home/runner/work/strings/strings/src/Inflector.php:501    [M] UnwrapStrReplace

--- Original
+++ New
@@ @@
        $regex = $strict ? '/(?<=\\p{L})(\\p{Lu})/u' : '/(?<=\\p{L})(?<!\\p{Lu})(\\p{Lu})/u';
        $result = preg_replace($regex, addslashes($separator) . '\\1', $input);
        if ($separator !== '_') {
-            $result = str_replace('_', $separator, $result);
+            $result = $result;
        }
        return mb_strtolower(trim($result, $separator));
    }


3) /home/runner/work/strings/strings/src/Inflector.php:555    [M] MBString

--- Original
+++ New
@@ @@
    public function toCamelCase(string $input) : string
    {
        $input = $this->toPascalCase($input);
-        return mb_strtolower(mb_substr($input, 0, 1)) . mb_substr($input, 1, null);
+        return strtolower(mb_substr($input, 0, 1)) . mb_substr($input, 1, null);
    }
    /**
     * Returns given word as "snake_cased".


4) /home/runner/work/strings/strings/src/Inflector.php:621    [M] PregQuote

--- Original
+++ New
@@ @@
        // replace all non words character
        $input = preg_replace('/[^a-zA-Z0-9]++/u', $replacement, $this->toTransliterated($input));
        // remove first and last replacements
-        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u' . ($lowercase ? 'i' : ''), '', $input);
+        $input = preg_replace('/^(?:' . $replacement . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u' . ($lowercase ? 'i' : ''), '', $input);
        return $lowercase ? strtolower($input) : $input;
    }
    /**


5) /home/runner/work/strings/strings/src/Inflector.php:621    [M] PregQuote

--- Original
+++ New
@@ @@
        // replace all non words character
        $input = preg_replace('/[^a-zA-Z0-9]++/u', $replacement, $this->toTransliterated($input));
        // remove first and last replacements
-        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u' . ($lowercase ? 'i' : ''), '', $input);
+        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . $replacement . ')++$/u' . ($lowercase ? 'i' : ''), '', $input);
        return $lowercase ? strtolower($input) : $input;
    }
    /**


6) /home/runner/work/strings/strings/src/Inflector.php:621    [M] Ternary

--- Original
+++ New
@@ @@
        // replace all non words character
        $input = preg_replace('/[^a-zA-Z0-9]++/u', $replacement, $this->toTransliterated($input));
        // remove first and last replacements
-        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u' . ($lowercase ? 'i' : ''), '', $input);
+        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u' . ($lowercase ? '' : 'i'), '', $input);
        return $lowercase ? strtolower($input) : $input;
    }
    /**


7) /home/runner/work/strings/strings/src/Inflector.php:621    [M] ConcatOperandRemoval

--- Original
+++ New
@@ @@
        // replace all non words character
        $input = preg_replace('/[^a-zA-Z0-9]++/u', $replacement, $this->toTransliterated($input));
        // remove first and last replacements
-        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u' . ($lowercase ? 'i' : ''), '', $input);
+        $input = preg_replace('/^(?:' . preg_quote($replacement, '/') . ')++|(?:' . preg_quote($replacement, '/') . ')++$/u', '', $input);
        return $lowercase ? strtolower($input) : $input;
    }
    /**


8) /home/runner/work/strings/strings/src/WildcardPattern.php:65    [M] Assignment

--- Original
+++ New
@@ @@
        $pattern = $this->pattern;
        $replacements = ['\\*\\*' => '.*', '\\\\\\\\' => '\\\\', '\\\\\\*' => '[*]', '\\\\\\?' => '[?]', '\\\\\\[' => '[\\[]', '\\\\\\]' => '[\\]]'];
        if ($this->delimiters === []) {
-            $replacements += ['\\*' => '.*', '\\?' => '?'];
+            $replacements = ['\\*' => '.*', '\\?' => '?'];
        } else {
            $notDelimiters = '[^' . preg_quote(implode('', $this->delimiters), '#') . ']';
            $replacements += ['\\*' => "{$notDelimiters}*", '\\?' => $notDelimiters];


9) /home/runner/work/strings/strings/src/WildcardPattern.php:70    [M] PregQuote

--- Original
+++ New
@@ @@
        if ($this->delimiters === []) {
            $replacements += ['\\*' => '.*', '\\?' => '?'];
        } else {
-            $notDelimiters = '[^' . preg_quote(implode('', $this->delimiters), '#') . ']';
+            $notDelimiters = '[^' . implode('', $this->delimiters) . ']';
            $replacements += ['\\*' => "{$notDelimiters}*", '\\?' => $notDelimiters];
        }
        $replacements += ['\\[\\!' => '[^', '\\[' => '[', '\\]' => ']', '\\-' => '-'];


Timed Out mutants:
==================

Skipped mutants:
================

In JsonException.php line 10:
                                                           
 Malformed UTF-8 characters, possibly incorrectly encoded  
                                                           

run [--test-framework TEST-FRAMEWORK] [--test-framework-options TEST-FRAMEWORK-OPTIONS] [-j|--threads THREADS] [--only-covered] [-s|--show-mutations] [--no-progress] [--force-progress] [-c|--configuration CONFIGURATION] [--coverage COVERAGE] [--mutators MUTATORS] [--filter FILTER] [--formatter FORMATTER] [--git-diff-filter GIT-DIFF-FILTER] [--git-diff-lines] [--git-diff-base GIT-DIFF-BASE] [--logger-github] [--logger-html LOGGER-HTML] [--noop] [--only-covering-test-cases] [--min-msi MIN-MSI] [--min-covered-msi MIN-COVERED-MSI] [--log-verbosity LOG-VERBOSITY] [--initial-tests-php-options INITIAL-TESTS-PHP-OPTIONS] [--skip-initial-tests] [--ignore-msi-with-no-mutations] [--debug] [--dry-run]
@maks-rafalko
Copy link
Member

Thank you, please try the new release https://github.com/infection/infection/releases/tag/0.26.1

@vjik
Copy link
Author

vjik commented Jan 12, 2022

Thank you, please try the new release https://github.com/infection/infection/releases/tag/0.26.1

Good work! Thank you for the prompt solution.

ricardoboss pushed a commit to ricardoboss/infection that referenced this issue Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants