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

[Testing] Fix running unit test on macOS #4941

Merged
merged 1 commit into from Sep 9, 2023
Merged

[Testing] Fix running unit test on macOS #4941

merged 1 commit into from Sep 9, 2023

Conversation

samsonasik
Copy link
Member

Running all unit test in macOS currently got error:

There was 1 error:

1) Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TestModifyReprintTest::test
PHPStan\File\CouldNotReadFileException: Could not read file: /Users/samsonasik/www/rector-src/tests/Issues/InfiniteLoop/Fixture/some_method_call_infinity.php

phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/File/FileReader.php:20
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/FileNodesFetcher.php:29
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/OptimizedSingleFileSourceLocator.php:60
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php:26
/Users/samsonasik/www/rector-src/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocator/IntermediateSourceLocator.php:25
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php:26
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/MemoizingSourceLocator.php:33
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/DefaultReflector.php:32
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingReflector.php:45
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php:147
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php:35
/Users/samsonasik/www/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:350
/Users/samsonasik/www/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:185
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:441
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:384
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:612
phar:///Users/samsonasik/www/rector-src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:353
/Users/samsonasik/www/rector-src/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:196
/Users/samsonasik/www/rector-src/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php:43
/Users/samsonasik/www/rector-src/packages/FileSystemRector/Parser/FileInfoParser.php:35
/Users/samsonasik/www/rector-src/packages-tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php:74
/Users/samsonasik/www/rector-src/packages-tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php:48

--

There were 3 failures:

1) Rector\Tests\Parallel\Command\WorkerCommandLineFactoryTest::test with data set #2
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-''/opt/local/bin/php82' 'main_script' '' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi'
+''/opt/local/bin/php82' 'main_script' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi'

/Users/samsonasik/www/rector-src/packages-tests/Parallel/Command/WorkerCommandLineFactoryTest.php:58

2) Rector\Tests\Parallel\Command\WorkerCommandLineFactoryTest::test with data set #1
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-''/opt/local/bin/php82' 'main_script' '' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi'
+''/opt/local/bin/php82' 'main_script' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi'

/Users/samsonasik/www/rector-src/packages-tests/Parallel/Command/WorkerCommandLineFactoryTest.php:58

3) Rector\Tests\Parallel\Command\WorkerCommandLineFactoryTest::test with data set #0
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-''/opt/local/bin/php82' 'main_script' '' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi'
+''/opt/local/bin/php82' 'main_script' worker --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi'

/Users/samsonasik/www/rector-src/packages-tests/Parallel/Command/WorkerCommandLineFactoryTest.php:58

ERRORS!
Tests: 3405, Assertions: 4007, Errors: 1, Failures: 3.
➜  rector-src git:(main) vendor/bin/phpunit packages-tests/Parallel/Command/WorkerCommandLineFactoryTest.php
PHPUnit 10.3.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.5
Configuration: /Users/samsonasik/www/rector-src/phpunit.xml

...                                                                 3 / 3 (100%)

Time: 00:00.161, Memory: 38.00 MB

OK (3 tests, 3 assertions)
➜  rector-src git:(main) 

This patch resolve it.

@samsonasik samsonasik enabled auto-merge (squash) September 9, 2023 07:26
@samsonasik samsonasik merged commit 0a1835f into main Sep 9, 2023
40 checks passed
@samsonasik samsonasik deleted the fix-unit-test branch September 9, 2023 07:28
@staabm
Copy link
Contributor

staabm commented Sep 9, 2023

thanks for fixing it. I have seen this error for a long time, but did not yet have time to resolve it

@@ -55,6 +55,7 @@ public function test(array $inputParameters, string $expectedCommand): void
2000
);

$workerCommandLine = str_replace("'main_script' worker", "'main_script' '' worker", $workerCommandLine);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a notes here that it's macos related? Just to avoid false removal in the future.
Same for the one above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively add a macos github action job

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@staabm That would be great too, but comment is easy pick for warning in case of local cleanup. CI should only verify edge cases, not inform about them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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