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

In Assert.php line 2042: Expected a value other than null. #1357

Closed
terabytesoftw opened this issue Oct 20, 2020 · 14 comments · Fixed by #1358
Closed

In Assert.php line 2042: Expected a value other than null. #1357

terabytesoftw opened this issue Oct 20, 2020 · 14 comments · Fixed by #1358
Milestone

Comments

@terabytesoftw
Copy link

terabytesoftw commented Oct 20, 2020

Question Answer
Infection version 0.18.0
Test Framework version PHPUnit
PHP version 7.4.10
Platform windows-github/actions
Github Repo https://github.com/yiisoft/active-record/runs/1270725926?check_suite_focus=true
Processing source code files: 0
........U.........T..........T...............UU..U   (   50)
UU............................U...........U.......   (  100)
.......................U...U...UUUUUUUUUUUUUUUUUUU   (  150)
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU..   (  200)
...............U.....................UU...........   (  250)
....M................UU...........................   (  300)
......M.............................U.......U....U   (  350)
...............U.........U......U.........U.....UU   (  400)

In Assert.php line 2042:
                                     
  Expected a value other than null.  
                                     

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] [--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]

UUUSS.SSS
Error: Process completed with exit code 1.
@maks-rafalko
Copy link
Member

Hi, after cloning this repository, I can't successfully run phpunit and get:


Runtime:       PHP 7.4.10
Configuration: /tmp/remove/active-record/phpunit.xml.dist

........E

Time: 00:00.040, Memory: 18.00 MB

There was 1 error:

1) Yiisoft\ActiveRecord\Tests\Mssql\ActiveQueryFindTest::testFindAll
Yiisoft\Db\Exception\Exception: could not find driver

There is nothing special in the Unit Testing section https://github.com/yiisoft/active-record#unit-testing, only a note about sqlite3 which is enabled on my machine. Any hints hot to run phpunit successfuly (to be able to run Infection)?

Should I run any docker containers as it's done in GH actions?

@terabytesoftw
Copy link
Author

terabytesoftw commented Oct 20, 2020

Hi, please run:

vendor/bin/phpunit --group sqlite

Since recently the repository was updated and now the complete set runs the tests of redis, mysql, pgsql, mssql, sqlite, i must update the note in the README.md.

Should I run any docker containers as it's done in GH actions?

if you want to run the entire test set if you must configure all containers.

@sanmai
Copy link
Member

sanmai commented Oct 21, 2020

Apparently it's a bug in ArrayItemRemoval.

Here's a stack trace for the error:

In Assert.php line 2042:
                                     
  [InvalidArgumentException]         
  Expected a value other than null.  
                                     

Exception trace:
  at /home/runner/work/active-record/active-record/vendor/webmozart/assert/src/Assert.php:2042
 Webmozart\Assert\Assert::reportInvalidArgument() at /home/runner/work/active-record/active-record/vendor/webmozart/assert/src/Assert.php:600
 Webmozart\Assert\Assert::notNull() at /home/runner/work/active-record/active-record/vendor/webmozart/assert/src/Assert.php:1955
 Webmozart\Assert\Assert::__callStatic() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Mutator/Removal/ArrayItemRemoval.php:110
 Infection\Mutator\Removal\ArrayItemRemoval->mutate() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:137
 Infection\Mutator\NodeMutationGenerator->generateForMutator() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:93
 Infection\Mutator\NodeMutationGenerator->Infection\Mutator\{closure}() at /home/runner/work/active-record/active-record/vendor/sanmai/pipeline/src/Principal.php:93
 Pipeline\Principal::apply() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:94
 Infection\Mutator\NodeMutationGenerator->generate() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/PhpParser/Visitor/MutationCollectorVisitor.php:80
 Infection\PhpParser\Visitor\MutationCollectorVisitor->getMutations() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Mutation/FileMutationGenerator.php:109
 Infection\Mutation\FileMutationGenerator->generate() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Mutation/MutationGenerator.php:100
 Infection\Mutation\MutationGenerator->generate() at /home/runner/work/active-record/active-record/vendor/sanmai/pipeline/src/Principal.php:88
 Pipeline\Principal::apply() at n/a:n/a
 FilterIterator->next() at n/a:n/a
 FilterIterator->next() at n/a:n/a
 FilterIterator->next() at /home/runner/work/active-record/active-record/vendor/sanmai/pipeline/src/Principal.php:88
 Pipeline\Principal::apply() at n/a:n/a
 Generator->next() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Process/Runner/ParallelProcessRunner.php:157
 Infection\Process\Runner\ParallelProcessRunner::fillBucketOnce() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Process/Runner/ParallelProcessRunner.php:97
 Infection\Process\Runner\ParallelProcessRunner->run() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Process/Runner/MutationTestingRunner.php:154
 Infection\Process\Runner\MutationTestingRunner->run() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Engine.php:171
 Infection\Engine->runMutationAnalysis() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Engine.php:111
 Infection\Engine->execute() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Command/RunCommand.php:240
 Infection\Command\RunCommand->executeCommand() at /home/runner/work/active-record/active-record/vendor/infection/infection/src/Command/BaseCommand.php:78
 Infection\Command\BaseCommand->execute() at /home/runner/work/active-record/active-record/vendor/symfony/console/Command/Command.php:258
 Symfony\Component\Console\Command\Command->run() at /home/runner/work/active-record/active-record/vendor/symfony/console/Application.php:920
 Symfony\Component\Console\Application->doRunCommand() at /home/runner/work/active-record/active-record/vendor/symfony/console/Application.php:266
 Symfony\Component\Console\Application->doRun() at /home/runner/work/active-record/active-record/vendor/symfony/console/Application.php:142
 Symfony\Component\Console\Application->run() at /home/runner/work/active-record/active-record/vendor/infection/infection/bin/infection:83

@sanmai
Copy link
Member

sanmai commented Oct 21, 2020

I can reproduce it. Check out the project, install deps, then:

vendor/bin/phpunit --coverage-xml=build/logs/coverage-xml --log-junit=build/logs/junit.xml --colors=always --group sqlite
vendor/bin/infection --threads=2 --coverage=build/logs --show-mutations --no-progress --skip-initial-tests

@sanmai
Copy link
Member

sanmai commented Oct 21, 2020

Problematic line looks like this:

[, $alias] = $this->getTableNameAndAlias();

@terabytesoftw
Copy link
Author

Thks, @maks-rafalko and @sanmai for your great help.

@maks-rafalko
Copy link
Member

Released as 0.18.1. Thank you @terabytesoftw & @sanmai

@maks-rafalko maks-rafalko modified the milestones: 0.19, 0.20.0 Oct 28, 2020
@choks87
Copy link

choks87 commented Feb 10, 2021

I am getting this error again as I upgraded from 0.20 to 0.21

@maks-rafalko
Copy link
Member

Please, provide a reproducible code example.

Also, we have a Playground so if an example is simple, you can create it there

@challgren
Copy link

challgren commented Feb 11, 2021

I get this error too. I'm a brand new user and have infection/infection 0.21.0@dfacb1e3d9def7fd34c6fb8df4d4bd098815dc82 PHPUnit version 8.5.14 PHP 7.4.15 Xdebug 3.0.2 codebase is CakePHP 4.2.2.

challgren@challgren-pro authenticon-web %  XDEBUG_MODE=coverage; vendor/bin/infection

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

Infection - PHP Mutation Testing Framework version 0.21.0@dfacb1e3d9def7fd34c6fb8df4d4bd098815dc82


Running initial test suite...

PHPUnit version: 8.5.14

  173 [============================] 19 secs

Generate mutants...

