mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 09:55:37 +08:00
fix windows test failures: path separators and arch normalization
This commit is contained in:
@@ -327,7 +327,7 @@ class Artifact
|
|||||||
public function getSourceRoot(): string
|
public function getSourceRoot(): string
|
||||||
{
|
{
|
||||||
if (isset($this->config['metadata']['source-root'])) {
|
if (isset($this->config['metadata']['source-root'])) {
|
||||||
return $this->getSourceDir() . '/' . ltrim($this->config['metadata']['source-root'], '/');
|
return FileSystem::convertPath($this->getSourceDir() . '/' . ltrim($this->config['metadata']['source-root'], '/'));
|
||||||
}
|
}
|
||||||
return $this->getSourceDir();
|
return $this->getSourceDir();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,8 +223,8 @@ class ArtifactCache
|
|||||||
public function getCacheFullPath(array $cache_info): string
|
public function getCacheFullPath(array $cache_info): string
|
||||||
{
|
{
|
||||||
return match ($cache_info['cache_type']) {
|
return match ($cache_info['cache_type']) {
|
||||||
'archive', 'file' => DOWNLOAD_PATH . '/' . $cache_info['filename'],
|
'archive', 'file' => FileSystem::convertPath(DOWNLOAD_PATH . '/' . $cache_info['filename']),
|
||||||
'git' => DOWNLOAD_PATH . '/' . $cache_info['dirname'],
|
'git' => FileSystem::convertPath(DOWNLOAD_PATH . '/' . $cache_info['dirname']),
|
||||||
'local' => $cache_info['dirname'], // local dirname is absolute path
|
'local' => $cache_info['dirname'], // local dirname is absolute path
|
||||||
default => throw new SPCInternalException("Unknown cache type: {$cache_info['cache_type']}"),
|
default => throw new SPCInternalException("Unknown cache type: {$cache_info['cache_type']}"),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -254,11 +254,16 @@ class ArtifactTest extends TestCase
|
|||||||
ApplicationContext::initialize();
|
ApplicationContext::initialize();
|
||||||
ApplicationContext::set(ArtifactCache::class, $cache);
|
ApplicationContext::set(ArtifactCache::class, $cache);
|
||||||
|
|
||||||
|
// Use a platform-appropriate absolute path: a Unix-style /tmp/... isn't
|
||||||
|
// absolute on Windows (no drive letter), so the test would otherwise
|
||||||
|
// fall through into the SOURCE_PATH-prefixed branch on Windows.
|
||||||
|
$extract = DIRECTORY_SEPARATOR === '\\' ? 'C:\tmp\my-pkg-extract' : '/tmp/my-pkg-extract';
|
||||||
|
|
||||||
$artifact = new Artifact('my-pkg', [
|
$artifact = new Artifact('my-pkg', [
|
||||||
'source' => ['type' => 'url', 'url' => 'https://example.com/file.tar.gz', 'extract' => '/tmp/my-pkg-extract'],
|
'source' => ['type' => 'url', 'url' => 'https://example.com/file.tar.gz', 'extract' => $extract],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$expected = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, '/tmp/my-pkg-extract');
|
$expected = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $extract);
|
||||||
$this->assertSame($expected, $artifact->getSourceDir());
|
$this->assertSame($expected, $artifact->getSourceDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,11 +708,7 @@ class ArtifactTest extends TestCase
|
|||||||
'Windows' => 'windows',
|
'Windows' => 'windows',
|
||||||
default => 'linux',
|
default => 'linux',
|
||||||
};
|
};
|
||||||
$arch = php_uname('m');
|
return "{$os}-" . arch2gnu(php_uname('m'));
|
||||||
if ($arch === 'arm64') {
|
|
||||||
$arch = 'aarch64';
|
|
||||||
}
|
|
||||||
return "{$os}-{$arch}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function injectArtifactConfig(string $name, array $config): void
|
private function injectArtifactConfig(string $name, array $config): void
|
||||||
|
|||||||
Reference in New Issue
Block a user