Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc1d853

Browse filesBrowse files
[Process] Fix transient tests for incremental outputs
1 parent de6e3c8 commit cc1d853
Copy full SHA for cc1d853

File tree

Expand file treeCollapse file tree

3 files changed

+29
-95
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+29
-95
lines changed

‎phpunit

Copy file name to clipboardExpand all lines: phpunit
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if ('phpdbg' === PHP_SAPI) {
2727
$PHP .= ' -qrr';
2828
}
2929

30-
$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `where.exe composer.phar` : `which composer.phar`))
30+
$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar`))
3131
? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER)
3232
: 'composer';
3333

‎src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ public function testVeryLongHosts($host)
16691669
$request = Request::create('/');
16701670
$request->headers->set('host', $host);
16711671
$this->assertEquals($host, $request->getHost());
1672-
$this->assertLessThan(1, microtime(true) - $start);
1672+
$this->assertLessThan(3, microtime(true) - $start);
16731673
}
16741674

16751675
/**

‎src/Symfony/Component/Process/Tests/ProcessTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/ProcessTest.php
+27-93Lines changed: 27 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -290,56 +290,42 @@ public function testGetErrorOutput()
290290
$this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches));
291291
}
292292

293-
public function testGetIncrementalErrorOutput()
293+
/**
294+
* @dataProvider provideIncrementalOutput
295+
*/
296+
public function testIncrementalOutput($getOutput, $getIncrementalOutput, $uri)
294297
{
295-
// use a lock file to toggle between writing ("W") and reading ("R") the
296-
// error stream
297-
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
298-
file_put_contents($lock, 'W');
299-
300-
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
301-
302-
$p->start();
303-
while ($p->isRunning()) {
304-
if ('R' === file_get_contents($lock)) {
305-
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches));
306-
file_put_contents($lock, 'W');
307-
}
308-
usleep(100);
309-
}
310-
311-
unlink($lock);
312-
}
298+
$lock = tempnam(sys_get_temp_dir(), __FUNCTION__);
313299

314-
public function testGetEmptyIncrementalErrorOutput()
315-
{
316-
// use a lock file to toggle between writing ("W") and reading ("R") the
317-
// output stream
318-
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
319-
file_put_contents($lock, 'W');
300+
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('file_put_contents($s = "'.$uri.'", $s); flock(fopen('.var_export($lock, true).', "r"), LOCK_EX); file_put_contents($s, "foo\n");')));
320301

321-
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
302+
$h = fopen($lock, 'w');
303+
flock($h, LOCK_EX);
322304

323305
$p->start();
306+
while (false === strpos($o = $p->$getOutput(), $uri)) {
307+
usleep(1000);
308+
}
309+
$this->assertSame($uri, $p->$getIncrementalOutput());
310+
$this->assertSame('', $p->$getIncrementalOutput());
324311

325-
$shouldWrite = false;
326-
327-
while ($p->isRunning()) {
328-
if ('R' === file_get_contents($lock)) {
329-
if (!$shouldWrite) {
330-
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalOutput(), $matches));
331-
$shouldWrite = true;
332-
} else {
333-
$this->assertSame('', $p->getIncrementalOutput());
312+
flock($h, LOCK_UN);
334313

335-
file_put_contents($lock, 'W');
336-
$shouldWrite = false;
337-
}
338-
}
339-
usleep(100);
314+
while (false === strpos($o = $p->$getOutput(), "foo\n")) {
315+
usleep(1000);
340316
}
317+
$this->assertSame("foo\n", $p->$getIncrementalOutput());
318+
$this->assertSame('', $p->$getIncrementalOutput());
341319

342-
unlink($lock);
320+
fclose($h);
321+
}
322+
323+
public function provideIncrementalOutput()
324+
{
325+
return array(
326+
array('getOutput', 'getIncrementalOutput', 'php://stdout'),
327+
array('getErrorOutput', 'getIncrementalErrorOutput', 'php://stderr'),
328+
);
343329
}
344330

345331
public function testGetOutput()
@@ -350,58 +336,6 @@ public function testGetOutput()
350336
$this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches));
351337
}
352338

353-
public function testGetIncrementalOutput()
354-
{
355-
// use a lock file to toggle between writing ("W") and reading ("R") the
356-
// output stream
357-
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
358-
file_put_contents($lock, 'W');
359-
360-
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
361-
362-
$p->start();
363-
while ($p->isRunning()) {
364-
if ('R' === file_get_contents($lock)) {
365-
$this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches));
366-
file_put_contents($lock, 'W');
367-
}
368-
usleep(100);
369-
}
370-
371-
unlink($lock);
372-
}
373-
374-
public function testGetEmptyIncrementalOutput()
375-
{
376-
// use a lock file to toggle between writing ("W") and reading ("R") the
377-
// output stream
378-
$lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock');
379-
file_put_contents($lock, 'W');
380-
381-
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }')));
382-
383-
$p->start();
384-
385-
$shouldWrite = false;
386-
387-
while ($p->isRunning()) {
388-
if ('R' === file_get_contents($lock)) {
389-
if (!$shouldWrite) {
390-
$this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches));
391-
$shouldWrite = true;
392-
} else {
393-
$this->assertSame('', $p->getIncrementalOutput());
394-
395-
file_put_contents($lock, 'W');
396-
$shouldWrite = false;
397-
}
398-
}
399-
usleep(100);
400-
}
401-
402-
unlink($lock);
403-
}
404-
405339
public function testZeroAsOutput()
406340
{
407341
if ('\\' === DIRECTORY_SEPARATOR) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.