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

fix windows tests #74

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ os: linux
dist: xenial
language: php

git:
autocrlf: false
Copy link
Contributor

Choose a reason for hiding this comment

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

I had similar issues running the tests locally on windows. It would be great to have a solution which will not only work on travis.

Does #50 Work for your problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had similar issues with other repos as well, that's why my autocrlf setting on windows is set to false by default. It works very well locally too.

I believe it's possible to configure this on a project basis. Based on what I've experienced, I'd recommend setting this to false by default and switching it back(to input or true) on projects that must absolutely have CRLF.

#50 should work too, I just didn't needed it locally so I put the same setting on travis.


stages:
- test
- name: phar
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/LevelsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testLevels(
string $topic
): void
{
$file = sprintf('%s/%s.php', $this->getDataPath(), $topic);
$file = sprintf('%s' . DIRECTORY_SEPARATOR . '%s.php', $this->getDataPath(), $topic);
$command = escapeshellcmd($this->getPhpStanExecutablePath());
$configPath = $this->getPhpStanConfigPath();
$fileHelper = new FileHelper(__DIR__ . '/../..');
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testCollectWarnings(): void
$errors = $this->runAnalyse(__DIR__ . '/data/declaration-warning.php');
$this->assertCount(1, $errors);
$this->assertSame('Declaration of DeclarationWarning\Bar::doFoo(int $i): void should be compatible with DeclarationWarning\Foo::doFoo(): void', $errors[0]->getMessage());
$this->assertSame(__DIR__ . '/data/declaration-warning.php', $errors[0]->getFile());
$this->assertSame(__DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'declaration-warning.php', $errors[0]->getFile());
$this->assertSame(PHP_VERSION_ID >= 70400 ? 22 : 27, $errors[0]->getLine());
}

Expand Down
34 changes: 17 additions & 17 deletions tests/PHPStan/Command/CommandHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,24 @@ public function dataResolveRelativePaths(): array
[
__DIR__ . '/relative-paths/root.neon',
[
'bootstrap' => __DIR__ . '/relative-paths/here.php',
'bootstrap' => __DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
'autoload_files' => [
__DIR__ . '/relative-paths/here.php',
__DIR__ . '/relative-paths/test/there.php',
__DIR__ . '/up.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'here.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'there.php',
__DIR__ . DIRECTORY_SEPARATOR . 'up.php',
],
'autoload_directories' => [
__DIR__ . '/relative-paths/src',
__DIR__ . '/relative-paths',
realpath(__DIR__ . '/../../../conf'),
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'src',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths',
realpath(__DIR__ . '/../../../') . '/conf',
],
'paths' => [
__DIR__ . '/relative-paths/src',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'src',
],
'memoryLimitFile' => __DIR__ . '/relative-paths/.memory_limit',
'memoryLimitFile' => __DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . '.memory_limit',
'excludes_analyse' => [
__DIR__ . '/relative-paths/src',
__DIR__ . '/relative-paths/src/*/data',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'src',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'data',
'*/src/*/data',
],
],
Expand All @@ -186,20 +186,20 @@ public function dataResolveRelativePaths(): array
__DIR__ . '/relative-paths/nested/nested.neon',
[
'autoload_files' => [
__DIR__ . '/relative-paths/nested/here.php',
__DIR__ . '/relative-paths/nested/test/there.php',
__DIR__ . '/relative-paths/up.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'nested' . DIRECTORY_SEPARATOR . 'here.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'nested' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'there.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'up.php',
],
'ignoreErrors' => [
[
'message' => '#aaa#',
'path' => __DIR__ . '/relative-paths/nested/src/aaa.php',
'path' => __DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'nested' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'aaa.php',
],
[
'message' => '#bbb#',
'paths' => [
__DIR__ . '/relative-paths/src/aaa.php',
__DIR__ . '/relative-paths/nested/src/bbb.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'aaa.php',
__DIR__ . DIRECTORY_SEPARATOR . 'relative-paths' . DIRECTORY_SEPARATOR . 'nested' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'bbb.php',
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Node/FileNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getNodeType(): string
public function processNode(Node $node, Scope $scope): array
{
$nodes = $node->getNodes();
$pathHelper = new SimpleRelativePathHelper(__DIR__ . '/data');
$pathHelper = new SimpleRelativePathHelper(__DIR__ . DIRECTORY_SEPARATOR . 'data');
if (!isset($nodes[0])) {
return [
RuleErrorBuilder::message(sprintf('File %s is empty.', $pathHelper->getRelativePath($scope->getFile())))->line(1)->build(),
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testRule(): void
70,
],
[
'Parameter #1 $str of callable class@anonymous/tests/PHPStan/Rules/Functions/data/callables.php:75 expects string, int given.',
'Parameter #1 $str of callable class@anonymous/tests' . DIRECTORY_SEPARATOR . 'PHPStan' . DIRECTORY_SEPARATOR . 'Rules' . DIRECTORY_SEPARATOR . 'Functions' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'callables.php:75 expects string, int given.',
81,
],
[
Expand Down