Git 2.23
[gitweb.git] / t / t7811-grep-open.sh
index 2e5c701566e007905825e79e55a03696895815e8..d1ebfd88c7a9a92a956b92347c4193c6b1d08701 100755 (executable)
@@ -51,19 +51,18 @@ test_expect_success SIMPLEPAGER 'git grep -O' '
        grep.h
        EOF
        echo grep.h >expect.notless &&
-       >empty &&
 
        PATH=.:$PATH git grep -O GREP_PATTERN >out &&
        {
                test_cmp expect.less pager-args ||
                test_cmp expect.notless pager-args
        } &&
-       test_cmp empty out
+       test_must_be_empty out
 '
 
 test_expect_success 'git grep -O --cached' '
        test_must_fail git grep --cached -O GREP_PATTERN >out 2>msg &&
-       grep open-files-in-pager msg
+       test_i18ngrep open-files-in-pager msg
 '
 
 test_expect_success 'git grep -O --no-index' '
@@ -72,7 +71,6 @@ test_expect_success 'git grep -O --no-index' '
        grep.h
        untracked
        EOF
-       >empty &&
 
        (
                GIT_PAGER='\''printf "%s\n" >pager-args'\'' &&
@@ -80,7 +78,7 @@ test_expect_success 'git grep -O --no-index' '
                git grep --no-index -O GREP_PATTERN >out
        ) &&
        test_cmp expect pager-args &&
-       test_cmp empty out
+       test_must_be_empty out
 '
 
 test_expect_success 'setup: fake "less"' '
@@ -96,24 +94,18 @@ test_expect_success 'git grep -O jumps to line in less' '
        +/*GREP_PATTERN
        grep.h
        EOF
-       >empty &&
 
        GIT_PAGER=./less git grep -O GREP_PATTERN >out &&
        test_cmp expect actual &&
-       test_cmp empty out &&
+       test_must_be_empty out &&
 
        git grep -O./less GREP_PATTERN >out2 &&
        test_cmp expect actual &&
-       test_cmp empty out2
+       test_must_be_empty out2
 '
 
 test_expect_success 'modified file' '
        rm -f actual &&
-       cat >less <<-\EOF &&
-       #!/bin/sh
-       printf "%s\n" "$@" >actual
-       EOF
-       chmod +x $less &&
        cat >expect <<-\EOF &&
        +/*enum grep_pat_token
        grep.h
@@ -127,13 +119,22 @@ test_expect_success 'modified file' '
        test_when_finished "git checkout HEAD unrelated" &&
        GIT_PAGER=./less git grep -F -O "enum grep_pat_token" >out &&
        test_cmp expect actual &&
-       test_cmp empty out
+       test_must_be_empty out
+'
+
+test_expect_success 'copes with color settings' '
+       rm -f actual &&
+       echo grep.h >expect &&
+       test_config color.grep always &&
+       test_config color.grep.filename yellow &&
+       test_config color.grep.separator green &&
+       git grep -O'\''printf "%s\n" >actual'\'' GREP_AND &&
+       test_cmp expect actual
 '
 
 test_expect_success 'run from subdir' '
        rm -f actual &&
        echo grep.c >expect &&
-       >empty &&
 
        (
                cd subdir &&
@@ -151,8 +152,8 @@ test_expect_success 'run from subdir' '
                ;;
        esac &&
        test_cmp expect args &&
-       test_cmp empty out &&
-       test_cmp empty out2
+       test_must_be_empty out &&
+       test_must_be_empty out2
 '
 
 test_done