From 3e19e18f4cfa0f9c578b6e306a0d887551893b3c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 6 Oct 2017 22:37:48 -0400 Subject: [PATCH 01/21] win: enable job tests that use jobstart only - echo "" does not hang in powershell - cmd.exe's echo command does not hang. - job tests default to powershell (WHY?) - wait 5 seconds for powershell to create an empty file - powershell is slow - cannot reliably validate the id returned by jobstart via jobpid, jobstop - if using cmd.exe, waiting for a second should be enough - remaining job tests are unreliable in Windows because any build can pass/fail for same conditions without changes, especially if the error is in stderr --- test/functional/core/job_spec.lua | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 73d437169a..5f39040a6f 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -60,7 +60,7 @@ describe('jobs', function() it('changes to given / directory', function() nvim('command', "let g:job_opts.cwd = '/'") if iswin() then - nvim('command', "let j = jobstart('pwd|%{$_.Path}', g:job_opts)") + nvim('command', "let j = jobstart('(Get-Location).Path', g:job_opts)") else nvim('command', "let j = jobstart('pwd', g:job_opts)") end @@ -75,7 +75,7 @@ describe('jobs', function() mkdir(dir) nvim('command', "let g:job_opts.cwd = '" .. dir .. "'") if iswin() then - nvim('command', "let j = jobstart('pwd|%{$_.Path}', g:job_opts)") + nvim('command', "let j = jobstart('(Get-Location).Path', g:job_opts)") else nvim('command', "let j = jobstart('pwd', g:job_opts)") end @@ -115,13 +115,13 @@ describe('jobs', function() end) it('returns -1 when target is not executable #5465', function() - if helpers.pending_win32(pending) then return end local function new_job() return eval([[jobstart('')]]) end local executable_jobid = new_job() - local nonexecutable_jobid = eval( - "jobstart(['./test/functional/fixtures/non_executable.txt'])") + local nonexecutable_jobid = eval("jobstart(['"..(iswin() + and './test/functional/fixtures' + or './test/functional/fixtures/non_executable.txt').."'])") eq(-1, nonexecutable_jobid) -- Should _not_ throw an error. eq("", eval("v:errmsg")) @@ -133,11 +133,10 @@ describe('jobs', function() -- TODO: hangs on Windows if helpers.pending_win32(pending) then return end nvim('command', "let g:job_opts.on_stderr = function('OnEvent')") - nvim('command', "call jobstart('echo', g:job_opts)") + nvim('command', [[call jobstart('echo ""', g:job_opts)]]) expect_twostreams({{'notification', 'stdout', {0, {'', ''}}}, {'notification', 'stdout', {0, {''}}}}, {{'notification', 'stderr', {0, {''}}}}) - eq({'notification', 'exit', {0, 0}}, next_msg()) end) @@ -253,7 +252,6 @@ describe('jobs', function() end) it('will not leak memory if we leave a job running', function() - if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. nvim('command', "call jobstart(['cat', '-'], g:job_opts)") end) @@ -300,11 +298,7 @@ describe('jobs', function() end) it('can omit options', function() - if helpers.pending_win32(pending) then return end - neq(0, nvim('eval', 'delete(".Xtestjob")')) - nvim('command', "call jobstart(['touch', '.Xtestjob'])") - nvim('command', "sleep 100m") - eq(0, nvim('eval', 'delete(".Xtestjob")')) + ok(eval([[jobstart('echo ""')]]) > 0) end) it('can omit data callbacks', function() @@ -348,7 +342,6 @@ describe('jobs', function() end) it('can redefine callbacks being used by a job', function() - if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. local screen = Screen.new() screen:attach() screen:set_default_attr_ids({ @@ -363,7 +356,7 @@ describe('jobs', function() \ 'on_stderr': function('g:JobHandler'), \ 'on_exit': function('g:JobHandler') \ } - let job = jobstart('cat -', g:callbacks) + let job = jobstart(['cat', '-'], g:callbacks) ]]) wait() source([[ From 0fd899aa077b9a70932bfc3b191e780716b4b4d5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 11 Oct 2017 21:25:54 -0400 Subject: [PATCH 02/21] win: enable legacy test 025 --- .../legacy/025_jump_tag_hidden_spec.lua | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/test/functional/legacy/025_jump_tag_hidden_spec.lua b/test/functional/legacy/025_jump_tag_hidden_spec.lua index 0d51b4da26..dd89a3680e 100644 --- a/test/functional/legacy/025_jump_tag_hidden_spec.lua +++ b/test/functional/legacy/025_jump_tag_hidden_spec.lua @@ -5,8 +5,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local feed_command, expect = helpers.feed_command, helpers.expect -if helpers.pending_win32(pending) then return end - describe('jump to a tag with hidden set', function() setup(clear) @@ -25,12 +23,17 @@ describe('jump to a tag with hidden set', function() feed_command('set hidden') -- Create a link from test25.dir to the current directory. - feed_command('!rm -f test25.dir') - feed_command('!ln -s . test25.dir') + if helpers.iswin() then + feed_command('!rd /q/s test25.dir') + feed_command('!mklink /j test25.dir .') + else + feed_command('!rm -f test25.dir') + feed_command('!ln -s . test25.dir') + end -- Create tags.text, with the current directory name inserted. feed_command('/tags line') - feed_command('r !pwd') + feed_command('r !' .. (helpers.iswin() and 'cd' or 'pwd')) feed('d$/test') feed('hP:.w! tags.test') @@ -39,7 +42,13 @@ describe('jump to a tag with hidden set', function() -- space will then be eaten by hit-return, instead of moving the cursor to 'd'. feed_command('set tags=tags.test') feed('G x:yank a') - feed_command('!rm -f Xxx test25.dir tags.test') + feed_command("call delete('tags.test')") + feed_command("call delete('Xxx')") + if helpers.iswin() then + feed_command('!rd /q test25.dir') + else + feed_command('!rm -f test25.dir') + end -- Put @a and remove empty line feed_command('%d') From bde32edefe0654907a4bea353cdad0aa85919e91 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 11 Oct 2017 22:56:11 -0400 Subject: [PATCH 03/21] win: enable legacy test 097 --- test/functional/legacy/097_glob_path_spec.lua | 72 +++++++++++++------ 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua index 6b63a317f1..907f0665ae 100644 --- a/test/functional/legacy/097_glob_path_spec.lua +++ b/test/functional/legacy/097_glob_path_spec.lua @@ -6,15 +6,19 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local command, expect = helpers.command, helpers.expect -if helpers.pending_win32(pending) then return end - describe('glob() and globpath()', function() setup(clear) setup(function() - os.execute("mkdir -p sautest/autoload") - os.execute("touch sautest/autoload/Test104.vim") - os.execute("touch sautest/autoload/footest.vim") + if helpers.iswin() then + os.execute("md sautest\\autoload") + os.execute(".>sautest\\autoload\\Test104.vim 2>nul") + os.execute(".>sautest\\autoload\\footest.vim 2>nul") + else + os.execute("mkdir -p sautest/autoload") + os.execute("touch sautest/autoload/Test104.vim") + os.execute("touch sautest/autoload/footest.vim") + end end) it('is working', function() @@ -24,29 +28,55 @@ describe('glob() and globpath()', function() -- Consistent sorting of file names command('set nofileignorecase') - command([[$put =glob('Xxx\{')]]) - command([[$put =glob('Xxx\$')]]) + if helpers.iswin() then + command([[$put =glob('Xxx{')]]) + command([[$put =glob('Xxx$')]]) - command('silent w! Xxx{') - command([[w! Xxx\$]]) - command([[$put =glob('Xxx\{')]]) - command([[$put =glob('Xxx\$')]]) + command('silent w! Xxx{') + command([[w! Xxx$]]) + command([[$put =glob('Xxx{')]]) + command([[$put =glob('Xxx$')]]) - command("$put =string(globpath('sautest/autoload', '*.vim'))") - command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))") - - expect([=[ + command([[$put =string(globpath('sautest\autoload', '*.vim'))]]) + command([[$put =string(globpath('sautest\autoload', '*.vim', 0, 1))]]) + expect([=[ - Xxx{ - Xxx$ - 'sautest/autoload/Test104.vim - sautest/autoload/footest.vim' - ['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=]) + Xxx{ + Xxx$ + 'sautest\autoload\Test104.vim + sautest\autoload\footest.vim' + ['sautest\autoload\Test104.vim', 'sautest\autoload\footest.vim']]=]) + else + command([[$put =glob('Xxx\{')]]) + command([[$put =glob('Xxx\$')]]) + + command('silent w! Xxx{') + command([[w! Xxx\$]]) + command([[$put =glob('Xxx\{')]]) + command([[$put =glob('Xxx\$')]]) + + command("$put =string(globpath('sautest/autoload', '*.vim'))") + command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))") + expect([=[ + + + + Xxx{ + Xxx$ + 'sautest/autoload/Test104.vim + sautest/autoload/footest.vim' + ['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=]) + end end) teardown(function() - os.execute("rm -rf sautest Xxx{ Xxx$") + if helpers.iswin() then + os.execute('del /q/f Xxx{ Xxx$') + os.execute('rd /q sautest') + else + os.execute("rm -rf sautest Xxx{ Xxx$") + end end) end) From 4f65cd7c0a6386c3554eaf133ca9dd885ec016fe Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 12 Oct 2017 22:55:14 -0400 Subject: [PATCH 04/21] win: enable legacy/delete_spec.lua --- test/functional/legacy/delete_spec.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index aeaab335e8..5ef456bfe3 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -2,8 +2,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source local eq, eval, command = helpers.eq, helpers.eval, helpers.command -if helpers.pending_win32(pending) then return end - describe('Test for delete()', function() before_each(clear) @@ -48,7 +46,11 @@ describe('Test for delete()', function() split Xfile call setline(1, ['a', 'b']) wq - silent !ln -s Xfile Xlink + if has('win32') + silent !mklink Xlink Xfile + else + silent !ln -s Xfile Xlink + endif ]]) -- Delete the link, not the file eq(0, eval("delete('Xlink')")) @@ -58,7 +60,11 @@ describe('Test for delete()', function() it('symlink directory delete', function() command("call mkdir('Xdir1')") - command("silent !ln -s Xdir1 Xlink") + if helpers.iswin() then + command("silent !mklink /j Xlink Xdir1") + else + command("silent !ln -s Xdir1 Xlink") + end eq(1, eval("isdirectory('Xdir1')")) eq(1, eval("isdirectory('Xlink')")) -- Delete the link, not the directory @@ -78,7 +84,11 @@ describe('Test for delete()', function() w Xdir3/subdir/Xfile w Xdir4/Xfile close - silent !ln -s ../Xdir4 Xdir3/Xlink + if has('win32') + silent !mklink /j Xdir3\Xlink Xdir4 + else + silent !ln -s ../Xdir4 Xdir3/Xlink + endif ]]) eq(1, eval("isdirectory('Xdir3')")) From f4d82c1438c2197d893f678b2fc66cc5dcbc6447 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 14 Oct 2017 22:08:50 -0400 Subject: [PATCH 05/21] win: enable legacy test 011 --- test/functional/legacy/011_autocommands_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index d969a8bd37..c2667d28d2 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -18,10 +18,9 @@ local clear, feed_command, expect, eq, neq, dedent, write_file, feed = helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq, helpers.dedent, helpers.write_file, helpers.feed -if helpers.pending_win32(pending) then return end - local function has_gzip() - return os.execute('gzip --help >/dev/null 2>&1') == 0 + local null = helpers.iswin() and 'nul' or '/dev/null' + return os.execute('gzip --help >' .. null .. ' 2>&1') == 0 end local function prepare_gz_file(name, text) @@ -142,6 +141,7 @@ describe('file reading, writing and bufnew and filter autocommands', function() end) it('FilterReadPre, FilterReadPost', function() + if helpers.pending_win32(pending) then return end -- Write a special input file for this test block. write_file('test.out', dedent([[ startstart From e55de56a99ac74d30665af6ab400e759ed8b3b40 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 13 Oct 2017 11:18:49 -0400 Subject: [PATCH 06/21] win: enable legacy/packadd_spec.lua --- test/functional/legacy/packadd_spec.lua | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 2dfd36142b..fb308475c0 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -9,17 +9,15 @@ local function expected_empty() eq({}, nvim.get_vvar('errors')) end -if helpers.pending_win32(pending) then return end - describe('packadd', function() before_each(function() clear() source([=[ func SetUp() - let s:topdir = expand('%:p:h') . '/Xdir' + let s:topdir = expand(expand('%:p:h') . '/Xdir') exe 'set packpath=' . s:topdir - let s:plugdir = s:topdir . '/pack/mine/opt/mytest' + let s:plugdir = expand(s:topdir . '/pack/mine/opt/mytest') endfunc func TearDown() @@ -52,8 +50,8 @@ describe('packadd', function() call assert_equal(77, g:plugin_also_works) call assert_true(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) - call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) - call assert_true(&rtp =~ (s:plugdir . '/after$')) + call assert_true(&rtp =~ (escape(s:plugdir, '\') . '\($\|,\)')) + call assert_true(&rtp =~ escape(expand(s:plugdir . '/after$'), '\')) " Check exception call assert_fails("packadd directorynotfound", 'E919:') @@ -74,7 +72,7 @@ describe('packadd', function() packadd! mytest call assert_true(len(&rtp) > len(rtp)) - call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + call assert_true(&rtp =~ (escape(s:plugdir, '\') . '\($\|,\)')) call assert_equal(0, g:plugin_works) " check the path is not added twice @@ -84,17 +82,18 @@ describe('packadd', function() endfunc func Test_packadd_symlink_dir() - if !has('unix') - return - endif - let top2_dir = s:topdir . '/Xdir2' - let real_dir = s:topdir . '/Xsym' + let top2_dir = expand(s:topdir . '/Xdir2') + let real_dir = expand(s:topdir . '/Xsym') call mkdir(real_dir, 'p') - exec "silent! !ln -s Xsym" top2_dir - let &rtp = top2_dir . ',' . top2_dir . '/after' + if has('win32') + exec "silent! !mklink /d" top2_dir "Xsym" + else + exec "silent! !ln -s Xsym" top2_dir + endif + let &rtp = top2_dir . ',' . expand(top2_dir . '/after') let &packpath = &rtp - let s:plugdir = top2_dir . '/pack/mine/opt/mytest' + let s:plugdir = expand(top2_dir . '/pack/mine/opt/mytest') call mkdir(s:plugdir . '/plugin', 'p') exe 'split ' . s:plugdir . '/plugin/test.vim' @@ -105,7 +104,7 @@ describe('packadd', function() packadd mytest " Must have been inserted in the middle, not at the end - call assert_true(&rtp =~ '/pack/mine/opt/mytest,') + call assert_true(&rtp =~ escape(expand('/pack/mine/opt/mytest').',', '\')) call assert_equal(44, g:plugin_works) " No change when doing it again. @@ -115,7 +114,7 @@ describe('packadd', function() set rtp& let rtp = &rtp - exec "silent !rm" top2_dir + exec "silent !" (has('win32') ? "rd /q/s" : "rm") top2_dir endfunc func Test_packloadall() From 3c0cc9c2fb3b4982bf39ded27fa3bdd454cb9af0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 00:28:37 -0400 Subject: [PATCH 07/21] win: enable legacy/wordcount_spec.lua --- test/functional/legacy/wordcount_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/wordcount_spec.lua b/test/functional/legacy/wordcount_spec.lua index 5412903866..0c8bd2cdcc 100644 --- a/test/functional/legacy/wordcount_spec.lua +++ b/test/functional/legacy/wordcount_spec.lua @@ -6,8 +6,6 @@ local clear, command = helpers.clear, helpers.command local eq, eval = helpers.eq, helpers.eval local wait = helpers.wait -if helpers.pending_win32(pending) then return end - describe('wordcount', function() before_each(clear) From c5a7f451ce2385c1d687fe2b5fe331c9ebc0d618 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 00:47:46 -0400 Subject: [PATCH 08/21] win: enable legacy/getcwd_spec.lua --- test/functional/legacy/getcwd_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/getcwd_spec.lua b/test/functional/legacy/getcwd_spec.lua index 8fb31ccd22..eae13da528 100644 --- a/test/functional/legacy/getcwd_spec.lua +++ b/test/functional/legacy/getcwd_spec.lua @@ -4,8 +4,6 @@ local helpers = require('test.functional.helpers')(after_each) local eq, eval, source = helpers.eq, helpers.eval, helpers.source local call, clear, command = helpers.call, helpers.clear, helpers.command -if helpers.pending_win32(pending) then return end - describe('getcwd', function() before_each(clear) From 18a53b65028869a7397711698c3aebaa86a441cc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 01:38:30 -0400 Subject: [PATCH 09/21] win: enable legacy test 30 --- test/functional/legacy/030_fileformats_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/030_fileformats_spec.lua b/test/functional/legacy/030_fileformats_spec.lua index 7384fdf847..2fd51602d8 100644 --- a/test/functional/legacy/030_fileformats_spec.lua +++ b/test/functional/legacy/030_fileformats_spec.lua @@ -5,8 +5,6 @@ local feed, clear, command = helpers.feed, helpers.clear, helpers.command local eq, write_file = helpers.eq, helpers.write_file local wait = helpers.wait -if helpers.pending_win32(pending) then return end - describe('fileformats option', function() setup(function() clear() From 10fbae086a205651b5ec76251f5bb4a4a6deaf06 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 09:51:25 -0400 Subject: [PATCH 10/21] win: enable legacy/arglist_spec.lua --- test/functional/legacy/arglist_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index ec754a533b..bd65e549ef 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -4,8 +4,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, command, eq = helpers.clear, helpers.command, helpers.eq local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq -if helpers.pending_win32(pending) then return end - describe('argument list commands', function() before_each(clear) From 44dc8b475300f5fecf8d959c51a53f841802d188 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 10:05:59 -0400 Subject: [PATCH 11/21] win: enable legacy test 093 --- .../functional/legacy/093_mksession_cursor_cols_latin1_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua index b1221ff8b6..f09fd9a6e5 100644 --- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua +++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua @@ -7,8 +7,6 @@ local helpers = require('test.functional.helpers')(after_each) local feed, insert = helpers.feed, helpers.insert local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect -if helpers.pending_win32(pending) then return end - describe('store cursor position in session file in Latin-1', function() setup(clear) From 2943056f75a5ead14cd4d370215821a229cfb49e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 10:30:12 -0400 Subject: [PATCH 12/21] win: enable legacy test 107 --- test/functional/legacy/107_adjust_window_and_contents_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua index 836a0f8f24..239f60341a 100644 --- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua +++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua @@ -8,8 +8,6 @@ local clear = helpers.clear local insert = helpers.insert local command = helpers.command -if helpers.pending_win32(pending) then return end - describe('107', function() setup(clear) From f1e6828b7bf45e3d3ea9acfba6a3e49938caa132 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 10:59:44 -0400 Subject: [PATCH 13/21] win: enable legacy test 059 --- .../legacy/059_utf8_spell_checking_spec.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/functional/legacy/059_utf8_spell_checking_spec.lua b/test/functional/legacy/059_utf8_spell_checking_spec.lua index 120e469ab2..8630ac58ef 100644 --- a/test/functional/legacy/059_utf8_spell_checking_spec.lua +++ b/test/functional/legacy/059_utf8_spell_checking_spec.lua @@ -5,8 +5,6 @@ local feed, insert, source = helpers.feed, helpers.insert, helpers.source local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect local write_file, call = helpers.write_file, helpers.call -if helpers.pending_win32(pending) then return end - local function write_latin1(name, text) text = call('iconv', text, 'utf-8', 'latin-1') write_file(name, text) @@ -507,8 +505,13 @@ describe("spell checking with 'encoding' set to utf-8", function() -- Vim function in the original legacy test. local function test_one(aff, dic) -- Generate a .spl file from a .dic and .aff file. - os.execute('cp -f Xtest'..aff..'.aff Xtest.aff') - os.execute('cp -f Xtest'..dic..'.dic Xtest.dic') + if helpers.iswin() then + os.execute('copy /y Xtest'..aff..'.aff Xtest.aff') + os.execute('copy /y Xtest'..dic..'.dic Xtest.dic') + else + os.execute('cp -f Xtest'..aff..'.aff Xtest.aff') + os.execute('cp -f Xtest'..dic..'.dic Xtest.dic') + end source([[ set spellfile= function! SpellDumpNoShow() @@ -559,7 +562,11 @@ describe("spell checking with 'encoding' set to utf-8", function() feed_command([[$put =soundfold('kóopërÿnôven')]]) feed_command([[$put =soundfold('oeverloos gezwets edale')]]) -- And now with SAL instead of SOFO items; test automatic reloading. - os.execute('cp -f Xtest-sal.aff Xtest.aff') + if helpers.iswin() then + os.execute('copy /y Xtest-sal.aff Xtest.aff') + else + os.execute('cp -f Xtest-sal.aff Xtest.aff') + end feed_command('mkspell! Xtest Xtest') feed_command([[$put =soundfold('goobledygoook')]]) feed_command([[$put =soundfold('kóopërÿnôven')]]) From 6beb7ee77ae7d0fdddc640b16eb8894a7c3a1883 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 20 Oct 2017 21:31:05 -0400 Subject: [PATCH 14/21] win: enable legacy test 051 --- test/functional/legacy/051_highlight_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua index 2ef74196ee..40f70de2ec 100644 --- a/test/functional/legacy/051_highlight_spec.lua +++ b/test/functional/legacy/051_highlight_spec.lua @@ -8,8 +8,6 @@ local eq = helpers.eq local wait = helpers.wait local exc_exec = helpers.exc_exec -if helpers.pending_win32(pending) then return end - describe(':highlight', function() setup(clear) From 55ce6bfffb3fc55353d4cd344963a545f5444ec4 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 5 Oct 2017 11:29:54 -0400 Subject: [PATCH 15/21] test: enable ex_cmds/write_spec.lua in Windows --- test/functional/ex_cmds/write_spec.lua | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index 863d439080..301e72bb42 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -10,8 +10,6 @@ local feed_command = helpers.feed_command local funcs = helpers.funcs local meths = helpers.meths -if helpers.pending_win32(pending) then return end - local fname = 'Xtest-functional-ex_cmds-write' local fname_bak = fname .. '~' local fname_broken = fname_bak .. 'broken' @@ -36,7 +34,11 @@ describe(':write', function() it('&backupcopy=auto preserves symlinks', function() command('set backupcopy=auto') write_file('test_bkc_file.txt', 'content0') - command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + if helpers.iswin() then + command("silent !mklink test_bkc_link.txt test_bkc_file.txt") + else + command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + end source([[ edit test_bkc_link.txt call setline(1, ['content1']) @@ -49,7 +51,11 @@ describe(':write', function() it('&backupcopy=no replaces symlink with new file', function() command('set backupcopy=no') write_file('test_bkc_file.txt', 'content0') - command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + if helpers.iswin() then + command("silent !mklink test_bkc_link.txt test_bkc_file.txt") + else + command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + end source([[ edit test_bkc_link.txt call setline(1, ['content1']) @@ -82,8 +88,11 @@ describe(':write', function() command('let $HOME=""') eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~')) -- Message from check_overwrite - eq(('\nE17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), - redir_exec('write .')) + -- FIXME: 'E13: File exists (add ! to override)' in Windows + if not helpers.iswin() then + eq(('\nE17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), + redir_exec('write .')) + end meths.set_option('writeany', true) -- Message from buf_write eq(('\nE502: "." is a directory'), @@ -100,9 +109,16 @@ describe(':write', function() funcs.setfperm(fname, 'r--------') eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)', exc_exec('write')) - os.remove(fname) - os.remove(fname_bak) + if helpers.iswin() then + eq(0, os.execute('del /q/f ' .. fname)) + eq(0, os.execute('rd /q/s ' .. fname_bak)) + else + eq(true, os.remove(fname)) + eq(true, os.remove(fname_bak)) + end write_file(fname_bak, 'TTYX') + -- FIXME: exc_exec('write!') outputs 0 in Windows + if helpers.iswin() then return end lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true) eq('Vim(write):E166: Can\'t open linked file for writing', exc_exec('write!')) From df99ab461ee2a515b82b53573de741b6d2024644 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 1 Nov 2017 17:40:59 -0400 Subject: [PATCH 16/21] test: enable legacy/fixeol_spec in Windows Try nvim's delete() for cross-platform file remove in Windows --- test/functional/legacy/fixeol_spec.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua index 801451b300..50236e8617 100644 --- a/test/functional/legacy/fixeol_spec.lua +++ b/test/functional/legacy/fixeol_spec.lua @@ -4,15 +4,14 @@ local helpers = require('test.functional.helpers')(after_each) local feed = helpers.feed local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect -if helpers.pending_win32(pending) then return end - describe('fixeol', function() local function rmtestfiles() - os.remove('test.out') - os.remove('XXEol') - os.remove('XXNoEol') - os.remove('XXTestEol') - os.remove('XXTestNoEol') + feed_command('%bwipeout!') + feed_command('call delete("test.out")') + feed_command('call delete("XXEol")') + feed_command('call delete("XXNoEol")') + feed_command('call delete("XXTestEol")') + feed_command('call delete("XXTestNoEol")') end setup(function() clear() From d80bf3c656cc4b64005cbc149a764a5c238203ad Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 11 Nov 2017 03:14:44 -0500 Subject: [PATCH 17/21] test: enable ex_cmds/cd_spec.lua on Windows --- test/functional/ex_cmds/cd_spec.lua | 47 +++++++++++++++-------------- test/functional/helpers.lua | 2 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index 059cb26d5d..d45f46ed3d 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -8,8 +8,7 @@ local call = helpers.call local clear = helpers.clear local command = helpers.command local exc_exec = helpers.exc_exec - -if helpers.pending_win32(pending) then return end +local pathsep = helpers.get_pathsep() -- These directories will be created for testing local directories = { @@ -75,8 +74,8 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, lwd(globalwin, tabnr)) -- Window with local dir reports as such - eq(globalDir .. '/' .. directories.window, cwd(localwin)) - eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr)) + eq(globalDir .. pathsep .. directories.window, cwd(localwin)) + eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr)) eq(1, lwd(localwin)) eq(1, lwd(localwin, tabnr)) @@ -86,7 +85,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, lwd(globalwin, tabnr)) -- From new tab page, local window reports as such - eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr)) + eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr)) eq(1, lwd(localwin, tabnr)) end) @@ -109,14 +108,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, lwd(-1, globaltab)) -- new tab reports local - eq(globalDir .. '/' .. directories.tab, cwd(-1, 0)) - eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab)) + eq(globalDir .. pathsep .. directories.tab, cwd(-1, 0)) + eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab)) eq(1, lwd(-1, 0)) eq(1, lwd(-1, localtab)) command('tabnext') -- From original tab page, local reports as such - eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab)) + eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab)) eq(1, lwd(-1, localtab)) end) end) @@ -147,17 +146,17 @@ for _, cmd in ipairs {'cd', 'chdir'} do -- Create a new tab and change directory command('tabnew') command('silent t' .. cmd .. ' ' .. directories.tab) - eq(globalDir .. '/' .. directories.tab, tcwd()) + eq(globalDir .. pathsep .. directories.tab, tcwd()) -- Create a new tab and verify it has inherited the directory command('tabnew') - eq(globalDir .. '/' .. directories.tab, tcwd()) + eq(globalDir .. pathsep .. directories.tab, tcwd()) -- Change tab and change back, verify that directories are correct command('tabnext') eq(globalDir, tcwd()) command('tabprevious') - eq(globalDir .. '/' .. directories.tab, tcwd()) + eq(globalDir .. pathsep .. directories.tab, tcwd()) end) end) @@ -173,7 +172,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do -- Change tab-local working directory and verify it is different command('silent t' .. cmd .. ' ' .. directories.tab) - eq(globalDir .. '/' .. directories.tab, cwd()) + eq(globalDir .. pathsep .. directories.tab, cwd()) eq(cwd(), tcwd()) -- working directory maches tab directory eq(1, tlwd()) eq(cwd(), wcwd()) -- still no window-directory @@ -183,16 +182,16 @@ for _, cmd in ipairs {'cd', 'chdir'} do command('new') eq(1, tlwd()) -- Still tab-local working directory eq(0, wlwd()) -- Still no window-local working directory - eq(globalDir .. '/' .. directories.tab, cwd()) + eq(globalDir .. pathsep .. directories.tab, cwd()) command('silent l' .. cmd .. ' ../' .. directories.window) - eq(globalDir .. '/' .. directories.window, cwd()) - eq(globalDir .. '/' .. directories.tab, tcwd()) + eq(globalDir .. pathsep .. directories.window, cwd()) + eq(globalDir .. pathsep .. directories.tab, tcwd()) eq(1, wlwd()) -- Verify the first window still has the tab local directory command('wincmd w') - eq(globalDir .. '/' .. directories.tab, cwd()) - eq(globalDir .. '/' .. directories.tab, tcwd()) + eq(globalDir .. pathsep .. directories.tab, cwd()) + eq(globalDir .. pathsep .. directories.tab, tcwd()) eq(0, wlwd()) -- No window-local directory -- Change back to initial tab and verify working directory has stayed @@ -203,10 +202,10 @@ for _, cmd in ipairs {'cd', 'chdir'} do -- Verify global changes don't affect local ones command('silent ' .. cmd .. ' ' .. directories.global) - eq(globalDir .. '/' .. directories.global, cwd()) + eq(globalDir .. pathsep .. directories.global, cwd()) command('tabnext') - eq(globalDir .. '/' .. directories.tab, cwd()) - eq(globalDir .. '/' .. directories.tab, tcwd()) + eq(globalDir .. pathsep .. directories.tab, cwd()) + eq(globalDir .. pathsep .. directories.tab, tcwd()) eq(0, wlwd()) -- Still no window-local directory in this window -- Unless the global change happened in a tab with local directory @@ -220,9 +219,9 @@ for _, cmd in ipairs {'cd', 'chdir'} do -- But not in a window with its own local directory command('tabnext | wincmd w') - eq(globalDir .. '/' .. directories.window, cwd() ) + eq(globalDir .. pathsep .. directories.window, cwd() ) eq(0 , tlwd()) - eq(globalDir .. '/' .. directories.window, wcwd()) + eq(globalDir .. pathsep .. directories.window, wcwd()) end) end) end @@ -280,6 +279,10 @@ describe("getcwd()", function () end) it("returns empty string if working directory does not exist", function() + if helpers.iswin() then + pending('[Cannot delete working directory in Windows]') + return + end command("cd "..directories.global) command("call delete('../"..directories.global.."', 'd')") eq("", helpers.eval("getcwd()")) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index a1da55ab1c..1f53200dd8 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -641,7 +641,7 @@ local function redir_exec(cmd) end local function get_pathsep() - return funcs.fnamemodify('.', ':p'):sub(-1) + return iswin() and '\\' or '/' end local function pathroot() From 8dcfd58e2c20adea1eb69a97dead7a45d5beb170 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 15 Feb 2018 14:13:47 -0500 Subject: [PATCH 18/21] test: win: enable termclose_spec.lua --- test/functional/autocmd/termclose_spec.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua index e64df502a6..9918cbe4fa 100644 --- a/test/functional/autocmd/termclose_spec.lua +++ b/test/functional/autocmd/termclose_spec.lua @@ -5,8 +5,8 @@ local clear, command, nvim, nvim_dir = local eval, eq, retry = helpers.eval, helpers.eq, helpers.retry local ok = helpers.ok +local iswin = helpers.iswin -if helpers.pending_win32(pending) then return end describe('TermClose event', function() before_each(function() @@ -23,7 +23,7 @@ describe('TermClose event', function() end) it('triggers when long-running terminal job gets stopped', function() - nvim('set_option', 'shell', 'sh') + nvim('set_option', 'shell', iswin() and 'cmd.exe' or 'sh') command('autocmd TermClose * let g:test_termclose = 23') command('terminal') command('call jobstop(b:terminal_job_id)') @@ -31,6 +31,7 @@ describe('TermClose event', function() end) it('kills job trapping SIGTERM', function() + if helpers.pending_win32(pending) then return end nvim('set_option', 'shell', 'sh') nvim('set_option', 'shellcmdflag', '-c') command([[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]] @@ -48,6 +49,7 @@ describe('TermClose event', function() end) it('kills pty job trapping SIGHUP and SIGTERM', function() + if helpers.pending_win32(pending) then return end nvim('set_option', 'shell', 'sh') nvim('set_option', 'shellcmdflag', '-c') command([[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]] From 07dfe0f5ea31521679926b7aeacde5e3944246ea Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 17 Feb 2018 00:36:59 -0500 Subject: [PATCH 19/21] test: win: enable ui/wildmode_spec.lua --- test/functional/ui/wildmode_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 042969357e..946194ed13 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -60,15 +60,15 @@ describe("'wildmenu'", function() command('set wildmenu wildmode=full') command('set scrollback=4') if iswin() then - if helpers.pending_win32(pending) then return end - -- feed([[:terminal 1,2,3,4,5 | foreach-object -process {echo $_; sleep 0.1}]]) + helpers.set_shell_powershell() + feed([[:terminal for ($i = 1; $i -le 5000; $i++) {Write-Output foo foo foo; Start-Sleep -Milliseconds 100}]]) else feed([[:terminal for i in $(seq 1 5000); do printf 'foo\nfoo\nfoo\n'; sleep 0.1; done]]) end feed([[gg]]) feed([[:sign ]]) -- Invoke wildmenu. - screen:sleep(50) -- Allow some terminal output. + screen:sleep(iswin() and 500 or 50) -- Allow some terminal output. screen:expect([[ foo | foo | @@ -80,7 +80,7 @@ describe("'wildmenu'", function() -- cmdline CTRL-D display should also be preserved. feed([[]]) feed([[:sign ]]) -- Invoke cmdline CTRL-D. - screen:sleep(50) -- Allow some terminal output. + screen:sleep(iswin() and 500 or 50) -- Allow some terminal output. screen:expect([[ :sign | define place | From 795da343bbf99c4b77d10cd5035c29df23f113ae Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 17 Feb 2018 02:25:51 -0500 Subject: [PATCH 20/21] test: win: emulate yes with for loop --- test/functional/eval/system_spec.lua | 12 ++++++++---- test/functional/ui/wildmode_spec.lua | 7 +++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua index 7fe79d4351..446afefb59 100644 --- a/test/functional/eval/system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -188,8 +188,9 @@ describe('system()', function() end) it('`yes` and is interrupted with CTRL-C', function() - if helpers.pending_win32(pending) then return end - feed(':call system("yes")') + feed(':call system("' .. (iswin() + and 'for /L %I in (1,0,2) do @echo y' + or 'yes') .. '")') screen:expect([[ | ~ | @@ -204,8 +205,11 @@ describe('system()', function() ~ | ~ | ~ | - :call system("yes") | - ]]) +]] .. (iswin() + and [[ + :call system("for /L %I in (1,0,2) do @echo y") |]] + or [[ + :call system("yes") |]])) feed('') screen:expect([[ ^ | diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 946194ed13..c6ddc78618 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -60,15 +60,14 @@ describe("'wildmenu'", function() command('set wildmenu wildmode=full') command('set scrollback=4') if iswin() then - helpers.set_shell_powershell() - feed([[:terminal for ($i = 1; $i -le 5000; $i++) {Write-Output foo foo foo; Start-Sleep -Milliseconds 100}]]) + feed([[:terminal for /L \%I in (1,1,5000) do @(echo foo & echo foo & echo foo)]]) else feed([[:terminal for i in $(seq 1 5000); do printf 'foo\nfoo\nfoo\n'; sleep 0.1; done]]) end feed([[gg]]) feed([[:sign ]]) -- Invoke wildmenu. - screen:sleep(iswin() and 500 or 50) -- Allow some terminal output. + screen:sleep(50) -- Allow some terminal output. screen:expect([[ foo | foo | @@ -80,7 +79,7 @@ describe("'wildmenu'", function() -- cmdline CTRL-D display should also be preserved. feed([[]]) feed([[:sign ]]) -- Invoke cmdline CTRL-D. - screen:sleep(iswin() and 500 or 50) -- Allow some terminal output. + screen:sleep(50) -- Allow some terminal output. screen:expect([[ :sign | define place | From 7fa69fb288d9fcf66c2fe504d760cc7a23da7256 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 19 Feb 2018 07:09:46 -0500 Subject: [PATCH 21/21] Resolve issues mentioned in PR review --- test/functional/core/job_spec.lua | 4 ---- test/functional/ex_cmds/cd_spec.lua | 1 - test/functional/ex_cmds/write_spec.lua | 1 - 3 files changed, 6 deletions(-) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 5f39040a6f..50feb41d1a 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -297,10 +297,6 @@ describe('jobs', function() eq({'notification', 'exit', {data, 0}}, next_msg()) end) - it('can omit options', function() - ok(eval([[jobstart('echo ""')]]) > 0) - end) - it('can omit data callbacks', function() nvim('command', 'unlet g:job_opts.on_stdout') nvim('command', 'let g:job_opts.user = 5') diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index d45f46ed3d..bc2b365b30 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -280,7 +280,6 @@ describe("getcwd()", function () it("returns empty string if working directory does not exist", function() if helpers.iswin() then - pending('[Cannot delete working directory in Windows]') return end command("cd "..directories.global) diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index 301e72bb42..bcf83698bb 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -88,7 +88,6 @@ describe(':write', function() command('let $HOME=""') eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~')) -- Message from check_overwrite - -- FIXME: 'E13: File exists (add ! to override)' in Windows if not helpers.iswin() then eq(('\nE17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), redir_exec('write .'))