From 4b1f21de75f9981007d80aca8355239e8615d6bd Mon Sep 17 00:00:00 2001 From: erw7 Date: Tue, 28 Mar 2017 18:07:58 +0900 Subject: win: support :terminal --- test/functional/terminal/ex_terminal_spec.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index be0fd9f8ff..5eb6a5f18c 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -3,10 +3,10 @@ local Screen = require('test.functional.ui.screen') local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq local feed_command, eval = helpers.feed_command, helpers.eval - -if helpers.pending_win32(pending) then return end +local iswin = helpers.iswin describe(':terminal', function() + if helpers.pending_win32(pending) then return end local screen before_each(function() @@ -174,10 +174,15 @@ describe(':terminal (with fake shell)', function() eq('term://', string.match(eval('bufname("%")'), "^term://")) helpers.feed([[]]) feed_command([[find */shadacat.py]]) - eq('scripts/shadacat.py', eval('bufname("%")')) + if iswin() then + eq('scripts\\shadacat.py', eval('bufname("%")')) + else + eq('scripts/shadacat.py', eval('bufname("%")')) + end end) it('works with gf', function() + if helpers.pending_win32(pending) then return end terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) wait() screen:expect([[ -- cgit From d2d76882f74875d6c1ee10f31524b104eab6375d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 8 Aug 2017 02:26:25 +0200 Subject: win/test: enable more :terminal tests To deal with SIGWINCH limitations on Windows, change some resize tests to _shrink_ the screen width. ... But this didn't work, so still ignoring those tests on Windows. --- test/functional/terminal/ex_terminal_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 5eb6a5f18c..9930efc402 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -182,9 +182,7 @@ describe(':terminal (with fake shell)', function() end) it('works with gf', function() - if helpers.pending_win32(pending) then return end terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) - wait() screen:expect([[ ready $ echo "scripts/shadacat.py" | | -- cgit From 642e14d9e7d946d1ebd4395f9c9497926c0df2f3 Mon Sep 17 00:00:00 2001 From: Drew Neil Date: Thu, 25 May 2017 11:27:56 +0100 Subject: Repair ex_terminal_spec functional tests --- test/functional/terminal/ex_terminal_spec.lua | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 9930efc402..7522f073c4 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -72,10 +72,10 @@ describe(':terminal (with fake shell)', function() terminal_with_fake_shell() wait() screen:expect([[ - ready $ | + ^ready $ | [Process exited 0] | | - -- TERMINAL -- | + :terminal | ]]) end) @@ -96,10 +96,10 @@ describe(':terminal (with fake shell)', function() terminal_with_fake_shell() wait() screen:expect([[ - jeff $ | + ^jeff $ | [Process exited 0] | | - -- TERMINAL -- | + :terminal | ]]) end) @@ -107,10 +107,10 @@ describe(':terminal (with fake shell)', function() terminal_with_fake_shell('echo hi') wait() screen:expect([[ - ready $ echo hi | + ^ready $ echo hi | | [Process exited 0] | - -- TERMINAL -- | + :terminal echo hi | ]]) end) @@ -119,10 +119,10 @@ describe(':terminal (with fake shell)', function() terminal_with_fake_shell('echo hi') wait() screen:expect([[ - jeff $ echo hi | + ^jeff $ echo hi | | [Process exited 0] | - -- TERMINAL -- | + :terminal echo hi | ]]) end) @@ -130,10 +130,10 @@ describe(':terminal (with fake shell)', function() terminal_with_fake_shell([[echo 'hello' \ "world"]]) wait() screen:expect([[ - ready $ echo 'hello' \ "world" | + ^ready $ echo 'hello' \ "world" | | [Process exited 0] | - -- TERMINAL -- | + :terminal echo 'hello' \ "world" | ]]) end) @@ -166,10 +166,10 @@ describe(':terminal (with fake shell)', function() terminal_with_fake_shell() wait() screen:expect([[ - ready $ | + ^ready $ | [Process exited 0] | | - -- TERMINAL -- | + :terminal | ]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) helpers.feed([[]]) @@ -184,10 +184,10 @@ describe(':terminal (with fake shell)', function() it('works with gf', function() terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) screen:expect([[ - ready $ echo "scripts/shadacat.py" | + ^ready $ echo "scripts/shadacat.py" | | [Process exited 0] | - -- TERMINAL -- | + :terminal echo "scripts/shadacat.py" | ]]) helpers.feed([[]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) -- cgit From 618cfe03fce818ae546292e34d808d0d5e8ae631 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 7 Sep 2017 09:40:37 +0200 Subject: test: ex_terminal_spec.lua: retry flaky test (#7245) https://api.travis-ci.org/jobs/271833660/log.txt --- test/functional/terminal/ex_terminal_spec.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 7522f073c4..e015df10db 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq local feed_command, eval = helpers.feed_command, helpers.eval +local retry = helpers.retry local iswin = helpers.iswin describe(':terminal', function() @@ -70,19 +71,19 @@ describe(':terminal (with fake shell)', function() it('with no argument, acts like termopen()', function() terminal_with_fake_shell() - wait() + retry(3, 4 * screen.timeout, function() screen:expect([[ ^ready $ | [Process exited 0] | | :terminal | ]]) + end) end) it("with no argument, and 'shell' is set to empty string", function() nvim('set_option', 'shell', '') terminal_with_fake_shell() - wait() screen:expect([[ ^ | ~ | @@ -94,7 +95,6 @@ describe(':terminal (with fake shell)', function() it("with no argument, but 'shell' has arguments, acts like termopen()", function() nvim('set_option', 'shell', nvim_dir..'/shell-test -t jeff') terminal_with_fake_shell() - wait() screen:expect([[ ^jeff $ | [Process exited 0] | @@ -105,7 +105,6 @@ describe(':terminal (with fake shell)', function() it('executes a given command through the shell', function() terminal_with_fake_shell('echo hi') - wait() screen:expect([[ ^ready $ echo hi | | @@ -117,7 +116,6 @@ describe(':terminal (with fake shell)', function() it("executes a given command through the shell, when 'shell' has arguments", function() nvim('set_option', 'shell', nvim_dir..'/shell-test -t jeff') terminal_with_fake_shell('echo hi') - wait() screen:expect([[ ^jeff $ echo hi | | @@ -128,7 +126,6 @@ describe(':terminal (with fake shell)', function() it('allows quotes and slashes', function() terminal_with_fake_shell([[echo 'hello' \ "world"]]) - wait() screen:expect([[ ^ready $ echo 'hello' \ "world" | | @@ -164,7 +161,6 @@ describe(':terminal (with fake shell)', function() it('works with :find', function() terminal_with_fake_shell() - wait() screen:expect([[ ^ready $ | [Process exited 0] | -- cgit From e9b5616eaf49755c972bcc46719f985f9ca1e15f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 5 Oct 2017 12:38:10 -0400 Subject: win: enable tests in ex_terminal_spec --- test/functional/terminal/ex_terminal_spec.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index e015df10db..ee92ba6865 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -7,7 +7,6 @@ local retry = helpers.retry local iswin = helpers.iswin describe(':terminal', function() - if helpers.pending_win32(pending) then return end local screen before_each(function() @@ -24,7 +23,11 @@ describe(':terminal', function() echomsg "msg3" ]]) -- Invoke a command that emits frequent terminal activity. - feed_command([[terminal while true; do echo X; done]]) + if iswin() then + feed_command([[terminal for /L \\%I in (1,0,2) do echo \\%I]]) + else + feed_command([[terminal while true; do echo X; done]]) + end helpers.feed([[]]) wait() screen:sleep(10) -- Let some terminal activity happen. @@ -38,7 +41,11 @@ describe(':terminal', function() end) it("in normal-mode :split does not move cursor", function() - feed_command([[terminal while true; do echo foo; sleep .1; done]]) + if iswin() then + feed_command([[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]]) + else + feed_command([[terminal while true; do echo foo; sleep .1; done]]) + end helpers.feed([[M]]) -- move cursor away from last line wait() eq(3, eval("line('$')")) -- window height -- cgit From d73dd1588ce6be4aa90b83fdcf4efc31ef743aec Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 5 Feb 2018 23:38:30 +0100 Subject: :terminal Enter/Leave should not increment jumplist The old behavior is probably not justified, for the usual reason: terminal buffers may have interactive processes, so cursor placement is arbitrary, therefore tracking it in the jumplist is useless (or worse). N.B.: per the docstring for `checkpcmark()` it looks like we were calling `checkpcmark()` and `setpcmark()` in the wrong order. closes #3723 --- test/functional/terminal/ex_terminal_spec.lua | 50 ++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index ee92ba6865..0a30b9bb02 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -2,8 +2,11 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq +local feed = helpers.feed local feed_command, eval = helpers.feed_command, helpers.eval +local funcs = helpers.funcs local retry = helpers.retry +local ok = helpers.ok local iswin = helpers.iswin describe(':terminal', function() @@ -24,13 +27,16 @@ describe(':terminal', function() ]]) -- Invoke a command that emits frequent terminal activity. if iswin() then - feed_command([[terminal for /L \\%I in (1,0,2) do echo \\%I]]) + feed_command([[terminal for /L \%I in (1,0,2) do echo \%I]]) else feed_command([[terminal while true; do echo X; done]]) end - helpers.feed([[]]) + feed([[]]) wait() - screen:sleep(10) -- Let some terminal activity happen. + -- Wait for some terminal activity. + retry(nil, 4000, function() + ok(funcs.line('$') > 6) + end) feed_command("messages") screen:expect([[ msg1 | @@ -46,7 +52,7 @@ describe(':terminal', function() else feed_command([[terminal while true; do echo foo; sleep .1; done]]) end - helpers.feed([[M]]) -- move cursor away from last line + feed([[M]]) -- move cursor away from last line wait() eq(3, eval("line('$')")) -- window height eq(2, eval("line('.')")) -- cursor is in the middle @@ -56,6 +62,32 @@ describe(':terminal', function() eq(2, eval("line('.')")) -- cursor stays where we put it end) + it('Enter/Leave does not increment jumplist #3723', function() + feed_command('terminal') + local function enter_and_leave() + local lines_before = funcs.line('$') + -- Create a new line (in the shell). For a normal buffer this + -- increments the jumplist; for a terminal-buffer it should not. #3723 + feed('i') + wait() + feed('') + wait() + feed([[]]) + wait() + -- Wait for >=1 lines to be created. + retry(nil, 4000, function() + ok(funcs.line('$') > lines_before) + end) + end + enter_and_leave() + enter_and_leave() + enter_and_leave() + ok(funcs.line('$') > 6) -- Verify assumption. + local jumps = funcs.split(funcs.execute('jumps'), '\n') + eq(' jump line col file/text', jumps[1]) + eq(3, #jumps) + end) + end) describe(':terminal (with fake shell)', function() @@ -151,12 +183,12 @@ describe(':terminal (with fake shell)', function() it('ignores writes if the backing stream closes', function() terminal_with_fake_shell() - helpers.feed('iiXXXXXXX') + feed('iiXXXXXXX') wait() -- Race: Though the shell exited (and streams were closed by SIGCHLD -- handler), :terminal cleanup is pending on the main-loop. -- This write should be ignored (not crash, #5445). - helpers.feed('iiYYYYYYY') + feed('iiYYYYYYY') eq(2, eval("1+1")) -- Still alive? end) @@ -175,7 +207,7 @@ describe(':terminal (with fake shell)', function() :terminal | ]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) - helpers.feed([[]]) + feed([[]]) feed_command([[find */shadacat.py]]) if iswin() then eq('scripts\\shadacat.py', eval('bufname("%")')) @@ -192,9 +224,9 @@ describe(':terminal (with fake shell)', function() [Process exited 0] | :terminal echo "scripts/shadacat.py" | ]]) - helpers.feed([[]]) + feed([[]]) eq('term://', string.match(eval('bufname("%")'), "^term://")) - helpers.feed([[ggf"lgf]]) + feed([[ggf"lgf]]) eq('scripts/shadacat.py', eval('bufname("%")')) end) -- cgit From 131aad953c007d382cbff1d2560471b29975da87 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 30 Sep 2017 21:31:31 -0400 Subject: win: defaults: 'shellcmdflag', 'shellxquote' #7343 closes #7698 Wrapping a command in double-quotes allows cmd.exe to safely dequote the entire command as if the user entered the entire command in an interactive prompt. This reduces the need to escape nested and uneven double quotes. The `/s` flag of cmd.exe makes the behaviour more reliable: :set shellcmdflag=/s\ /c Before this patch, cmd.exe cannot use cygwin echo.exe (as opposed to cmd.exe `echo` builtin) even if it is wrapped in double quotes. Example: :: internal echo > cmd /s /c " echo foo\:bar" " foo\:bar" :: cygwin echo.exe > cmd /s /c " "echo" foo\:bar" " foo:bar --- test/functional/terminal/ex_terminal_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional/terminal/ex_terminal_spec.lua') diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 0a30b9bb02..4f22f7385d 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -8,6 +8,7 @@ local funcs = helpers.funcs local retry = helpers.retry local ok = helpers.ok local iswin = helpers.iswin +local command = helpers.command describe(':terminal', function() local screen @@ -143,6 +144,7 @@ describe(':terminal (with fake shell)', function() end) it('executes a given command through the shell', function() + command('set shellxquote=') -- win: avoid extra quotes terminal_with_fake_shell('echo hi') screen:expect([[ ^ready $ echo hi | @@ -154,6 +156,7 @@ describe(':terminal (with fake shell)', function() it("executes a given command through the shell, when 'shell' has arguments", function() nvim('set_option', 'shell', nvim_dir..'/shell-test -t jeff') + command('set shellxquote=') -- win: avoid extra quotes terminal_with_fake_shell('echo hi') screen:expect([[ ^jeff $ echo hi | @@ -164,6 +167,7 @@ describe(':terminal (with fake shell)', function() end) it('allows quotes and slashes', function() + command('set shellxquote=') -- win: avoid extra quotes terminal_with_fake_shell([[echo 'hello' \ "world"]]) screen:expect([[ ^ready $ echo 'hello' \ "world" | @@ -217,6 +221,7 @@ describe(':terminal (with fake shell)', function() end) it('works with gf', function() + command('set shellxquote=') -- win: avoid extra quotes terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) screen:expect([[ ^ready $ echo "scripts/shadacat.py" | -- cgit