Skip to content

Commit e9b6c7c

Browse files
committed
merged branch Seldaek/windows-tests (PR #7847)
This PR was merged into the master branch. Discussion ---------- Windows test fixes I checked all components/bundles/bridges.. Now everything is green except a few things still in Process that I wasn't sure what to do with yet. Commits ------- ae1624f [Process] Fix tests on windows 08e95db [Finder] Fix tests on windows e8b07a0 [Filesystem] Fix tests on windows 7b83b72 [Console] Fix tests on windows
2 parents 1362b38 + ae1624f commit e9b6c7c

File tree

7 files changed

+57
-13
lines changed

7 files changed

+57
-13
lines changed

src/Symfony/Component/Console/Tests/Command/ListCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public function testExecuteListsCommandsWithRawOption()
4444
4545
EOF;
4646

47-
$this->assertEquals(str_replace("\n", PHP_EOL, $output), $commandTester->getDisplay());
47+
$this->assertEquals($output, $commandTester->getDisplay(true));
4848
}
4949
}

src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testDescribeApplication(DescriptorInterface $descriptor, Applica
5454
$command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
5555
}
5656

57-
$this->assertEquals(trim($expectedDescription), trim($descriptor->describe($application)));
57+
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $descriptor->describe($application))));
5858
}
5959

6060
public function getDescribeInputArgumentTestData()

src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ public function testRenderProvider()
176176

177177
protected function getOutputStream()
178178
{
179-
return new StreamOutput($this->stream);
179+
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);
180180
}
181181

182182
protected function getOutputContent(StreamOutput $output)
183183
{
184184
rewind($output->getStream());
185185

186-
return stream_get_contents($output->getStream());
186+
return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream()));
187187
}
188188
}

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,11 @@ public function testDumpFile()
905905

906906
$this->assertFileExists($filename);
907907
$this->assertSame('bar', file_get_contents($filename));
908-
$this->assertEquals(753, $this->getFilePermissions($filename));
908+
909+
// skip mode check on windows
910+
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
911+
$this->assertEquals(753, $this->getFilePermissions($filename));
912+
}
909913
}
910914

911915
public function testDumpFileOverwritesAnExistingFile()

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ public function getTestPathData()
722722
*/
723723
public function testAccessDeniedException(Adapter\AdapterInterface $adapter)
724724
{
725+
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
726+
$this->markTestSkipped('chmod is not supported on windows');
727+
}
728+
725729
$finder = $this->buildFinder($adapter);
726730
$finder->files()->in(self::$tmpDir);
727731

@@ -744,6 +748,10 @@ public function testAccessDeniedException(Adapter\AdapterInterface $adapter)
744748
*/
745749
public function testIgnoredAccessDeniedException(Adapter\AdapterInterface $adapter)
746750
{
751+
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
752+
$this->markTestSkipped('chmod is not supported on windows');
753+
}
754+
747755
$finder = $this->buildFinder($adapter);
748756
$finder->files()->ignoreUnreadableDirs()->in(self::$tmpDir);
749757

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,19 @@ public function testCallbackIsExecutedForOutput()
136136

137137
public function testGetErrorOutput()
138138
{
139-
$p = new Process(sprintf('php -r %s', escapeshellarg('ini_set(\'display_errors\',\'on\'); $n = 0; while ($n < 3) { echo $a; $n++; }')));
139+
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
140140

141141
$p->run();
142-
$this->assertEquals(3, preg_match_all('/PHP Notice/', $p->getErrorOutput(), $matches));
142+
$this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches));
143143
}
144144

145145
public function testGetIncrementalErrorOutput()
146146
{
147-
$p = new Process(sprintf('php -r %s', escapeshellarg('ini_set(\'display_errors\',\'on\'); usleep(50000); $n = 0; while ($n < 3) { echo $a; $n++; }')));
147+
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
148148

149149
$p->start();
150150
while ($p->isRunning()) {
151-
$this->assertLessThanOrEqual(1, preg_match_all('/PHP Notice/', $p->getIncrementalOutput(), $matches));
151+
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches));
152152
usleep(20000);
153153
}
154154
}
@@ -431,6 +431,10 @@ public function testGetPidIsNullAfterRun()
431431

432432
public function testSignal()
433433
{
434+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
435+
$this->markTestSkipped('POSIX signals do not work on windows');
436+
}
437+
434438
$process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php');
435439
$process->start();
436440
usleep(500000);
@@ -448,6 +452,10 @@ public function testSignal()
448452
*/
449453
public function testSignalProcessNotRunning()
450454
{
455+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
456+
$this->markTestSkipped('POSIX signals do not work on windows');
457+
}
458+
451459
$process = $this->getProcess('php -m');
452460
$process->signal(SIGHUP);
453461
}
@@ -457,6 +465,10 @@ public function testSignalProcessNotRunning()
457465
*/
458466
public function testSignalWithWrongIntSignal()
459467
{
468+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
469+
$this->markTestSkipped('POSIX signals do not work on windows');
470+
}
471+
460472
$process = $this->getProcess('php -r "sleep(3);"');
461473
$process->start();
462474
$process->signal(-4);
@@ -467,6 +479,10 @@ public function testSignalWithWrongIntSignal()
467479
*/
468480
public function testSignalWithWrongNonIntSignal()
469481
{
482+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
483+
$this->markTestSkipped('POSIX signals do not work on windows');
484+
}
485+
470486
$process = $this->getProcess('php -r "sleep(3);"');
471487
$process->start();
472488
$process->signal('Céphalopodes');

src/Symfony/Component/Process/Tests/ProcessBuilderTest.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,18 @@ public function testPrefixIsPrependedToAllGeneratedProcess()
122122
$pb->setPrefix('/usr/bin/php');
123123

124124
$proc = $pb->setArguments(array('-v'))->getProcess();
125-
$this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
125+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
126+
$this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine());
127+
} else {
128+
$this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
129+
}
126130

127131
$proc = $pb->setArguments(array('-i'))->getProcess();
128-
$this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
132+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
133+
$this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine());
134+
} else {
135+
$this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
136+
}
129137
}
130138

131139
public function testShouldEscapeArguments()
@@ -167,14 +175,22 @@ public function testShouldNotThrowALogicExceptionIfNoArgument()
167175
->setPrefix('/usr/bin/php')
168176
->getProcess();
169177

170-
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
178+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
179+
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
180+
} else {
181+
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
182+
}
171183
}
172184

173185
public function testShouldNotThrowALogicExceptionIfNoPrefix()
174186
{
175187
$process = ProcessBuilder::create(array('/usr/bin/php'))
176188
->getProcess();
177189

178-
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
190+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
191+
$this->assertEquals('"/usr/bin/php"', $process->getCommandLine());
192+
} else {
193+
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
194+
}
179195
}
180196
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy