1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Test parallelization (#4045)

* Run tests in random order

Being able to run tests in any order is a pre-requisite for being able
to run them in parallel.

* Reset type coverage between tests, fix affected tests

* Reset parser and lexer between test runs and on php version change

Previously lexer was reset, but parser kept the reference to the old
one, and reference to the parser was kept by StatementsProvider. This
resulted in order-dependent tests - if the parser was first initialized
with phpVersion set to 7.4 then arrow functions worked fine, but were
failing when the parser was initially constructed with settings for 7.3

This can be demonstrated on current master by upgrading to
nikic/php-parser:4.9 and running:

```
vendor/bin/phpunit --no-coverage --filter="inferredArgArrowFunction" tests/ClosureTest.php
```

Now all tests using PHP 7.4 features must set the PHP version
accordingly.

* Marked more tests using 7.4 syntax

* Reset newline-between-annotation flag between tests

* Resolve real paths before passing them to checkPaths

When checkPaths is called from psalm.php the paths are resolved, so we
just mimicking SUT behaviour here.

* Restore newline-between-annotations in DocCommentTest

* Tweak Appveyor caches

* Tweak TravisCI caches

* Tweak CircleCI caches

* Run tests in parallel

Use `vendor/bin/paratest` instead of `vendor/bin/phpunit`

* Use default paratest runner on Windows

WrapperRunner is not supported on Windows.

* TRAVIS_TAG could be empty

* Restore appveyor conditional caching
This commit is contained in:
Bruce Weirdan 2020-08-23 17:32:07 +03:00 committed by Daniil Gentili
parent bcc9c413ad
commit dabfb16e34
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
50 changed files with 200 additions and 84 deletions

View File

@ -18,13 +18,13 @@ environment:
DEPS: 'high'
cache:
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
- composer.phar
- '%LOCALAPPDATA%\Composer\files'
- '%LOCALAPPDATA%\Composer\vcs'
# Cache chocolatey packages
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
- C:\ProgramData\chocolatey\bin
- C:\ProgramData\chocolatey\lib
# Cache php install
- c:\tools\php -> .appveyor.yml
- c:\tools\php
## Install PHP and composer, and run the appropriate composer command
install:
@ -45,18 +45,17 @@ install:
- IF %PHP%==1 echo assert.exception=On >> php.ini
- IF %PHP%==1 echo error_reporting=E_ALL >> php.ini
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer-stable.phar -FileName composer.phar
- IF NOT EXIST composer.phar appveyor-retry appveyor DownloadFile https://getcomposer.org/composer-stable.phar -FileName composer.phar
- cd c:\projects\php-project-workspace
- php -r "phpinfo(INFO_GENERAL);"
- if NOT DEFINED APPVEYOR_REPO_TAG_NAME (set COMPOSER_ROOT_VERSION=dev-master)
- if %DEPS%==low appveyor-retry composer update --no-interaction --prefer-source --no-progress --profile --prefer-lowest --prefer-stable
- if %DEPS%==high appveyor-retry composer update --no-interaction --prefer-source --no-progress --profile
- composer show
- if %DEPS%==low appveyor-retry composer update --no-interaction --no-progress --profile --prefer-lowest --prefer-stable
- if %DEPS%==high appveyor-retry composer update --no-interaction --no-progress --profile
## Run the actual test
test_script:
- cd c:\projects\php-project-workspace
- vendor/bin/phpunit --log-junit build/phpunit/phpunit.xml
- vendor/bin/paratest --log-junit build/phpunit/phpunit.xml
- php ./psalm --shepherd
on_finish:

View File

@ -15,24 +15,27 @@ jobs:
- run: date "+%F" > /tmp/cachekey; cat composer.json >> /tmp/cachekey
- restore_cache:
keys:
- composer-v2-{{ checksum "/tmp/cachekey" }}
# fallback to using the latest cache if no exact match is found (See https://circleci.com/docs/2.0/caching/)
- composer-v2-
- composer-v3
- restore_cache:
keys:
- psalm-cache-{{ checksum "/tmp/cachekey" }} # speeds up run with --diff and --diff-methods
- run: composer update
- save_cache:
key: composer-v2-{{ checksum "/tmp/cachekey" }}
key: composer-v3
paths:
- vendor
- /home/docker/.composer/cache/files
- /home/docker/.composer/cache/vcs
- run:
name: Static analysis
command: php -dextension=pcntl.so ./psalm --threads=10 --diff --diff-methods
- save_cache:
key: psalm-cache-{{ checksum "/tmp/cachekey" }}
paths:
- /tmp/psalm
- run:
name: Static analysis
command: php -dextension=pcntl.so ./psalm --threads=10 --diff --diff-methods
- persist_to_workspace:
root: /home/docker/project/
paths:
@ -52,7 +55,7 @@ jobs:
at: /home/docker/project/
- run:
name: PHPUnit test
command: php vendor/bin/phpunit --log-junit build/phpunit/phpunit.xml
command: php vendor/bin/paratest --runner=WrapperRunner --log-junit build/phpunit/phpunit.xml
- store_test_results:
path: build/
- store_artifacts:

View File

@ -3,14 +3,15 @@ language: php
env:
global:
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-suggest --prefer-source"
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-suggest --prefer-dist"
- XDEBUG="false"
# generated with travis encrypt -r vimeo/psalm --org GITHUB_TOKEN="<secret oauth token>"
- secure: Ayjp10v6IWeJX3ThWvPxlv0gkuTuvu30lsdQCjop+vS0Kv+6/IEOdSOxtm0tEWacq9EFCViWRKh9zxiwPtoi0wxGdzGGws+UtIJxew6Vy8HDCEH8nY4k50eElKUWI4YhVbiSdZEZ+Bd9kO0qGEBH9iWh8Tc8MP2Hklx7lOf+zUTSm8vpv+idcCxwGCvQMaMc5NhfnkgGq95/UU3iOvCi5/wkIFnSnoccxmZE2zsxI1e355ipa0uoe8/Ml6vK0NrZ0aBZwZfItsIuhRcL4Cm5kyar+Ao/mn9Zw8CHbfESrIMomRI7ZxwPNFj+sR/wCvEasIGHRxH8B9F4d8SmAoHR1CrmM/zyWRon73CfRb56M4VGG1hyqTr1GYHpBgZKSOYA8TKyOjD8EHGvevfHpJoGVNxf0+vAfdizlVJvkYhzSz/VjpOZO8rfOct4deNcpCVuVGg5uOGeg5P7coVniGHLHTm3JozK9Ia+ZLePtr3l/NuoW5dXVF1fdroCyQS2X0VSXALnnTPzcIQYsmpCk8yJ8uXorxj4dJHhstyll1jemJjxT7HJ1ASPUOTsPu9u9EoBDHQxOGa5b2/7chyV+EhrYV899RKZ4xEPzpC619sWgtZJci3oLcebU1BY42pIr94UqtwcJKhriwV72VpKvCG/eqOKLhXq355TYRx2dK05a5w=
cache:
directories:
- ./vendor
- $(composer config cache-files-dir)
- $(composer config cache-vcs-dir)
before_install:
# determine INI file
@ -23,7 +24,6 @@ before_install:
- if [[ "$XDEBUG" = 'false' && -f $INI_DIR/xdebug.ini ]]; then phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION = nightly ]]; then export DEFAULT_COMPOSER_FLAGS="$DEFAULT_COMPOSER_FLAGS --ignore-platform-reqs"; fi
- composer validate
- composer clear-cache
install:
@ -31,7 +31,7 @@ install:
- if [[ "$DEPS" = 'low' ]]; then travis_retry composer $DEFAULT_COMPOSER_FLAGS --prefer-lowest --prefer-stable update; fi
script:
- vendor/bin/phpunit
- vendor/bin/paratest --runner=WrapperRunner
- ./psalm
# Additional stages

