From 79a8d905ab8908362109284240d2f9a75564f8ad Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 01:18:39 -0400 Subject: [PATCH 01/13] oldtests: newstyle: win: reset shell to cmd.exe Unset $SHELL so that child nvim use cmd.exe as default shell. Unset $TERM so that child nvim don't segfault with negative exit code. sh/bash use TERM=cygwin by default if it is unset. mintty sets TERM to xterm. --- src/nvim/testdir/runtest.vim | 2 +- src/nvim/testdir/setup.vim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 7090be7726..5c98455909 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -61,7 +61,7 @@ set nomore lang mess C " Always use forward slashes. -set shellslash +" set shellslash " Prepare for calling test_garbagecollect_now(). let v:testing = 1 diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index 7d6dd0c7ce..aac9fefef4 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -17,3 +17,11 @@ let &packpath = &rtp " Make sure $HOME does not get read or written. let $HOME = '/does/not/exist' + +" Use default shell on Windows to avoid segfault, caused by TUI +if has('win32') + let $SHELL = '' + let $TERM = '' + let &shell = empty($COMSPEC) ? exepath('cmd.exe') : $COMSPEC + set shellcmdflag=/s/c shellxquote=\" shellredir=>%s\ 2>&1 +endif From 979569356fdeca8361a387ae11c7294bcfaea2d9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 02:27:10 -0400 Subject: [PATCH 02/13] ci/win: prefer msys find.exe runnvim.sh depends on it for file glob patterns. --- ci/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.ps1 b/ci/build.ps1 index 71cc7c5b50..d530bbad52 100644 --- a/ci/build.ps1 +++ b/ci/build.ps1 @@ -114,7 +114,7 @@ if ($uploadToCodecov) { } # Old tests -$env:PATH += ';C:\msys64\usr\bin' +$env:PATH = "C:\msys64\usr\bin;$env:PATH" & "C:\msys64\mingw$bits\bin\mingw32-make.exe" -C $(Convert-Path ..\src\nvim\testdir) VERBOSE=1 if ($uploadToCodecov) { From e3687165a74ba2f3234cd6acc156ec12f85a5f3a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 02:37:41 -0400 Subject: [PATCH 03/13] oldtests: use expand() to fix pathsep Fix failing oldtests because of noshellslash. --- src/nvim/testdir/test_cmdline.vim | 6 +++--- src/nvim/testdir/test_quickfix.vim | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 673246e1fb..be68e9ff9d 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -154,7 +154,7 @@ func Test_getcompletion() call assert_equal([], l) let l = getcompletion('', 'dir') - call assert_true(index(l, 'sautest/') >= 0) + call assert_true(index(l, expand('sautest/')) >= 0) let l = getcompletion('NoMatch', 'dir') call assert_equal([], l) @@ -246,7 +246,7 @@ func Test_getcompletion() " Command line completion tests let l = getcompletion('cd ', 'cmdline') - call assert_true(index(l, 'sautest/') >= 0) + call assert_true(index(l, expand('sautest/')) >= 0) let l = getcompletion('cd NoMatch', 'cmdline') call assert_equal([], l) let l = getcompletion('let v:n', 'cmdline') @@ -288,7 +288,7 @@ func Test_expand_star_star() call mkdir('a/b', 'p') call writefile(['asdfasdf'], 'a/b/fileXname') call feedkeys(":find **/fileXname\\", 'xt') - call assert_equal('find a/b/fileXname', getreg(':')) + call assert_equal('find '.expand('a/b/fileXname'), getreg(':')) bwipe! call delete('a', 'rf') endfunc diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index dd177fd633..85f93cf3da 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -850,17 +850,17 @@ func s:dir_stack_tests(cchar) let qf = g:Xgetlist() - call assert_equal('dir1/a/habits2.txt', bufname(qf[1].bufnr)) + call assert_equal(expand('dir1/a/habits2.txt'), bufname(qf[1].bufnr)) call assert_equal(1, qf[1].lnum) - call assert_equal('dir1/a/b/habits3.txt', bufname(qf[3].bufnr)) + call assert_equal(expand('dir1/a/b/habits3.txt'), bufname(qf[3].bufnr)) call assert_equal(2, qf[3].lnum) - call assert_equal('dir1/a/habits2.txt', bufname(qf[4].bufnr)) + call assert_equal(expand('dir1/a/habits2.txt'), bufname(qf[4].bufnr)) call assert_equal(7, qf[4].lnum) - call assert_equal('dir1/c/habits4.txt', bufname(qf[6].bufnr)) + call assert_equal(expand('dir1/c/habits4.txt'), bufname(qf[6].bufnr)) call assert_equal(3, qf[6].lnum) call assert_equal('habits1.txt', bufname(qf[9].bufnr)) call assert_equal(4, qf[9].lnum) - call assert_equal('dir2/habits5.txt', bufname(qf[11].bufnr)) + call assert_equal(expand('dir2/habits5.txt'), bufname(qf[11].bufnr)) call assert_equal(5, qf[11].lnum) let &efm=save_efm @@ -1065,7 +1065,7 @@ func Test_efm2() call assert_equal(8, len(l)) call assert_equal(89, l[4].lnum) call assert_equal(1, l[4].valid) - call assert_equal('unittests/dbfacadeTest.py', bufname(l[4].bufnr)) + call assert_equal(expand('unittests/dbfacadeTest.py'), bufname(l[4].bufnr)) " The following sequence of commands used to crash Vim set efm=%W%m @@ -1609,11 +1609,11 @@ func Test_two_windows() laddexpr 'one.txt:3:one one one' let loc_one = getloclist(one_id) - call assert_equal('Xone/a/one.txt', bufname(loc_one[1].bufnr)) + call assert_equal(expand('Xone/a/one.txt'), bufname(loc_one[1].bufnr)) call assert_equal(3, loc_one[1].lnum) let loc_two = getloclist(two_id) - call assert_equal('Xtwo/a/two.txt', bufname(loc_two[1].bufnr)) + call assert_equal(expand('Xtwo/a/two.txt'), bufname(loc_two[1].bufnr)) call assert_equal(5, loc_two[1].lnum) call win_gotoid(one_id) From fa0e32fba2b5af04a4e1c5afeb4af66c2386dd1e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 13:53:15 -0400 Subject: [PATCH 04/13] oldtests: win: cmd.exe echo has trailing CR --- src/nvim/testdir/test_system.vim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/nvim/testdir/test_system.vim b/src/nvim/testdir/test_system.vim index ce9d110d82..d3c0594c03 100644 --- a/src/nvim/testdir/test_system.vim +++ b/src/nvim/testdir/test_system.vim @@ -5,14 +5,12 @@ function! Test_System() return endif let out = system('echo 123') - " On Windows we may get a trailing space. - if out != "123 \n" - call assert_equal("123\n", out) - endif + call assert_equal("123\n", out) let out = systemlist('echo 123') - " On Windows we may get a trailing space and CR. - if out != ["123 \r"] + if &shell =~# 'cmd.exe$' + call assert_equal(["123\r"], out) + else call assert_equal(['123'], out) endif From 6245b4873d5e24fade9aadadf32645bfb3ebfc31 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 17:09:33 -0400 Subject: [PATCH 05/13] oldtests: win: shellslash for cdpath,tags,:find --- src/nvim/testdir/test_find_complete.vim | 3 +++ src/nvim/testdir/test_options.vim | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/nvim/testdir/test_find_complete.vim b/src/nvim/testdir/test_find_complete.vim index 4732109ed0..1019246404 100644 --- a/src/nvim/testdir/test_find_complete.vim +++ b/src/nvim/testdir/test_find_complete.vim @@ -3,6 +3,8 @@ " Do all the tests in a separate window to avoid E211 when we recursively " delete the Xfind directory during cleanup func Test_find_complete() + let shellslash = &shellslash + set shellslash set belloff=all " On windows a stale "Xfind" directory may exist, remove it so that @@ -154,4 +156,5 @@ func Test_find_complete() exe 'cd ' . cwd call delete('Xfind', 'rf') set path& + let &shellslash = shellslash endfunc diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index a15d15213a..f8c3161b40 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -158,6 +158,8 @@ func Test_set_completion() call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:) " Expand directories. + let shellslash = &shellslash + set shellslash call feedkeys(":set cdpath=./\\\"\", 'tx') call assert_match('./samples/ ', @:) call assert_notmatch('./small.vim ', @:) @@ -168,6 +170,7 @@ func Test_set_completion() call feedkeys(":set tags=./\\\\ dif\\\"\", 'tx') call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:) + let &shellslash = shellslash endfunc func Test_set_errors() From 4bbe51b79efe751159e900200716ff715c1452c5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 19:29:10 -0400 Subject: [PATCH 06/13] oldtests: win: help sp?it opens split() Vim 8 and Neovim 0.2.3 open the same target on Windows. --- src/nvim/testdir/test_help_tagjump.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 06c48d8e76..4d4a902031 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -30,7 +30,7 @@ func Test_help_tagjump() help sp?it call assert_equal("help", &filetype) - call assert_true(getline('.') =~ '\*:split\*') + call assert_true(getline('.') =~ '\*'.(has('win32') ? 'split()' : ':split').'\*') helpclose help :? From 49e86cebf0341f0aa2da5ca9d530ee2bebe6606e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 28 Mar 2018 21:41:22 -0400 Subject: [PATCH 07/13] oldtests: check +iconv for makeencoding MSVC builds don't include it. Test utf8 and latin only if +iconv is missing. --- src/nvim/testdir/test_makeencoding.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_makeencoding.vim b/src/nvim/testdir/test_makeencoding.vim index a3d5538a47..6e4c7af821 100644 --- a/src/nvim/testdir/test_makeencoding.vim +++ b/src/nvim/testdir/test_makeencoding.vim @@ -13,12 +13,19 @@ endif let s:script = 'test_makeencoding.py' -let s:message_tbl = { +if has('iconv') + let s:message_tbl = { \ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好', \ 'latin1': 'ÀÈÌÒÙ', \ 'cp932': 'こんにちは', \ 'cp936': '你好', \} +else + let s:message_tbl = { + \ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好', + \ 'latin1': 'ÀÈÌÒÙ', + \} +endif " Tests for :cgetfile and :lgetfile. From 7c8122f36d219ab5aaea1b772e301cf1cff80cce Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 6 Apr 2018 14:00:38 -0400 Subject: [PATCH 08/13] win: getftype(symlink) returns 'link' Vim doesn't detect symlinks correctly so stick with Neovim's behaviour. --- runtime/doc/eval.txt | 3 +-- src/nvim/testdir/test_stat.vim | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 11c4b62403..5b2fcbde3d 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4208,8 +4208,7 @@ getftype({fname}) *getftype()* getftype("/home") < Note that a type such as "link" will only be returned on systems that support it. On some systems only "dir" and - "file" are returned. On MS-Windows a symbolic link to a - directory returns "dir" instead of "link". + "file" are returned. *getline()* getline({lnum} [, {end}]) diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim index 1239fe9427..0a09130b0c 100644 --- a/src/nvim/testdir/test_stat.vim +++ b/src/nvim/testdir/test_stat.vim @@ -86,7 +86,7 @@ func Test_win32_symlink_dir() let res = system('dir C:\Users /a') if match(res, '\C *All Users') >= 0 " Get the filetype of the symlink. - call assert_equal('dir', getftype('C:\Users\All Users')) + call assert_equal('link', getftype('C:\Users\All Users')) endif endif endfunc From bc43d2559f33aa6334d70834b389f0bc59dadcbf Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 11 Apr 2018 14:03:21 -0400 Subject: [PATCH 09/13] ci/win: don't use lastexitcode hack on mingw build The heck is for MSVC builds to workaround msbuild error detection for cmake. --- ci/build.ps1 | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ci/build.ps1 b/ci/build.ps1 index d530bbad52..0476d2a0b7 100644 --- a/ci/build.ps1 +++ b/ci/build.ps1 @@ -97,15 +97,21 @@ bin\nvim --version ; exitIfFailed # Functional tests # The $LastExitCode from MSBuild can't be trusted -$failed = $false -# Temporarily turn off tracing to reduce log file output -Set-PSDebug -Off -cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs | - foreach { $failed = $failed -or - $_ -match 'Running functional tests failed with error'; $_ } -Set-PSDebug -Trace 1 -if ($failed) { - exit $LastExitCode +if ($compiler -eq 'MSVC') { + $failed = $false + # Temporarily turn off tracing to reduce log file output + Set-PSDebug -Off + cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs | + foreach { $failed = $failed -or + $_ -match 'Running functional tests failed with error'; $_ } + Set-PSDebug -Trace 1 + if ($failed) { + exit $LastExitCode + } +} +else { + cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs + exitIfFailed } From 714e0f8bf05cc6febcbcd8cbcbe5f119c37a14b0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 12 Apr 2018 02:44:06 -0400 Subject: [PATCH 10/13] oldtests: win: keep set dir=/ Any user can create a directory on root. Creating a directory on root allows any user to write files within that directory. Test_recover_root_dir() passes when run locally as a regular user (not admin). --- src/nvim/testdir/test_recover.vim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/nvim/testdir/test_recover.vim b/src/nvim/testdir/test_recover.vim index 46d884a97c..beecb4cd0d 100644 --- a/src/nvim/testdir/test_recover.vim +++ b/src/nvim/testdir/test_recover.vim @@ -6,11 +6,6 @@ func Test_recover_root_dir() set dir=/ call assert_fails('recover', 'E305:') close! - - if has('win32') || filewritable('/') == 2 - " can write in / directory on MS-Windows - set dir=/notexist/ - endif call assert_fails('split Xtest', 'E303:') set dir& endfunc From 8e87d89a99b88d013655911ca9ebc34da37fbaa2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 12 Apr 2018 21:11:55 -0400 Subject: [PATCH 11/13] oldtests: win: skip test49 Vim doesn't test it on Windows. See https://github.com/vim/vim/blob/master/src/testdir/Make_all.mak --- src/nvim/testdir/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index a31e1843fc..4bfcbf8e79 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -20,13 +20,13 @@ SCRIPTS_DEFAULT = \ test40.out \ test42.out \ test48.out \ - test49.out \ test52.out \ test64.out \ ifneq ($(OS),Windows_NT) SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \ test17.out \ + test49.out \ endif From ad30907814dafdfe8533fe49c62ee8eb3472e438 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 13 Apr 2018 13:38:31 -0400 Subject: [PATCH 12/13] Revert "ci/win: don't use lastexitcode hack on mingw build" This reverts commit bc43d2559f33aa6334d70834b389f0bc59dadcbf. stderr redirection should make the workaround work for mingw builds. --- ci/build.ps1 | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/ci/build.ps1 b/ci/build.ps1 index 0476d2a0b7..d530bbad52 100644 --- a/ci/build.ps1 +++ b/ci/build.ps1 @@ -97,21 +97,15 @@ bin\nvim --version ; exitIfFailed # Functional tests # The $LastExitCode from MSBuild can't be trusted -if ($compiler -eq 'MSVC') { - $failed = $false - # Temporarily turn off tracing to reduce log file output - Set-PSDebug -Off - cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs | - foreach { $failed = $failed -or - $_ -match 'Running functional tests failed with error'; $_ } - Set-PSDebug -Trace 1 - if ($failed) { - exit $LastExitCode - } -} -else { - cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs - exitIfFailed +$failed = $false +# Temporarily turn off tracing to reduce log file output +Set-PSDebug -Off +cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs | + foreach { $failed = $failed -or + $_ -match 'Running functional tests failed with error'; $_ } +Set-PSDebug -Trace 1 +if ($failed) { + exit $LastExitCode } From 51b9d85bb47495014968922d4adff5319ba44900 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 13 Apr 2018 13:42:02 -0400 Subject: [PATCH 13/13] ci/win: redirect stderr to fix mingw build --- ci/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.ps1 b/ci/build.ps1 index d530bbad52..8eb237ccd1 100644 --- a/ci/build.ps1 +++ b/ci/build.ps1 @@ -100,7 +100,7 @@ bin\nvim --version ; exitIfFailed $failed = $false # Temporarily turn off tracing to reduce log file output Set-PSDebug -Off -cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs | +cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs 2>&1 | foreach { $failed = $failed -or $_ -match 'Running functional tests failed with error'; $_ } Set-PSDebug -Trace 1