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 c29b421

Browse filesBrowse files
committed
minor #10492 [2.3][Process] Remove unreachable code + avoid skipping tests in sigchild environment (romainneutron)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3][Process] Remove unreachable code + avoid skipping tests in sigchild environment | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT As mentioned by @Tobion in #10480 (comment), I removed the dead code. I also fixed/updated the test suite on PHP compiled with `--enable-sigchild`. Commits ------- d52dd32 [Process] Remove unreachable code + avoid skipping tests in sigchild environment
2 parents 8ab7d58 + d52dd32 commit c29b421
Copy full SHA for c29b421

File tree

Expand file treeCollapse file tree

2 files changed

+50
-30
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+50
-30
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,6 @@ public function wait($callback = null)
324324
}
325325

326326
if ($this->processInformation['signaled']) {
327-
if ($this->isSigchildEnabled()) {
328-
throw new RuntimeException('The process has been signaled.');
329-
}
330-
331327
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
332328
}
333329

@@ -1188,7 +1184,7 @@ private function doSignal($signal, $throwException)
11881184

11891185
if (true !== @proc_terminate($this->process, $signal)) {
11901186
if ($throwException) {
1191-
throw new RuntimeException(sprintf('Error while sending signal `%d`.', $signal));
1187+
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
11921188
}
11931189

11941190
return false;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/SimpleProcessTest.php
+49-25Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,106 +27,123 @@ public function setUp()
2727

2828
public function testGetExitCode()
2929
{
30-
$this->skipIfPHPSigchild();
30+
$this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
3131
parent::testGetExitCode();
3232
}
3333

3434
public function testExitCodeCommandFailed()
3535
{
36-
$this->skipIfPHPSigchild();
36+
$this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
3737
parent::testExitCodeCommandFailed();
3838
}
3939

4040
public function testProcessIsSignaledIfStopped()
4141
{
42-
$this->skipIfPHPSigchild();
42+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
4343
parent::testProcessIsSignaledIfStopped();
4444
}
4545

4646
public function testProcessWithTermSignal()
4747
{
48-
$this->skipIfPHPSigchild();
48+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
4949
parent::testProcessWithTermSignal();
5050
}
5151

5252
public function testProcessIsNotSignaled()
5353
{
54-
$this->skipIfPHPSigchild();
54+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
5555
parent::testProcessIsNotSignaled();
5656
}
5757

5858
public function testProcessWithoutTermSignal()
5959
{
60-
$this->skipIfPHPSigchild();
60+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
6161
parent::testProcessWithoutTermSignal();
6262
}
6363

6464
public function testExitCodeText()
6565
{
66-
$this->skipIfPHPSigchild();
66+
$this->skipIfPHPSigchild(); // This test use exitcode that is not available in this case
6767
parent::testExitCodeText();
6868
}
6969

7070
public function testIsSuccessful()
7171
{
72-
$this->skipIfPHPSigchild();
72+
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
7373
parent::testIsSuccessful();
7474
}
7575

7676
public function testIsNotSuccessful()
7777
{
78-
$this->skipIfPHPSigchild();
78+
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
7979
parent::testIsNotSuccessful();
8080
}
8181

8282
public function testGetPid()
8383
{
84-
$this->skipIfPHPSigchild();
84+
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
8585
parent::testGetPid();
8686
}
8787

8888
public function testGetPidIsNullBeforeStart()
8989
{
90-
$this->skipIfPHPSigchild();
90+
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
9191
parent::testGetPidIsNullBeforeStart();
9292
}
9393

9494
public function testGetPidIsNullAfterRun()
9595
{
96-
$this->skipIfPHPSigchild();
96+
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
9797
parent::testGetPidIsNullAfterRun();
9898
}
9999

100100
public function testSignal()
101101
{
102-
$this->skipIfPHPSigchild();
102+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
103103
parent::testSignal();
104104
}
105105

106-
/**
107-
* @expectedException \Symfony\Component\Process\Exception\LogicException
108-
*/
106+
public function testProcessWithoutTermSignalIsNotSignaled()
107+
{
108+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
109+
parent::testProcessWithoutTermSignalIsNotSignaled();
110+
}
111+
112+
public function testProcessThrowsExceptionWhenExternallySignaled()
113+
{
114+
$this->skipIfPHPSigchild(); // This test use PID that is not available in this case
115+
parent::testProcessThrowsExceptionWhenExternallySignaled();
116+
}
117+
118+
public function testExitCodeIsAvailableAfterSignal()
119+
{
120+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
121+
parent::testExitCodeIsAvailableAfterSignal();
122+
}
123+
109124
public function testSignalProcessNotRunning()
110125
{
111-
$this->skipIfPHPSigchild();
126+
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Can not send signal on a non running process.');
112127
parent::testSignalProcessNotRunning();
113128
}
114129

115-
/**
116-
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
117-
*/
118130
public function testSignalWithWrongIntSignal()
119131
{
120-
$this->skipIfPHPSigchild();
132+
if ($this->enabledSigchild) {
133+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
134+
} else {
135+
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `-4`.');
136+
}
121137
parent::testSignalWithWrongIntSignal();
122138
}
123139

124-
/**
125-
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
126-
*/
127140
public function testSignalWithWrongNonIntSignal()
128141
{
129-
$this->skipIfPHPSigchild();
142+
if ($this->enabledSigchild) {
143+
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
144+
} else {
145+
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'Error while sending signal `Céphalopodes`.');
146+
}
130147
parent::testSignalWithWrongNonIntSignal();
131148
}
132149

@@ -144,4 +161,11 @@ private function skipIfPHPSigchild()
144161
$this->markTestSkipped('Your PHP has been compiled with --enable-sigchild, this test can not be executed');
145162
}
146163
}
164+
165+
private function expectExceptionIfPHPSigchild($classname, $message)
166+
{
167+
if ($this->enabledSigchild) {
168+
$this->setExpectedException($classname, $message);
169+
}
170+
}
147171
}

0 commit comments

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