Skip to content

Commit 8588a4f

Browse files
[Process] Don't catch RuntimeException when it complicates tests debugging
1 parent f8a7ddb commit 8588a4f

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

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

+19-28
Original file line numberDiff line numberDiff line change
@@ -152,46 +152,37 @@ public function testSignalWithWrongNonIntSignal()
152152

153153
public function testStopTerminatesProcessCleanly()
154154
{
155-
try {
156-
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
157-
$process->run(function () use ($process) {
158-
$process->stop();
159-
});
160-
} catch (\RuntimeException $e) {
161-
$this->fail('A call to stop() is not expected to cause wait() to throw a RuntimeException');
162-
}
155+
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
156+
$process->run(function () use ($process) {
157+
$process->stop();
158+
});
159+
$this->assertTrue(true, 'A call to stop() is not expected to cause wait() to throw a RuntimeException');
163160
}
164161

165162
public function testKillSignalTerminatesProcessCleanly()
166163
{
167164
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
168165

169-
try {
170-
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
171-
$process->run(function () use ($process) {
172-
if ($process->isRunning()) {
173-
$process->signal(defined('SIGKILL') ? SIGKILL : 9);
174-
}
175-
});
176-
} catch (\RuntimeException $e) {
177-
$this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException');
178-
}
166+
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
167+
$process->run(function () use ($process) {
168+
if ($process->isRunning()) {
169+
$process->signal(defined('SIGKILL') ? SIGKILL : 9);
170+
}
171+
});
172+
$this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
179173
}
180174

181175
public function testTermSignalTerminatesProcessCleanly()
182176
{
183177
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
184178

185-
try {
186-
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
187-
$process->run(function () use ($process) {
188-
if ($process->isRunning()) {
189-
$process->signal(defined('SIGTERM') ? SIGTERM : 15);
190-
}
191-
});
192-
} catch (\RuntimeException $e) {
193-
$this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException');
194-
}
179+
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
180+
$process->run(function () use ($process) {
181+
if ($process->isRunning()) {
182+
$process->signal(defined('SIGTERM') ? SIGTERM : 15);
183+
}
184+
});
185+
$this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
195186
}
196187

197188
public function testStopWithTimeoutIsActuallyWorking()

0 commit comments

Comments
 (0)