Merge branch 'wc/make-funnynames-shared-lazy-prereq'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 18:33:55 +0000 (11:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 18:33:55 +0000 (11:33 -0700)
A test prerequisite defined by various test scripts with slightly
different semantics has been consolidated into a single copy and
made into a lazily defined one.

* wc/make-funnynames-shared-lazy-prereq:
t: factor out FUNNYNAMES as shared lazy prereq

1  2 
t/t9902-completion.sh
t/t9903-bash-prompt.sh
t/test-lib.sh
diff --combined t/t9902-completion.sh
index 5ff43b9cbbe1693ac23ac7f020522d16424cb936,532df85c43855cbb90d6a329ec363c53cc0bd6ae..175f83d7042a0fb9f093bc6f25e1d0b25ce548af
@@@ -501,42 -501,6 +501,42 @@@ test_expect_success '__gitcomp - suffix
        EOF
  '
  
 +test_expect_success '__gitcomp - ignore optional negative options' '
 +      test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF
 +      --abc Z
 +      --def Z
 +      --no-one Z
 +      --no-... Z
 +      EOF
 +'
 +
 +test_expect_success '__gitcomp - ignore/narrow optional negative options' '
 +      test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF
 +      --abc Z
 +      --abcdef Z
 +      EOF
 +'
 +
 +test_expect_success '__gitcomp - ignore/narrow optional negative options' '
 +      test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF
 +      --no-one Z
 +      --no-... Z
 +      EOF
 +'
 +
 +test_expect_success '__gitcomp - expand all negative options' '
 +      test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF
 +      --no-one Z
 +      --no-two Z
 +      EOF
 +'
 +
 +test_expect_success '__gitcomp - expand/narrow all negative options' '
 +      test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF
 +      --no-one Z
 +      EOF
 +'
 +
  test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
        __gitcomp "$invalid_variable_name"
  '
@@@ -1103,7 -1067,7 +1103,7 @@@ test_expect_success '__git_complete_ref
        master-in-other Z
        EOF
        (
 -              cur=
 +              cur= &&
                __git_complete_refs --remote=other &&
                print_comp
        ) &&
@@@ -1122,7 -1086,7 +1122,7 @@@ test_expect_success '__git_complete_ref
        master-in-other Z
        EOF
        (
 -              cur=
 +              cur= &&
                __git_complete_refs --track &&
                print_comp
        ) &&
@@@ -1278,7 -1242,7 +1278,7 @@@ test_expect_success 'setup for path com
           touch BS\\dir/DQ\"file \
                 '$'separators\034in\035dir/sep\036in\037file''
        then
-               test_set_prereq FUNNYNAMES
+               test_set_prereq FUNNIERNAMES
        else
                rm -rf BS\\dir '$'separators\034in\035dir''
        fi
@@@ -1320,7 -1284,7 +1320,7 @@@ test_expect_success '__git_complete_ind
        test_path_completion árvíztűrő/С "árvíztűrő/Сайн яваарай"
  '
  
- test_expect_success FUNNYNAMES \
+ test_expect_success FUNNIERNAMES \
      '__git_complete_index_file - C-style escapes in ls-files output' '
        test_path_completion BS \
                             BS\\dir &&
                             BS\\dir/DQ\"file
  '
  
- test_expect_success FUNNYNAMES \
+ test_expect_success FUNNIERNAMES \
      '__git_complete_index_file - \nnn-escaped characters in ls-files output' '
        test_path_completion sep '$'separators\034in\035dir'' &&
        test_path_completion '$'separators\034i'' \
@@@ -1434,8 -1398,8 +1434,8 @@@ test_expect_success 'double dash "git c
        --ignore-other-worktrees Z
        --recurse-submodules Z
        --progress Z
 -      --no-track Z
 -      --no-recurse-submodules Z
 +      --no-quiet Z
 +      --no-... Z
        EOF
  '
  
@@@ -1643,7 -1607,6 +1643,7 @@@ test_expect_success 'completion used <c
  test_expect_success 'completion without explicit _git_xxx function' '
        test_completion "git version --" <<-\EOF
        --build-options Z
 +      --no-build-options Z
        EOF
  '
  
diff --combined t/t9903-bash-prompt.sh
index 04440685a66d6baff98c1739979c8f866255572b,994a676a6bfcb76d3e20c4421b859763041d0787..ab890d3d4b3e2a39bb787bd29d7865c46f64c7f6
@@@ -63,18 -63,15 +63,15 @@@ test_expect_success 'prompt - unborn br
        test_cmp expected "$actual"
  '
  
- repo_with_newline='repo
- with
- newline'
- if test_have_prereq !MINGW && mkdir "$repo_with_newline" 2>/dev/null
- then
-       test_set_prereq FUNNYNAMES
- else
+ if test_have_prereq !FUNNYNAMES; then
        say 'Your filesystem does not allow newlines in filenames.'
  fi
  
  test_expect_success FUNNYNAMES 'prompt - with newline in path' '
+     repo_with_newline="repo
+ with
+ newline" &&
+       mkdir "$repo_with_newline" &&
        printf " (master)" >expected &&
        git init "$repo_with_newline" &&
        test_when_finished "rm -rf \"$repo_with_newline\"" &&
@@@ -529,7 -526,7 +526,7 @@@ test_expect_success 'prompt - bash colo
        printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected &&
        (
                GIT_PS1_SHOWCOLORHINTS=y &&
 -              __git_ps1 "BEFORE:" ":AFTER" >"$actual"
 +              __git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
                printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
        ) &&
        test_cmp expected "$actual"
diff --combined t/test-lib.sh
index 78f7097746fc88f1de5321e5f78d9aec8c5e0b5f,f221aa95e51f16cea16c96e28ad6d2c8b20927bf..8bb0f4348e94037ab8877fdb0389bde5a11a86e3
@@@ -675,8 -675,7 +675,8 @@@ test_run_ () 
                trace=
                # 117 is magic because it is unlikely to match the exit
                # code of other programs
 -              if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
 +              if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
 +                      test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
                then
                        error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1"
                fi
@@@ -1104,6 -1103,20 +1104,20 @@@ test_lazy_prereq CASE_INSENSITIVE_FS 
        test "$(cat CamelCase)" != good
  '
  
+ test_lazy_prereq FUNNYNAMES '
+       test_have_prereq !MINGW &&
+       touch -- \
+               "FUNNYNAMES tab embedded" \
+               "FUNNYNAMES \"quote embedded\"" \
+               "FUNNYNAMES newline
+ embedded" 2>/dev/null &&
+       rm -- \
+               "FUNNYNAMES tab embedded" \
+               "FUNNYNAMES \"quote embedded\"" \
+               "FUNNYNAMES newline
+ embedded" 2>/dev/null
+ '
  test_lazy_prereq UTF8_NFD_TO_NFC '
        # check whether FS converts nfd unicode to nfc
        auml=$(printf "\303\244")