Skip to content

Commit 036b6a9

Browse files
[PhpUnitBridge] Kill the last concurrent process when it stales for more than 60s
1 parent 8e93517 commit 036b6a9

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
398398
}
399399
}
400400

401+
$lastOutput = null;
402+
$lastOutputTime = null;
403+
401404
while ($runningProcs) {
402405
usleep(300000);
403406
$terminatedProcs = [];
@@ -410,6 +413,26 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
410413
}
411414
}
412415

416+
if (!$terminatedProcs && 1 === count($runningProcs)) {
417+
$component = key($runningProcs);
418+
419+
$output = file_get_contents("$component/phpunit.stdout");
420+
$output .= file_get_contents("$component/phpunit.stderr");
421+
422+
if ($lastOutput !== $output) {
423+
$lastOutput = $output;
424+
$lastOutputTime = microtime(true);
425+
} elseif (microtime(true) - $lastOutputTime > 60) {
426+
echo "\033[41mTimeout\033[0m $component\n\n";
427+
428+
if ('\\' === \DIRECTORY_SEPARATOR) {
429+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $procStatus['pid']), $output, $exitCode);
430+
} else {
431+
proc_terminate(current($runningProcs));
432+
}
433+
}
434+
}
435+
413436
foreach ($terminatedProcs as $component => $procStatus) {
414437
foreach (['out', 'err'] as $file) {
415438
$file = "$component/phpunit.std$file";

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ public function testInvalidCwd()
6666
$cmd->run();
6767
}
6868

69+
/**
70+
* @group transient-on-windows
71+
*/
6972
public function testThatProcessDoesNotThrowWarningDuringRun()
7073
{
71-
if ('\\' === \DIRECTORY_SEPARATOR) {
72-
$this->markTestSkipped('This test is transient on Windows');
73-
}
7474
@trigger_error('Test Error', \E_USER_NOTICE);
7575
$process = $this->getProcessForCode('sleep(3)');
7676
$process->run();
@@ -130,12 +130,11 @@ public function testStopWithTimeoutIsActuallyWorking()
130130
$this->assertLessThan(15, microtime(true) - $start);
131131
}
132132

133+
/**
134+
* @group transient-on-windows
135+
*/
133136
public function testWaitUntilSpecificOutput()
134137
{
135-
if ('\\' === \DIRECTORY_SEPARATOR) {
136-
$this->markTestIncomplete('This test is too transient on Windows, help wanted to improve it');
137-
}
138-
139138
$p = $this->getProcess([self::$phpBin, __DIR__.'/KillableProcessWithOutput.php']);
140139
$p->start();
141140

@@ -1538,6 +1537,9 @@ public function testEnvCaseInsensitiveOnWindows()
15381537
}
15391538
}
15401539

1540+
/**
1541+
* @group transient-on-windows
1542+
*/
15411543
public function testNotTerminableInputPipe()
15421544
{
15431545
$process = $this->getProcess('echo foo');

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