Skip to content

Commit 8b72088

Browse files
committed
Cross platfor fixes
1 parent d174145 commit 8b72088

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/Builder/ServerBuilder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ public function withPluginTools()
119119
$pluginSrcPath = dirname(__DIR__);
120120
$pluginSrcPath = str_replace(ROOT, '', $pluginSrcPath);
121121
$pluginSrcPath = ltrim($pluginSrcPath, DIRECTORY_SEPARATOR);
122+
// Normalize to forward slashes for consistency across platforms
123+
$pluginSrcPath = str_replace(DIRECTORY_SEPARATOR, '/', $pluginSrcPath);
122124

123125
foreach ($scanDirs as $dir) {
124-
$path = $pluginSrcPath . DIRECTORY_SEPARATOR . $dir;
126+
$path = $pluginSrcPath . '/' . $dir;
125127
if (!in_array($path, $this->scanDirs, true)) {
126128
$this->scanDirs[] = $path;
127129
}

tests/TestCase/Builder/ServerBuilderTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ public function testWithPluginToolsDoesNotDuplicate(): void
142142
$scanDirs = $builder->getScanDirs();
143143
$pluginSrcPath = dirname(dirname(dirname(__DIR__))) . '/src';
144144
$pluginSrcPath = ltrim($pluginSrcPath, DIRECTORY_SEPARATOR);
145+
// Normalize to forward slashes for cross-platform consistency
146+
$pluginSrcPath = str_replace(DIRECTORY_SEPARATOR, '/', $pluginSrcPath);
145147

146-
$toolsPath = $pluginSrcPath . DIRECTORY_SEPARATOR . 'Tools';
147-
$promptsPath = $pluginSrcPath . DIRECTORY_SEPARATOR . 'Prompts';
148-
$resourcesPath = $pluginSrcPath . DIRECTORY_SEPARATOR . 'Resources';
148+
$toolsPath = $pluginSrcPath . '/Tools';
149+
$promptsPath = $pluginSrcPath . '/Prompts';
150+
$resourcesPath = $pluginSrcPath . '/Resources';
149151

150152
// Count occurrences of each path - should be 1 each
151153
$toolsCount = count(array_filter($scanDirs, fn(string $dir): bool => $dir === $toolsPath));
@@ -278,10 +280,12 @@ public function testBuildWithPluginTools(): void
278280
// Verify Tools, Prompts, and Resources directories are in scan dirs
279281
$pluginSrcPath = dirname(dirname(dirname(__DIR__))) . '/src';
280282
$pluginSrcPath = ltrim($pluginSrcPath, DIRECTORY_SEPARATOR);
283+
// Normalize to forward slashes for cross-platform consistency
284+
$pluginSrcPath = str_replace(DIRECTORY_SEPARATOR, '/', $pluginSrcPath);
281285

282-
$toolsPath = $pluginSrcPath . DIRECTORY_SEPARATOR . 'Tools';
283-
$promptsPath = $pluginSrcPath . DIRECTORY_SEPARATOR . 'Prompts';
284-
$resourcesPath = $pluginSrcPath . DIRECTORY_SEPARATOR . 'Resources';
286+
$toolsPath = $pluginSrcPath . '/Tools';
287+
$promptsPath = $pluginSrcPath . '/Prompts';
288+
$resourcesPath = $pluginSrcPath . '/Resources';
285289
$this->assertContains($toolsPath, $builder->getScanDirs());
286290
$this->assertContains($promptsPath, $builder->getScanDirs());
287291
$this->assertContains($resourcesPath, $builder->getScanDirs());

tests/TestCase/Documentation/DocumentProcessorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ protected function readTestFile(string $filename): string
5050
$content = file_get_contents($this->docsPath . $filename);
5151
$this->assertNotFalse($content, sprintf('Test file %s not found', $filename));
5252

53-
return $content;
53+
// Normalize line endings for cross-platform consistency
54+
return str_replace("\r\n", "\n", $content);
5455
}
5556

5657
/**

tests/TestCase/Tools/TinkerToolsTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,12 @@ public function testSubprocessFailsWithInvalidPhpBinary(): void
409409
$result = $this->tinkerTools->execute('return 1;');
410410

411411
$this->assertFalse($result['success']);
412-
// Error can be our message or shell's "No such file or directory"
412+
// Error can be our message or shell's error (varies by platform)
413413
$this->assertTrue(
414414
str_contains($result['error'], 'PHP binary') ||
415415
str_contains($result['error'], 'No such file or directory') ||
416-
str_contains($result['error'], 'not found'),
416+
str_contains($result['error'], 'not found') ||
417+
str_contains($result['error'], 'cannot find the path'),
417418
'Expected error about missing PHP binary, got: ' . $result['error'],
418419
);
419420
}
@@ -443,6 +444,10 @@ public function testDefaultTimeoutIsThirtySeconds(): void
443444
*/
444445
public function testExecuteTimeout(): void
445446
{
447+
if (DIRECTORY_SEPARATOR === '\\') {
448+
$this->markTestSkipped('Process timeout behavior differs on Windows');
449+
}
450+
446451
// Use a very short timeout with code that sleeps
447452
$result = $this->tinkerTools->execute('sleep(5); return "done";', 1);
448453

0 commit comments

Comments
 (0)