File tree Expand file tree Collapse file tree 2 files changed +44
-8
lines changed Expand file tree Collapse file tree 2 files changed +44
-8
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,17 @@ public function runPHPCS()
126
126
Timing::printRunTime ();
127
127
}
128
128
} catch (DeepExitException $ e ) {
129
- echo $ e ->getMessage ();
130
- return $ e ->getCode ();
129
+ $ exitCode = $ e ->getCode ();
130
+ $ message = $ e ->getMessage ();
131
+ if ($ message !== '' ) {
132
+ if ($ exitCode === 0 ) {
133
+ echo $ e ->getMessage ();
134
+ } else {
135
+ StatusWriter::write ($ e ->getMessage (), 0 , 0 );
136
+ }
137
+ }
138
+
139
+ return $ exitCode ;
131
140
}//end try
132
141
133
142
if ($ numErrors === 0 ) {
@@ -212,8 +221,17 @@ public function runPHPCBF()
212
221
Timing::printRunTime ();
213
222
}
214
223
} catch (DeepExitException $ e ) {
215
- echo $ e ->getMessage ();
216
- return $ e ->getCode ();
224
+ $ exitCode = $ e ->getCode ();
225
+ $ message = $ e ->getMessage ();
226
+ if ($ message !== '' ) {
227
+ if ($ exitCode === 0 ) {
228
+ echo $ e ->getMessage ();
229
+ } else {
230
+ StatusWriter::write ($ e ->getMessage (), 0 , 0 );
231
+ }
232
+ }
233
+
234
+ return $ exitCode ;
217
235
}//end try
218
236
219
237
if ($ this ->reporter ->totalFixed === 0 ) {
Original file line number Diff line number Diff line change 10
10
11
11
use PHP_CodeSniffer \Runner ;
12
12
use PHP_CodeSniffer \Tests \Core \Runner \AbstractRunnerTestCase ;
13
+ use PHP_CodeSniffer \Tests \Core \StatusWriterTestHelper ;
13
14
14
15
/**
15
16
* Tests for the "All files were excluded" error message.
18
19
*/
19
20
final class RunAllFilesExcludedErrorTest extends AbstractRunnerTestCase
20
21
{
22
+ use StatusWriterTestHelper;
21
23
22
24
23
25
/**
@@ -41,6 +43,8 @@ public function testPhpcs($sourceDir, $extraArgs)
41
43
$ runner = new Runner ();
42
44
$ runner ->runPHPCS ();
43
45
46
+ $ this ->verifyOutput ();
47
+
44
48
}//end testPhpcs()
45
49
46
50
@@ -66,6 +70,8 @@ public function testPhpcbf($sourceDir, $extraArgs)
66
70
$ runner = new Runner ();
67
71
$ runner ->runPHPCBF ();
68
72
73
+ $ this ->verifyOutput ();
74
+
69
75
}//end testPhpcbf()
70
76
71
77
@@ -111,12 +117,24 @@ private function setupTest($sourceDir, $extraArgs)
111
117
$ _SERVER ['argv ' ][] = $ arg ;
112
118
}
113
119
114
- $ message = 'ERROR: No files were checked. ' .PHP_EOL ;
115
- $ message .= 'All specified files were excluded or did not match filtering rules. ' .PHP_EOL .PHP_EOL ;
116
-
117
- $ this ->expectOutputString ($ message );
120
+ $ this ->expectNoStdoutOutput ();
118
121
119
122
}//end setupTest()
120
123
121
124
125
+ /**
126
+ * Helper method to verify the output expectation for STDERR.
127
+ *
128
+ * @return void
129
+ */
130
+ private function verifyOutput ()
131
+ {
132
+ $ expected = 'ERROR: No files were checked. ' .PHP_EOL ;
133
+ $ expected .= 'All specified files were excluded or did not match filtering rules. ' .PHP_EOL .PHP_EOL ;
134
+
135
+ $ this ->assertStderrOutputSameString ($ expected );
136
+
137
+ }//end verifyOutput()
138
+
139
+
122
140
}//end class
You can’t perform that action at this time.
0 commit comments