File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -193,10 +193,13 @@ final public function testSniff()
193
193
$ fixedFile = $ testFile .'.fixed ' ;
194
194
$ filename = basename ($ testFile );
195
195
if (file_exists ($ fixedFile ) === true ) {
196
- $ diff = $ phpcsFile ->fixer ->generateDiff ($ fixedFile );
197
- if (trim ($ diff ) !== '' ) {
198
- $ fixedFilename = basename ($ fixedFile );
199
- $ failureMessages [] = "Fixed version of $ filename does not match expected version in $ fixedFilename; the diff is \n$ diff " ;
196
+ if ($ phpcsFile ->fixer ->getContents () !== file_get_contents ($ fixedFile )) {
197
+ // Only generate the (expensive) diff if a difference is expected.
198
+ $ diff = $ phpcsFile ->fixer ->generateDiff ($ fixedFile );
199
+ if (trim ($ diff ) !== '' ) {
200
+ $ fixedFilename = basename ($ fixedFile );
201
+ $ failureMessages [] = "Fixed version of $ filename does not match expected version in $ fixedFilename; the diff is \n$ diff " ;
202
+ }
200
203
}
201
204
} else if (is_callable ([$ this , 'addWarning ' ]) === true ) {
202
205
$ this ->addWarning ("Missing fixed version of $ filename to verify the accuracy of fixes, while the sniff is making fixes against the test case file " );
You can’t perform that action at this time.
0 commit comments