diff options
-rwxr-xr-x | scripts/vim-patch.sh | 50 | ||||
-rw-r--r-- | src/nvim/testdir/runtest.vim | 51 | ||||
-rw-r--r-- | src/nvim/testdir/test_arglist.vim | 1 |
3 files changed, 69 insertions, 33 deletions
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index eeb77dbbdc..6218ba378a 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -30,9 +30,9 @@ usage() { echo " -g {vim-revision} Download a Vim patch." echo " -s Create a vim-patch pull request." echo " -r {pr-number} Review a vim-patch pull request." - echo ' -V Clone the Vim source code to $VIM_SOURCE_DIR.' + echo " -V Clone the Vim source code to \$VIM_SOURCE_DIR." echo - echo ' $VIM_SOURCE_DIR controls where Vim sources are found' + echo " \$VIM_SOURCE_DIR controls where Vim sources are found" echo " (default: '${VIM_SOURCE_DIR_DEFAULT}')" } @@ -93,9 +93,11 @@ get_vim_sources() { exit 1 fi echo "Updating Vim sources: ${VIM_SOURCE_DIR}" - git pull --ff && - msg_ok "Updated Vim sources." || + if git pull --ff; then + msg_ok "Updated Vim sources." + else msg_err "Could not update Vim sources; ignoring error." + fi fi } @@ -147,18 +149,18 @@ preprocess_patch() { # Remove *.proto, Make*, gui_*, some if_* local na_src='proto\|Make*\|gui_*\|if_lua\|if_mzsch\|if_olepp\|if_ole\|if_perl\|if_py\|if_ruby\|if_tcl\|if_xcmdsrv' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<\%(testdir/\)\@<!\%('${na_src}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<\%(testdir/\)\@<!\%('"${na_src}"'\)@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove unwanted Vim doc files. local na_doc='channel\.txt\|netbeans\.txt\|os_\w\+\.txt\|term\.txt\|todo\.txt\|version\d\.txt\|sponsor\.txt\|intro\.txt\|tags' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/\<\%('${na_doc}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/\<\%('"${na_doc}"'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove "Last change ..." changes in doc files. 2>/dev/null $nvim --cmd 'set dir=/tmp' +'%s/^@@.*\n.*For Vim version.*Last change.*\n.*For Vim version.*Last change.*//' +w +q "$file" # Remove screen dumps, testdir/Make_*.mak files local na_src_testdir='Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms\|dumps/.*.dump' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\<\%('${na_src_testdir}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\<\%('"${na_src_testdir}"'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove version.c #7555 local na_po='version.c' @@ -203,7 +205,7 @@ get_vimpatch() { msg_ok "Found Vim revision '${vim_commit}'." local patch_content - patch_content="$(git --no-pager show --color=never -1 --pretty=medium "${vim_commit}")" + patch_content="$(git --no-pager show --unified=5 --color=never -1 --pretty=medium "${vim_commit}")" cd "${NVIM_SOURCE_DIR}" @@ -216,6 +218,7 @@ get_vimpatch() { msg_ok "Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'." } +# shellcheck disable=SC2015 # "Note that A && B || C is not if-then-else." stage_patch() { get_vimpatch "$1" local try_apply="${2:-}" @@ -248,14 +251,14 @@ stage_patch() { msg_ok "${output}" || (msg_err "${output}"; false) + local ret=0 if test -n "$try_apply" ; then if ! check_executable patch; then printf "\n" msg_err "'patch' command not found\n" else printf "\nApplying patch...\n" - patch -p1 < "${patch_file}" || true - find . -name '*.orig' -type f -delete + patch -p1 --fuzz=1 --suffix= < "${patch_file}" || ret=$? fi printf "\nInstructions:\n Proceed to port the patch.\n" else @@ -275,6 +278,7 @@ stage_patch() { See the wiki for more information: * https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim ' "${vim_version}" "${BASENAME}" "${BASENAME}" + return $ret } hub_pr() { @@ -285,6 +289,7 @@ git_hub_pr() { git hub pull new -m "$1" } +# shellcheck disable=SC2015 # "Note that A && B || C is not if-then-else." submit_pr() { require_executable git local push_first @@ -316,7 +321,7 @@ submit_pr() { local patches # Extract just the "vim-patch:X.Y.ZZZZ" or "vim-patch:sha" portion of each log patches=("$(git log --grep=vim-patch --reverse --format='%s' "${git_remote}"/master..HEAD | sed 's/: .*//')") - patches=(${patches[@]//vim-patch:}) # Remove 'vim-patch:' prefix for each item in array. + patches=("${patches[@]//vim-patch:}") # Remove 'vim-patch:' prefix for each item in array. local pr_title="${patches[*]}" # Create space-separated string from array. pr_title="${pr_title// /,}" # Replace spaces with commas. @@ -369,7 +374,7 @@ list_vimpatch_tokens() { # a "vim-patch:xxx" token in the Nvim git log. list_vimpatch_numbers() { # Transform "vim-patch:X.Y.ZZZZ" to "ZZZZ". - list_vimpatch_tokens | while read vimpatch_token; do + list_vimpatch_tokens | while read -r vimpatch_token; do echo "$vimpatch_token" | grep '8\.0\.' | sed 's/.*vim-patch:8\.0\.\([0-9a-z]\+\).*/\1/' done } @@ -378,12 +383,21 @@ list_vimpatch_numbers() { list_missing_vimpatches() { local token vim_commit vim_tag patch_number declare -A tokens + declare -A vim_commit_tags # Find all "vim-patch:xxx" tokens in the Nvim git log. for token in $(list_vimpatch_tokens); do tokens[$token]=1 done + # Create an associative array mapping Vim commits to tags. + eval "declare -A vim_commit_tags=( + $(git -C "${VIM_SOURCE_DIR}" for-each-ref refs/tags \ + --format '[%(objectname)]=%(refname:lstrip=2)' \ + --sort='-*authordate' \ + --shell) + )" + # Get missing Vim commits for vim_commit in $(list_vim_commits); do # Check for vim-patch:<commit_hash> (usually runtime updates). @@ -392,7 +406,8 @@ list_missing_vimpatches() { continue fi - if vim_tag="$(git -C "${VIM_SOURCE_DIR}" describe --tags --exact-match "${vim_commit}" 2>/dev/null)"; then + vim_tag="${vim_commit_tags[$vim_commit]-}" + if [[ -n "$vim_tag" ]]; then # Check for vim-patch:<tag> (not commit hash). patch_number="vim-patch:${vim_tag:1}" # "v7.4.0001" => "7.4.0001" if [[ "${tokens[$patch_number]-}" ]]; then @@ -410,7 +425,7 @@ show_vimpatches() { get_vim_sources printf "\nVim patches missing from Neovim:\n" - list_missing_vimpatches | while read vim_commit; do + list_missing_vimpatches | while read -r vim_commit; do if [ -n "$(git -C "$VIM_SOURCE_DIR" diff-tree --no-commit-id --name-only "${vim_commit}" -- runtime)" ]; then printf ' • %s (+runtime)\n' "${vim_commit}" else @@ -507,8 +522,9 @@ review_pr() { echo echo "Downloading data for pull request #${pr}." - local pr_commit_urls=($(curl -Ssf "https://api.github.com/repos/neovim/neovim/pulls/${pr}/commits" \ - | jq -r '.[].html_url')) + local pr_commit_urls=( + "$(curl -Ssf "https://api.github.com/repos/neovim/neovim/pulls/${pr}/commits" \ + | jq -r '.[].html_url')") echo "Found ${#pr_commit_urls[@]} commit(s)." @@ -548,7 +564,7 @@ while getopts "hlLMVp:P:g:r:s" opt; do ;; p) stage_patch "${OPTARG}" - exit 0 + exit ;; P) stage_patch "${OPTARG}" TRY_APPLY diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index bfd6240f0c..aaddc90c99 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -276,28 +276,47 @@ endif for s:test in sort(s:tests) " Silence, please! set belloff=all + let prev_error = '' + let total_errors = [] + let run_nr = 1 call RunTheTest(s:test) + " Repeat a flaky test. Give up when: + " - it fails again with the same message + " - it fails five times (with a different mesage) if len(v:errors) > 0 && index(s:flaky, s:test) >= 0 - call add(s:messages, 'Found errors in ' . s:test . ':') - call extend(s:messages, v:errors) - call add(s:messages, 'Flaky test failed, running it again') - let first_run = v:errors + while 1 + call add(s:messages, 'Found errors in ' . s:test . ':') + call extend(s:messages, v:errors) - " Flakiness is often caused by the system being very busy. Sleep a couple - " of seconds to have a higher chance of succeeding the second time. - sleep 2 + call add(total_errors, 'Run ' . run_nr . ':') + call extend(total_errors, v:errors) - let v:errors = [] - call RunTheTest(s:test) - if len(v:errors) > 0 - let second_run = v:errors - let v:errors = ['First run:'] - call extend(v:errors, first_run) - call add(v:errors, 'Second run:') - call extend(v:errors, second_run) - endif + if run_nr == 5 || prev_error == v:errors[0] + call add(total_errors, 'Flaky test failed too often, giving up') + let v:errors = total_errors + break + endif + + call add(s:messages, 'Flaky test failed, running it again') + + " Flakiness is often caused by the system being very busy. Sleep a + " couple of seconds to have a higher chance of succeeding the second + " time. + sleep 2 + + let prev_error = v:errors[0] + let v:errors = [] + let run_nr += 1 + + call RunTheTest(s:test) + + if len(v:errors) == 0 + " Test passed on rerun. + break + endif + endwhile endif call AfterTheTest() diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim index 3a9ffbdbf3..6468819198 100644 --- a/src/nvim/testdir/test_arglist.vim +++ b/src/nvim/testdir/test_arglist.vim @@ -74,6 +74,7 @@ func Test_argadd() call assert_equal(1, len(argv())) call assert_equal('some file', get(argv(), 0, '')) + call delete('Xargadd') %argd new arga |