From b395596496373aeb90bbdd9fb3fddcfa7c01cb48 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 12:19:11 -0400 Subject: [PATCH] dont use grep -P for cross-platform compatibility `grep -P` gives access to the PCRE matching engine, which is nice, however, the version of grep shipped on many BSD systems (including Darwin) does not have this flag. Currently, `grep -P` was being used in the `_includes()` test helper. For cross platform compatibility in tests, do not rely upon this option. Luckily, all existing tests seem to work fine without it already! --- test/lib/git/shell_shortcuts_test.sh | 2 +- test/support/test_helper.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 3a6843a..834f03b 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -82,7 +82,7 @@ test_ls_with_file_shortcuts() { ls_with_file_shortcuts > $temp_file ls_output=$(<$temp_file strip_colors) - # Compare as fixed strings (F), instead of regex (P) + # Compare as fixed strings (F), instead of normal grep behavior assertIncludes "$ls_output" '[1] a "b"' F assertIncludes "$ls_output" "[2] a 'b'" F assertIncludes "$ls_output" '[3] a [b]' F diff --git a/test/support/test_helper.sh b/test/support/test_helper.sh index 7407b59..cf211a6 100644 --- a/test/support/test_helper.sh +++ b/test/support/test_helper.sh @@ -34,7 +34,7 @@ verboseGitCommands() { #----------------------------------------------------------------------------- _includes() { - if [ -n "$3" ]; then regex="$3"; else regex=P; fi + if [ -n "$3" ]; then regex="$3"; else regex=''; fi if echo "$1" | grep -q$regex "$2"; then echo 0; else echo 1; fi } @@ -46,4 +46,3 @@ assertIncludes() { assertNotIncludes() { assertFalse "'$1' should not have contained '$2'" $(_includes "$@") } -