Skip to content

Commit

Permalink
Merge pull request #130 from wp-cli/fix/strip-ansi-colors-on-string-c…
Browse files Browse the repository at this point in the history
…omparison

Strip ANSI colors on string comparison
  • Loading branch information
schlessera authored Jul 26, 2021
2 parents 2668bf5 + deb529b commit 1374d75
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Context/Support.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ protected function assert_not_numeric( $actual ) {
}

protected function check_string( $output, $expected, $action, $message = false ) {
// Strip ANSI color codes before comparing strings.
$output = preg_replace( '/\e[[][A-Za-z0-9];?[0-9]*m?/', '', $output );

switch ( $action ) {
case 'be':
$r = rtrim( $output, "\n" ) === $expected;
Expand Down

0 comments on commit 1374d75

Please sign in to comment.