Skip to content

Commit

Permalink
Merge pull request #504 from Automattic/fix/travis-not-failing-on-fai…
Browse files Browse the repository at this point in the history
…ling-rulesettest
  • Loading branch information
GaryJones authored Jul 22, 2020
2 parents e523148 + 4aed540 commit 2c70364
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions WordPressVIPMinimum/ruleset-test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


<?php // Error - Squiz.WhiteSpace.SuperfluousWhitespace.
$hello = ''; $posts_not_in = ''; $listofthings = ''; $cachedlistofthings = ''; $title = ''; $ch = ''; $thing = ''; $descriptorspec = ''; $pipes = ''; $cwd = ''; $env = ''; $page_title = ''; $menu_title = ''; $capability = ''; $function = ''; $icon_url = ''; $position = ''; $wpdb = ''; $file = ''; $fp = ''; $dir = ''; $test = ''; $post = ''; $bar = ''; $array = []; $query_args = []; $url = ''; $query = ''; $page_title = ''; $true = true; $some_nasty_var = ''; $data = ''; $group = ''; $testing = ''; $this = new stdClass(); $needle = ''; $some_var = ''; $blogid = 1; $text = ''; $category_id = 123; $foo = ''; $bar = ''; $var = ''; $wp_rewrite = ''; $count = 1; $loop = 1; $a = ''; $b = ''; $obj = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- All set for VariableAnalysis checks.
$hello = ''; $posts_not_in = ''; $listofthings = ''; $cachedlistofthings = ''; $title = ''; $ch = ''; $thing = ''; $descriptorspec = ''; $pipes = ''; $cwd = ''; $env = ''; $page_title = ''; $menu_title = ''; $capability = ''; $function = ''; $icon_url = ''; $position = ''; $wpdb = ''; $file = ''; $fp = ''; $dir = ''; $test = ''; $post = ''; $bar = ''; $array = []; $query_args = []; $url = ''; $query = ''; $page_title = ''; $true = true; $some_nasty_var = ''; $data = ''; $group = ''; $testing = ''; $stdClass = new stdClass(); $needle = ''; $some_var = ''; $blogid = 1; $text = ''; $category_id = 123; $foo = ''; $bar = ''; $var = ''; $wp_rewrite = ''; $count = 1; $loop = 1; $a = ''; $b = ''; $obj = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- All set for VariableAnalysis checks.
// Generic.PHP.Syntax
while { // Error.
foreach() { // Error.
}

// Generic.PHP.NoSilencedErrors
Expand Down Expand Up @@ -486,12 +486,12 @@ $query_args = [
];

// WordPressVIPMinimum.Performance.RemoteRequestTimeout
wp_remote_post( $this->endpoint, array(
wp_remote_post( $stdClass->endpoint, array(
'method' => 'POST',
'timeout' => 45, // Error.
'httpversion' => '1.1',
'blocking' => false,
'body' => wp_json_encode( $this->logs, JSON_UNESCAPED_SLASHES ),
'body' => wp_json_encode( $stdClass->logs, JSON_UNESCAPED_SLASHES ),
)
);

Expand Down
3 changes: 1 addition & 2 deletions bin/ruleset-tests
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
PHPCS_BIN="$(pwd)/vendor/bin/phpcs"
export PHPCS_BIN

php ./WordPressVIPMinimum/ruleset-test.php
php ./WordPress-VIP-Go/ruleset-test.php
php ./WordPressVIPMinimum/ruleset-test.php && php ./WordPress-VIP-Go/ruleset-test.php
8 changes: 8 additions & 0 deletions tests/RulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ private function check_missing_expected_values() {
}

foreach ( $lines as $line_number => $expected_count_of_type_violations ) {
if ( 0 === $expected_count_of_type_violations ) {
continue;
}

if ( ! isset( $this->{$type}[ $line_number ] ) ) {
$this->error_warning_message( $expected_count_of_type_violations, $type, 0, $line_number );
} elseif ( $this->{$type}[ $line_number ] !== $expected_count_of_type_violations ) {
Expand All @@ -247,6 +251,10 @@ private function check_missing_expected_values() {
private function check_unexpected_values() {
foreach ( [ 'errors', 'warnings' ] as $type ) {
foreach ( $this->$type as $line_number => $actual_count_of_type_violations ) {
if ( 0 === $actual_count_of_type_violations ) {
continue;
}

if ( ! isset( $this->expected[ $type ][ $line_number ] ) ) {
$this->error_warning_message( 0, $type, $actual_count_of_type_violations, $line_number );
} elseif ( $actual_count_of_type_violations !== $this->expected[ $type ][ $line_number ] ) {
Expand Down

0 comments on commit 2c70364

Please sign in to comment.