View File

@ -9,7 +9,7 @@
beStrictAboutTodoAnnotatedTests="true"
colors="true"
verbose="true"
executionOrder="default"
executionOrder="random"
>
<testsuites>
<testsuite name="psalm">

View File

@ -1335,8 +1335,19 @@ class ProjectAnalyzer
list($php_major_version, $php_minor_version) = explode('.', $version);
$this->codebase->php_major_version = (int) $php_major_version;
$this->codebase->php_minor_version = (int) $php_minor_version;
$php_major_version = (int) $php_major_version;
$php_minor_version = (int) $php_minor_version;
if ($this->codebase->php_major_version !== $php_major_version
|| $this->codebase->php_minor_version !== $php_minor_version
) {
// reset lexer and parser when php version changes
\Psalm\Internal\Provider\StatementsProvider::clearLexer();
\Psalm\Internal\Provider\StatementsProvider::clearParser();
}
$this->codebase->php_major_version = $php_major_version;
$this->codebase->php_minor_version = $php_minor_version;
}
/**

View File

@ -25,7 +25,7 @@ class PropertyMap
}
/** @var array<string, array<string, string>> */
$property_map = require_once(__DIR__ . '/../PropertyMap.php');
$property_map = require(__DIR__ . '/../PropertyMap.php');
self::$property_map = [];

View File

@ -73,7 +73,7 @@ class BuildInfoCollector
$this->readEnv['TRAVIS'] = $this->env['TRAVIS'];
$this->readEnv['TRAVIS_JOB_ID'] = $this->env['TRAVIS_JOB_ID'];
$this->readEnv['CI_NAME'] = $this->env['CI_NAME'];
$this->readEnv['TRAVIS_TAG'] = $this->env['TRAVIS_TAG'];
$this->readEnv['TRAVIS_TAG'] = $this->env['TRAVIS_TAG'] ?? '';
$repo_slug = (string) $this->env['TRAVIS_REPO_SLUG'];

View File

@ -1089,10 +1089,12 @@ class FileReferenceProvider
self::$references_to_mixed_member_names = [];
self::$class_method_locations = [];
self::$class_property_locations = [];
self::$class_locations = [];
self::$analyzed_methods = [];
self::$issues = [];
self::$file_maps = [];
self::$method_param_uses = [];
self::$classlike_files = [];
self::$mixed_counts = [];
}
}

View File

@ -464,4 +464,9 @@ class StatementsProvider
{
self::$lexer = null;
}
public static function clearParser(): void
{
self::$parser = null;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Psalm\Internal;
abstract class RuntimeCaches
{
public static function clearAll(): void
{
\Psalm\IssueBuffer::clearCache();
\Psalm\Internal\Codebase\Reflection::clearCache();
\Psalm\Internal\Codebase\Functions::clearCache();
\Psalm\Internal\Type\TypeTokenizer::clearCache();
\Psalm\Internal\Provider\FileReferenceProvider::clearCache();
\Psalm\Internal\FileManipulation\FileManipulationBuffer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
\Psalm\Internal\FileManipulation\PropertyDocblockManipulator::clearCache();
\Psalm\Internal\Analyzer\FileAnalyzer::clearCache();
\Psalm\Internal\Analyzer\FunctionLikeAnalyzer::clearCache();
\Psalm\Internal\Provider\ClassLikeStorageProvider::deleteAll();
\Psalm\Internal\Provider\FileStorageProvider::deleteAll();
\Psalm\Internal\Provider\StatementsProvider::clearLexer();
\Psalm\Internal\Provider\StatementsProvider::clearParser();
\Psalm\Internal\Scanner\ParsedDocblock::resetNewlineBetweenAnnotations();
}
}

View File

@ -88,4 +88,9 @@ class ParsedDocblock
{
static::$shouldAddNewLineBetweenAnnotations = $should;
}
public static function resetNewlineBetweenAnnotations(): void
{
static::$shouldAddNewLineBetweenAnnotations = true;
}
}

View File

@ -1295,6 +1295,9 @@ class ArrayFunctionCallTest extends TestCase
$dateTimes
);
}',
'assertions' => [],
'error_levels' => [],
'7.4',
],
'arrayPad' => [
'<?php
@ -1576,6 +1579,8 @@ class ArrayFunctionCallTest extends TestCase
'$a' => 'array<int, B>',
'$b' => 'array<int, B>',
],
'error_levels' => [],
'7.4',
],
'arrayMergeTwoExplicitLists' => [
'<?php
@ -1614,7 +1619,10 @@ class ArrayFunctionCallTest extends TestCase
$as = ["key"];
$bs = ["value"];
return array_map(fn ($a, $b) => [$a => $b], $as, $bs);'
return array_map(fn ($a, $b) => [$a => $b], $as, $bs);',
'assertions' => [],
'error_levels' => [],
'7.4',
],
'allowUnpackWithArrayKey' => [
'<?php
@ -1879,7 +1887,10 @@ class ArrayFunctionCallTest extends TestCase
'<?php
$list = [3, 2, 5, 9];
usort($list, fn(int $a, string $b): int => (int) ($a > $b));',
'error_message' => 'InvalidScalarArgument'
'error_message' => 'InvalidScalarArgument',
2 => [],
3 => false,
4 => '7.4',
],
'usortInvalidComparison' => [
'<?php

View File

@ -253,7 +253,10 @@ class BinaryOperationTest extends TestCase
function foo(?string $s): string {
$s ??= "Hello";
return $s;
}'
}',
'assertions' => [],
'error_levels' => [],
'7.4',
],
'nullCoalescingArrayAssignment' => [
'<?php
@ -266,7 +269,10 @@ class BinaryOperationTest extends TestCase
foreach ($arr as $a) {
$b[0] ??= $a;
}
}'
}',
'assertions' => [],
'error_levels' => [],
'7.4',
],
'addArrays' => [
'<?php

View File

@ -56,6 +56,9 @@ class CallableTest extends TestCase
fn(string $a) => $a . "blah",
$bar
);',
'assertions' => [],
'error_levels' => [],
'7.4',
],
'varReturnType' => [
'<?php
@ -76,6 +79,8 @@ class CallableTest extends TestCase
'assertions' => [
'$a' => 'int',
],
'error_levels' => [],
'7.4',
],
'varCallableParamReturnType' => [
'<?php
@ -111,6 +116,9 @@ class CallableTest extends TestCase
function foo() {
return fn(string $a): string => $a . "blah";
}',
'assertions' => [],
'error_levels' => [],
'7.4',
],
'callable' => [
'<?php

View File

@ -58,6 +58,9 @@ class ClosureTest extends TestCase
fn(string $a) => $a . "blah",
$bar
);',
'assertions' => [],
'error_levels' => [],
'7.4'
],
'varReturnType' => [
'<?php
@ -78,6 +81,8 @@ class ClosureTest extends TestCase
'assertions' => [
'$a' => 'int',
],
'error_levels' => [],
'7.4'
],
'correctParamType' => [
'<?php
@ -167,6 +172,9 @@ class ClosureTest extends TestCase
function foo(Closure $f, Closure $g) : Closure {
return fn(int $x):int => $f($g($x));
}',
'assertions' => [],
'error_levels' => [],
'7.4'
],
'returnsTypedClosureWithClasses' => [
'<?php

View File

@ -7,6 +7,8 @@ use function getcwd;
use const PHP_EOL;
use Psalm\Config;
use Psalm\Internal\PluginManager\ConfigFile;
use Psalm\Internal\RuntimeCaches;
use function sys_get_temp_dir;
use function tempnam;
use function trim;
@ -21,6 +23,7 @@ class ConfigFileTest extends \Psalm\Tests\TestCase
/** @return void */
public function setUp() : void
{
RuntimeCaches::clearAll();
$this->file_path = tempnam(sys_get_temp_dir(), 'psalm-test-config');
}

View File

@ -14,6 +14,7 @@ use function preg_match;
use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function realpath;
@ -49,7 +50,7 @@ class ConfigTest extends \Psalm\Tests\TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -6,6 +6,7 @@ use Psalm\Config;
use Psalm\Internal\PluginManager\ComposerLock;
use Psalm\Internal\PluginManager\ConfigFile;
use Psalm\Internal\PluginManager\PluginList;
use Psalm\Internal\RuntimeCaches;
/** @group PluginManager */
class PluginListTest extends \Psalm\Tests\TestCase
@ -21,6 +22,8 @@ class PluginListTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
RuntimeCaches::clearAll();
$this->config = $this->prophesize(Config::class);
$this->config->getPluginClasses()->willReturn([]);

View File

@ -17,6 +17,7 @@ use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\IncludeCollector;
use Psalm\Internal\RuntimeCaches;
use Psalm\Plugin\Hook\AfterCodebasePopulatedInterface;
use Psalm\PluginRegistrationSocket;
use Psalm\Tests\Internal\Provider;
@ -54,7 +55,7 @@ class PluginTest extends \Psalm\Tests\TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -3,10 +3,16 @@ namespace Psalm\Tests;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Psalm\DocComment;
use Psalm\Internal\RuntimeCaches;
use Psalm\Internal\Scanner\ParsedDocblock;
class DocCommentTest extends BaseTestCase
{
public function setUp(): void
{
RuntimeCaches::clearAll();
}
public function testNewLineIsAddedBetweenAnnotationsByDefault(): void
{
$docComment = new ParsedDocblock(

View File

@ -25,6 +25,8 @@ use function array_shift;
use DOMDocument;
use DOMXPath;
use DOMAttr;
use Psalm\Internal\RuntimeCaches;
use function array_filter;
use function var_export;
@ -80,8 +82,7 @@ class DocumentationTest extends TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();

View File

@ -20,6 +20,7 @@ use function unlink;
use function file_get_contents;
use function file_put_contents;
use function preg_replace;
use const PHP_VERSION_ID;
/**
* Tests some of the most important use cases of the psalm and psalter commands, by launching a new
@ -120,7 +121,9 @@ class PsalmEndToEndTest extends TestCase
public function testPsalmDiff(): void
{
$this->markTestSkipped('Only works on 7.4');
if (PHP_VERSION_ID < 70400) {
$this->markTestSkipped('Only works on 7.4+');
}
copy(__DIR__ . '/../fixtures/DummyProjectWithErrors/diff_composer.lock', self::$tmpDir . '/composer.lock');

View File

@ -7,6 +7,7 @@ use Prophecy\Prophecy\ObjectProphecy;
use Psalm\ErrorBaseline;
use Psalm\Exception\ConfigException;
use Psalm\Internal\Provider\FileProvider;
use Psalm\Internal\RuntimeCaches;
class ErrorBaselineTest extends TestCase
{
@ -18,6 +19,7 @@ class ErrorBaselineTest extends TestCase
*/
public function setUp() : void
{
RuntimeCaches::clearAll();
$this->fileProvider = $this->prophesize(FileProvider::class);
}

View File

@ -3,6 +3,7 @@ namespace Psalm\Tests\FileManipulation;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function strpos;
@ -14,8 +15,7 @@ class ClassConstantMoveTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -3,6 +3,7 @@ namespace Psalm\Tests\FileManipulation;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function strpos;
@ -14,8 +15,7 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -3,6 +3,7 @@ namespace Psalm\Tests\FileManipulation;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function strpos;
@ -14,9 +15,7 @@ abstract class FileManipulationTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
\Psalm\Internal\FileManipulation\PropertyDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -3,6 +3,7 @@ namespace Psalm\Tests\FileManipulation;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function strpos;
@ -14,8 +15,7 @@ class MethodMoveTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -3,6 +3,7 @@ namespace Psalm\Tests\FileManipulation;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function strpos;
@ -14,8 +15,7 @@ class NamespaceMoveTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -3,6 +3,7 @@ namespace Psalm\Tests\FileManipulation;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function strpos;
@ -14,8 +15,7 @@ class PropertyMoveTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}

View File

@ -4,6 +4,7 @@ namespace Psalm\Tests;
use function count;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use function strpos;
@ -17,8 +18,7 @@ class FileReferenceTest extends TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
\Psalm\Internal\FileManipulation\FunctionDocblockManipulator::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();

View File

@ -20,8 +20,6 @@ class AnalyzedMethodTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -20,8 +20,6 @@ class CachedStorageTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -21,8 +21,6 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -20,8 +20,6 @@ class ErrorFixTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -23,8 +23,6 @@ class TemporaryUpdateTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -1191,7 +1191,10 @@ class FunctionCallTest extends TestCase
fn (array $matches) => $matches[4],
$ids
);
};'
};',
'assertions' => [],
'error_levels' => [],
'7.4'
],
'compactDefinedVariable' => [
'<?php

View File

@ -4,6 +4,7 @@ namespace Psalm\Tests;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\IssueBuffer;
use Psalm\Tests\Internal\Provider;
use function substr;
@ -17,7 +18,7 @@ class JsonOutputTest extends TestCase
{
// `TestCase::setUp()` creates its own ProjectAnalyzer and Config instance, but we don't want to do that in this
// case, so don't run a `parent::setUp()` call here.
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -6,6 +6,7 @@ use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Provider\Providers;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
@ -18,8 +19,6 @@ class CompletionTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -6,6 +6,7 @@ use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Provider\Providers;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
@ -18,8 +19,6 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
{
parent::setUp();
FileAnalyzer::clearCache();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();
@ -303,7 +302,7 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
$this->assertSame('B\AClass', $symbol_at_position[0]);
}
/**
* @return void
*/
@ -336,7 +335,7 @@ class SymbolLookupTest extends \Psalm\Tests\TestCase
$this->assertSame('B\AClass', $symbol_at_position[0]);
}
/**
* @return void
*/

View File

@ -14,9 +14,11 @@ use Psalm\Codebase;
use Psalm\Config;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\IncludeCollector;
use Psalm\Internal\RuntimeCaches;
use Psalm\Plugin\Hook\AfterCodebasePopulatedInterface;
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\Progress\EchoProgress;
use function realpath;
class ProjectCheckerTest extends TestCase
{
@ -47,7 +49,7 @@ class ProjectCheckerTest extends TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}
@ -321,9 +323,11 @@ class Bat
$this->project_analyzer->progress = new EchoProgress();
ob_start();
// checkPaths expects absolute paths,
// otherwise it's unable to match them against configured folders
$this->project_analyzer->checkPaths([
'tests/fixtures/DummyProject/Bar.php',
'tests/fixtures/DummyProject/SomeTrait.php'
realpath(getcwd() . '/tests/fixtures/DummyProject/Bar.php'),
realpath(getcwd() . '/tests/fixtures/DummyProject/SomeTrait.php'),
]);
$output = ob_get_clean();
@ -359,9 +363,11 @@ class Bat
$this->project_analyzer->progress = new EchoProgress();
ob_start();
// checkPaths expects absolute paths,
// otherwise it's unable to match them against configured folders
$this->project_analyzer->checkPaths([
'tests/fixtures/DummyProject/Bar.php',
'tests/fixtures/DummyProject/SomeTrait.php'
realpath(getcwd() . '/tests/fixtures/DummyProject/Bar.php'),
realpath(getcwd() . '/tests/fixtures/DummyProject/SomeTrait.php'),
]);
$output = ob_get_clean();

View File

@ -9,6 +9,7 @@ use Psalm\Internal\PluginManager\Command\EnableCommand;
use Psalm\Internal\PluginManager\Command\ShowCommand;
use Psalm\Internal\PluginManager\PluginList;
use Psalm\Internal\PluginManager\PluginListFactory;
use Psalm\Internal\RuntimeCaches;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Tester\CommandTester;
@ -26,6 +27,7 @@ class PsalmPluginTest extends TestCase
public function setUp() : void
{
RuntimeCaches::clearAll();
$this->plugin_list = $this->prophesize(PluginList::class);
$this->plugin_list_factory = $this->prophesize(PluginListFactory::class);
$this->plugin_list_factory->__invoke(Argument::any(), Argument::any())->willReturn($this->plugin_list->reveal());

View File

@ -6,6 +6,7 @@ use DOMDocument;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\IssueBuffer;
use Psalm\Report;
use Psalm\Report\JsonReport;
@ -28,7 +29,7 @@ class ReportOutputTest extends TestCase
{
// `TestCase::setUp()` creates its own ProjectAnalyzer and Config instance, but we don't want to do that in this
// case, so don't run a `parent::setUp()` call here.
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -744,6 +744,8 @@ class ReturnTypeTest extends TestCase
'assertions' => [
'$res' => 'Closure(int):bool',
],
'error_levels' => [],
'7.4'
],
'infersClosureReturnTypesWithPartialTypehinting' => [
'<?php

View File

@ -12,6 +12,7 @@ use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\IncludeCollector;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
class StubTest extends TestCase
@ -40,7 +41,7 @@ class StubTest extends TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();
}
@ -501,6 +502,7 @@ class StubTest extends TestCase
/**
* @return void
* @runInSeparateProcess
*/
public function testPolyfilledFunction()
{
@ -533,6 +535,7 @@ class StubTest extends TestCase
/**
* @return void
* @runInSeparateProcess
*/
public function testConditionalConstantDefined()
{
@ -564,6 +567,7 @@ class StubTest extends TestCase
/**
* @return void
* @runInSeparateProcess
*/
public function testClassAlias()
{

View File

@ -12,6 +12,7 @@ use Psalm\Config;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Provider\Providers;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use RuntimeException;
@ -60,9 +61,7 @@ class TestCase extends BaseTestCase
{
parent::setUp();
FileAnalyzer::clearCache();
\Psalm\Internal\Provider\StatementsProvider::clearLexer();
RuntimeCaches::clearAll();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
@ -85,7 +84,7 @@ class TestCase extends BaseTestCase
public function tearDown() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
}
/**

View File

@ -3,6 +3,8 @@ namespace Psalm\Tests;
use function function_exists;
use function print_r;
use Psalm\Internal\RuntimeCaches;
use Psalm\Type;
use function stripos;
@ -13,6 +15,7 @@ class TypeParseTest extends TestCase
*/
public function setUp() : void
{
RuntimeCaches::clearAll();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();
$config = new TestConfig();

View File

@ -1,6 +1,8 @@
<?php
namespace Psalm\Tests\TypeReconciliation;
use Psalm\Internal\RuntimeCaches;
class ValueTest extends \Psalm\Tests\TestCase
{
use \Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
@ -8,7 +10,7 @@ class ValueTest extends \Psalm\Tests\TestCase
public function setUp() : void
{
\Psalm\Internal\Analyzer\FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new \Psalm\Tests\Internal\Provider\FakeFileProvider();

View File

@ -4,6 +4,7 @@ namespace Psalm\Tests;
use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
class UnusedCodeTest extends TestCase
@ -16,7 +17,7 @@ class UnusedCodeTest extends TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();

View File

@ -5,6 +5,7 @@ use function preg_quote;
use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Internal\RuntimeCaches;
use Psalm\Tests\Internal\Provider;
use function strpos;
@ -18,7 +19,7 @@ class UnusedVariableTest extends TestCase
*/
public function setUp() : void
{
FileAnalyzer::clearCache();
RuntimeCaches::clearAll();
$this->file_provider = new Provider\FakeFileProvider();

View File

@ -37,6 +37,7 @@ class VariadicTest extends TestCase
/**
* @throws \Psalm\Exception\ConfigException
* @return void
* @runInSeparateProcess
*/
public function testVariadicFunctionFromAutoloadFile()
{