Processing source code files: 33/36
In Assert.php line 2042:
                                     
  Expected a value other than null.  
                                     

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-base GIT-DIFF-BASE] [--logger-github] [--noop] [--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

maks-rafalko commented Feb 11, 2021

It looks like this issue is project-specific, I mean that Infection is broken on the code from your project, but not for any code.

Can I ask you trying to find the file (and line of the code ideally) that breaks Infection?

if you mutate src folder for example, you can try reduce the number of mutated files folder by folder and find where it breaks.

Also, could you please run Infection with -vvv and past stack trace here?


So, I installed PHP 7.4.15, Xdebug 3.0.2 and PHPUnit 8.5.14 - exactly as you have - and I can't reproduce the issue. So I need your help with identifying the exactly line of code that breaks Infection

@olevv
Copy link

olevv commented Mar 1, 2021

Hi, we also tried to run an infection on the project, but got this error.
How can understand what this is related to?
@maks-rafalko I will be grateful for your help.

bash-5.1# vendor/bin/infection -vvv
[debug] Checking INFECTION_ALLOW_XDEBUG
[debug] The Xdebug extension is loaded (3.0.2)
[debug] Process restarting (INFECTION_ALLOW_XDEBUG=internal|3.0.2|1|*|*)
[debug] Running '/usr/local/bin/php' 'vendor/bin/infection' '-vvv' '--ansi'
[debug] Checking INFECTION_ALLOW_XDEBUG
[debug] Restarted (501 ms). The Xdebug extension is not loaded

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

Infection - PHP Mutation Testing Framework version 0.21.2@c7d3d6ee744e8520e44a4590ac4bb2419e813f1e


Running initial test suite...

PHPUnit version: 9.5.0

  554 [============================] 22 secs

Generate mutants...

Processing source code files: 338/375
In Assert.php line 2042:
                                     
  [InvalidArgumentException]         
  Expected a value other than null.  
                                     

Exception trace:
  at /app/vendor/webmozart/assert/src/Assert.php:2042
 Webmozart\Assert\Assert::reportInvalidArgument() at /app/vendor/webmozart/assert/src/Assert.php:600
 Webmozart\Assert\Assert::notNull() at /app/vendor/infection/infection/src/TestFramework/Coverage/ProxyTrace.php:122
 Infection\TestFramework\Coverage\ProxyTrace->getTestLocator() at /app/vendor/infection/infection/src/TestFramework/Coverage/ProxyTrace.php:111
 Infection\TestFramework\Coverage\ProxyTrace->getAllTestsForMutation() at /app/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:182
 Infection\Mutator\NodeMutationGenerator->getAllTestsForCurrentNode() at /app/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:135
 Infection\Mutator\NodeMutationGenerator->generateForMutator() at /app/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:112
 Infection\Mutator\NodeMutationGenerator->generate() at /app/vendor/infection/infection/src/PhpParser/Visitor/MutationCollectorVisitor.php:80
 Infection\PhpParser\Visitor\MutationCollectorVisitor->getMutations() at /app/vendor/infection/infection/src/Mutation/FileMutationGenerator.php:109
 Infection\Mutation\FileMutationGenerator->generate() at /app/vendor/infection/infection/src/Mutation/MutationGenerator.php:101
 Infection\Mutation\MutationGenerator->generate() at n/a:n/a
 iterator_to_array() at /app/vendor/infection/infection/src/IterableCounter.php:64
 Infection\IterableCounter::bufferAndCountIfNeeded() at /app/vendor/infection/infection/src/Process/Runner/MutationTestingRunner.php:100
 Infection\Process\Runner\MutationTestingRunner->run() at /app/vendor/infection/infection/src/Engine.php:171
 Infection\Engine->runMutationAnalysis() at /app/vendor/infection/infection/src/Engine.php:111
 Infection\Engine->execute() at /app/vendor/infection/infection/src/Command/RunCommand.php:342
 Infection\Command\RunCommand->executeCommand() at /app/vendor/infection/infection/src/Command/BaseCommand.php:75
 Infection\Command\BaseCommand->execute() at /app/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/console/Application.php:971
 Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:290
 Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:166
 Symfony\Component\Console\Application->run() at /app/vendor/infection/infection/bin/infection:83

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-base GIT-DIFF-BASE] [--logger-github] [--noop] [--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]

[debug] Restarted process exited 1

Env:
PHP 8 (Docker from php:8.0.2-fpm-alpine)
Xdebug 3.0.2
PHPUnit 9.5
Symfony 5.2

@sanmai
Copy link
Member

sanmai commented Mar 1, 2021

That looks like #1480

@maks-rafalko
Copy link
Member

Please try 0.21.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants