Skip to content
Permalink
Browse files

Allow backslash after drive name (#1917)

* Allow backslash after drive name

Before, paths like `C:/path/to/something` were considered absolute, but
`C:\path/to/something` were not

Refs #1913

* Revert "Mark testPluginFilenameCanBeAbsolute incomplete on Windows (#1914)"

This reverts commit 210ac39.
  • Loading branch information...
weirdan authored and muglug committed Jul 7, 2019
1 parent 0dfbf48 commit 6a74cf96a1f0ff6e0793d8c678a0d2072dc8a4ac
Showing with 5 additions and 12 deletions.
  1. +1 −1 src/functions.php
  2. +0 −11 tests/Config/PluginTest.php
  3. +4 −0 tests/IsAbsolutePathTest.php
@@ -16,7 +16,7 @@ function isAbsolutePath($path)
$regex = '%^(?<wrappers>(?:[[:print:]]{2,}://)*)';
// Optional root prefix.
$regex .= '(?<root>(?:[[:alpha:]]:/|/)?)';
$regex .= '(?<root>(?:[[:alpha:]]:[\\\/]|[\\\/])?)';
// Actual path.
$regex .= '(?<path>(?:[[:print:]]*))$%';
@@ -4,7 +4,6 @@
use function define;
use function defined;
use const DIRECTORY_SEPARATOR;
use const PHP_OS;
use function dirname;
use function get_class;
use function getcwd;
@@ -18,7 +17,6 @@
use Psalm\Tests\Internal\Provider;
use Psalm\Tests\TestConfig;
use function sprintf;
use function stripos;
class PluginTest extends \Psalm\Tests\TestCase
{
@@ -821,10 +819,6 @@ public function testAfterAnalysisHooks()
*/
public function testPluginFilenameCanBeAbsolute()
{
if ($this->runningOnWindows()) {
$this->markTestIncomplete('Test fails on Windows - see https://github.com/vimeo/psalm/issues/1913');
}
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
@@ -871,9 +865,4 @@ public function testPluginInvalidAbsoluteFilenameThrowsException() : void
$this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer);
}
private function runningOnWindows(): bool
{
return stripos(PHP_OS, 'WIN') === 0;
}
}
@@ -29,6 +29,10 @@ public function providerForTestIsAbsolutePath()
['relative/path/to/something', false],
['relative/path/to/something/file.php', false],
['c:/path/to/something', true],
['C:\path\to\something', true],
['C:\path/to\something', true],
['\path\to\something', true],
['C:\path/to\..\..\something', true],
['file://c:/path/to/something', true],
['zlib://c:/path/to/something', true],
];

0 comments on commit 6a74cf9

Please sign in to comment.
You can’t perform that action at this time.