Skip to content

Commit 828b752

Browse files
authored
Merge pull request #833 from Automattic/feature/fix-ruleset-test
2 parents 058d2c2 + a057a98 commit 828b752

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ phpunit.xml
77
phpcs.cache
88
phpstan.neon
99
.phpunit.result.cache
10+
ruleset-tests-report.json

tests/RulesetTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,24 @@ private function collect_phpcs_result() {
147147
$php = \PHP_BINARY . ' ';
148148
}
149149

150-
$shell = sprintf(
151-
'%1$s%2$s --severity=1 --standard=%3$s --report=json ./%3$s/ruleset-test.inc',
150+
$report_file = dirname( __DIR__ ) . '/ruleset-tests-report.json';
151+
$shell = sprintf(
152+
'%1$s%2$s --severity=1 --standard=%3$s --report-json=%4$s ./%3$s/ruleset-test.inc',
152153
$php, // Current PHP executable if available.
153154
$this->phpcs_bin,
154-
$this->ruleset
155+
$this->ruleset,
156+
$report_file
155157
);
156158

157159
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_shell_exec -- This is test code, not production.
158-
$output = shell_exec( $shell );
160+
shell_exec( $shell );
161+
162+
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- This code is not run in the context of WP.
163+
$output = file_get_contents( $report_file );
164+
165+
// Delete the report as we no longer need it.
166+
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.WP.AlternativeFunctions.unlink_unlink
167+
@unlink( $report_file );
159168

160169
return json_decode( $output );
161170
}

0 commit comments

Comments
 (0)