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/scrollback_spec.lua | 64 +++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 05f81295c2..649bb4373b 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command +local iswin, wait_sigwinch = helpers.iswin, thelpers.wait_sigwinch local eval = helpers.eval local command = helpers.command local wait = helpers.wait @@ -11,8 +12,6 @@ local curbufmeths = helpers.curbufmeths local nvim = helpers.nvim local feed_data = thelpers.feed_data -if helpers.pending_win32(pending) then return end - describe('terminal scrollback', function() local screen @@ -142,6 +141,9 @@ describe('terminal scrollback', function() describe('and the height is decreased by 1', function() local function will_hide_top_line() screen:try_resize(screen._width, screen._height - 1) + if iswin() then + wait_sigwinch() + end screen:expect([[ line2 | line3 | @@ -158,6 +160,9 @@ describe('terminal scrollback', function() before_each(function() will_hide_top_line() screen:try_resize(screen._width, screen._height - 2) + if iswin() then + wait_sigwinch() + end end) it('will hide the top 3 lines', function() @@ -184,9 +189,13 @@ describe('terminal scrollback', function() describe('and the height is decreased by 2', function() before_each(function() screen:try_resize(screen._width, screen._height - 2) + if iswin() then + wait_sigwinch() + end end) local function will_delete_last_two_lines() + if helpers.pending_win32(pending) then return end screen:expect([[ tty ready | rows: 4, cols: 30 | @@ -200,9 +209,13 @@ describe('terminal scrollback', function() it('will delete the last two empty lines', will_delete_last_two_lines) describe('and then decreased by 1', function() + if helpers.pending_win32(pending) then return end before_each(function() will_delete_last_two_lines() screen:try_resize(screen._width, screen._height - 1) + if iswin() then + wait_sigwinch() + end end) it('will delete the last line and hide the first', function() @@ -245,6 +258,9 @@ describe('terminal scrollback', function() {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) + if iswin() then + wait_sigwinch() + end screen:expect([[ line4 | rows: 3, cols: 30 | @@ -257,6 +273,9 @@ describe('terminal scrollback', function() describe('and the height is increased by 1', function() local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) + if iswin() then + wait_sigwinch() + end screen:expect([[ line4 | rows: 3, cols: 30 | @@ -273,6 +292,9 @@ describe('terminal scrollback', function() pop_then_push() eq(8, curbuf('line_count')) screen:try_resize(screen._width, screen._height + 3) + if iswin() then + wait_sigwinch() + end end) local function pop3_then_push1() @@ -303,10 +325,14 @@ describe('terminal scrollback', function() it('will pop 3 lines and then push one back', pop3_then_push1) describe('and then by 4', function() + if helpers.pending_win32(pending) then return end before_each(function() pop3_then_push1() feed('Gi') screen:try_resize(screen._width, screen._height + 4) + if iswin() then + wait_sigwinch() + end end) it('will show all lines and leave a blank one at the end', function() @@ -384,10 +410,20 @@ describe("'scrollback' option", function() end it('set to 0 behaves as 1', function() - local screen = thelpers.screen_setup(nil, "['sh']", 30) + local screen + if iswin() then + screen = thelpers.screen_setup(nil, + "['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30) + else + screen = thelpers.screen_setup(nil, "['sh']", 30) + end curbufmeths.set_option('scrollback', 0) - feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + if iswin() then + feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r') + else + feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + end screen:expect('line30 ', nil, nil, nil, true) retry(nil, nil, function() expect_lines(7) end) @@ -395,7 +431,13 @@ describe("'scrollback' option", function() end) it('deletes lines (only) if necessary', function() - local screen = thelpers.screen_setup(nil, "['sh']", 30) + local screen + if iswin() then + screen = thelpers.screen_setup(nil, + "['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30) + else + screen = thelpers.screen_setup(nil, "['sh']", 30) + end curbufmeths.set_option('scrollback', 200) @@ -403,7 +445,11 @@ describe("'scrollback' option", function() screen:expect('$', nil, nil, nil, true) wait() - feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + if iswin() then + feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r') + else + feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + end screen:expect('line30 ', nil, nil, nil, true) @@ -416,7 +462,11 @@ describe("'scrollback' option", function() -- Terminal job data is received asynchronously, may happen before the -- 'scrollback' option is synchronized with the internal sb_buffer. command('sleep 100m') - feed_data('for i in $(seq 1 40); do echo "line$i"; done\n') + if iswin() then + feed_data('for($i=1;$i -le 40;$i++){Write-Host \"line$i\"}\r') + else + feed_data('for i in $(seq 1 40); do echo "line$i"; done\n') + end screen:expect('line40 ', nil, nil, nil, true) -- cgit From 1614e805b33bf159a7af06ed54a0fb5823d8e407 Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 31 Mar 2017 05:40:37 +0900 Subject: win/test: tty-test: print screen size explicitly with CTRL-Q tty-test.exe causes abnormal termination with low repeatability, try changing it so as not to use SIGWINCH. --- test/functional/terminal/scrollback_spec.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 649bb4373b..1333736376 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command -local iswin, wait_sigwinch = helpers.iswin, thelpers.wait_sigwinch +local iswin, print_screen_size = helpers.iswin, thelpers.print_screen_size local eval = helpers.eval local command = helpers.command local wait = helpers.wait @@ -142,7 +142,7 @@ describe('terminal scrollback', function() local function will_hide_top_line() screen:try_resize(screen._width, screen._height - 1) if iswin() then - wait_sigwinch() + print_screen_size() end screen:expect([[ line2 | @@ -161,7 +161,7 @@ describe('terminal scrollback', function() will_hide_top_line() screen:try_resize(screen._width, screen._height - 2) if iswin() then - wait_sigwinch() + print_screen_size() end end) @@ -190,7 +190,7 @@ describe('terminal scrollback', function() before_each(function() screen:try_resize(screen._width, screen._height - 2) if iswin() then - wait_sigwinch() + print_screen_size() end end) @@ -214,7 +214,7 @@ describe('terminal scrollback', function() will_delete_last_two_lines() screen:try_resize(screen._width, screen._height - 1) if iswin() then - wait_sigwinch() + print_screen_size() end end) @@ -259,7 +259,7 @@ describe('terminal scrollback', function() ]]) screen:try_resize(screen._width, screen._height - 3) if iswin() then - wait_sigwinch() + print_screen_size() end screen:expect([[ line4 | @@ -274,7 +274,7 @@ describe('terminal scrollback', function() local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) if iswin() then - wait_sigwinch() + print_screen_size() end screen:expect([[ line4 | @@ -293,7 +293,7 @@ describe('terminal scrollback', function() eq(8, curbuf('line_count')) screen:try_resize(screen._width, screen._height + 3) if iswin() then - wait_sigwinch() + print_screen_size() end end) @@ -331,7 +331,7 @@ describe('terminal scrollback', function() feed('Gi') screen:try_resize(screen._width, screen._height + 4) if iswin() then - wait_sigwinch() + print_screen_size() end end) -- cgit From d3a8c4f99289f7b65a68bf9ed5eeab34aa688e0e Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 2 Apr 2017 18:32:23 +0900 Subject: win/pty: log errors --- test/functional/terminal/scrollback_spec.lua | 36 +++++----------------------- 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 1333736376..f39335bfd0 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -3,7 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command -local iswin, print_screen_size = helpers.iswin, thelpers.print_screen_size +local iswin = helpers.iswin local eval = helpers.eval local command = helpers.command local wait = helpers.wait @@ -141,10 +141,7 @@ describe('terminal scrollback', function() describe('and the height is decreased by 1', function() local function will_hide_top_line() screen:try_resize(screen._width, screen._height - 1) - if iswin() then - print_screen_size() - end - screen:expect([[ + screen:expect_after_resize([[ line2 | line3 | line4 | @@ -160,13 +157,10 @@ describe('terminal scrollback', function() before_each(function() will_hide_top_line() screen:try_resize(screen._width, screen._height - 2) - if iswin() then - print_screen_size() - end end) it('will hide the top 3 lines', function() - screen:expect([[ + screen:expect_after_resize([[ rows: 5, cols: 30 | rows: 3, cols: 30 | {1: } | @@ -189,9 +183,6 @@ describe('terminal scrollback', function() describe('and the height is decreased by 2', function() before_each(function() screen:try_resize(screen._width, screen._height - 2) - if iswin() then - print_screen_size() - end end) local function will_delete_last_two_lines() @@ -213,9 +204,6 @@ describe('terminal scrollback', function() before_each(function() will_delete_last_two_lines() screen:try_resize(screen._width, screen._height - 1) - if iswin() then - print_screen_size() - end end) it('will delete the last line and hide the first', function() @@ -258,10 +246,7 @@ describe('terminal scrollback', function() {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) - if iswin() then - print_screen_size() - end - screen:expect([[ + screen:expect_after_resize([[ line4 | rows: 3, cols: 30 | {1: } | @@ -273,10 +258,7 @@ describe('terminal scrollback', function() describe('and the height is increased by 1', function() local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) - if iswin() then - print_screen_size() - end - screen:expect([[ + screen:expect_after_resize([[ line4 | rows: 3, cols: 30 | rows: 4, cols: 30 | @@ -292,13 +274,10 @@ describe('terminal scrollback', function() pop_then_push() eq(8, curbuf('line_count')) screen:try_resize(screen._width, screen._height + 3) - if iswin() then - print_screen_size() - end end) local function pop3_then_push1() - screen:expect([[ + screen:expect_after_resize([[ line2 | line3 | line4 | @@ -330,9 +309,6 @@ describe('terminal scrollback', function() pop3_then_push1() feed('Gi') screen:try_resize(screen._width, screen._height + 4) - if iswin() then - print_screen_size() - end end) it('will show all lines and leave a blank one at the end', function() -- cgit From 6a90f53862d9f75f7aeea350944c466aa85f11a2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 6 Aug 2017 14:26:17 +0200 Subject: test: cleanup --- test/functional/terminal/scrollback_spec.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index f39335bfd0..b6b0228513 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -141,7 +141,8 @@ describe('terminal scrollback', function() describe('and the height is decreased by 1', function() local function will_hide_top_line() screen:try_resize(screen._width, screen._height - 1) - screen:expect_after_resize([[ + retry(nil, 100000, function() + screen:expect([[ line2 | line3 | line4 | @@ -149,6 +150,7 @@ describe('terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) + end) end it('will hide top line', will_hide_top_line) @@ -160,7 +162,8 @@ describe('terminal scrollback', function() end) it('will hide the top 3 lines', function() - screen:expect_after_resize([[ + retry(nil, 100000, function() + screen:expect([[ rows: 5, cols: 30 | rows: 3, cols: 30 | {1: } | @@ -174,19 +177,21 @@ describe('terminal scrollback', function() rows: 3, cols: 30 | | ]]) + end) end) end) end) end) describe('with empty lines after the cursor', function() + if helpers.pending_win32(pending) then return end + describe('and the height is decreased by 2', function() before_each(function() screen:try_resize(screen._width, screen._height - 2) end) local function will_delete_last_two_lines() - if helpers.pending_win32(pending) then return end screen:expect([[ tty ready | rows: 4, cols: 30 | @@ -200,7 +205,6 @@ describe('terminal scrollback', function() it('will delete the last two empty lines', will_delete_last_two_lines) describe('and then decreased by 1', function() - if helpers.pending_win32(pending) then return end before_each(function() will_delete_last_two_lines() screen:try_resize(screen._width, screen._height - 1) @@ -246,19 +250,21 @@ describe('terminal scrollback', function() {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) - screen:expect_after_resize([[ + retry(nil, 100000, function() + screen:expect([[ line4 | rows: 3, cols: 30 | {1: } | {3:-- TERMINAL --} | ]]) eq(7, curbuf('line_count')) + end) end) describe('and the height is increased by 1', function() local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) - screen:expect_after_resize([[ + screen:expect([[ line4 | rows: 3, cols: 30 | rows: 4, cols: 30 | @@ -277,7 +283,7 @@ describe('terminal scrollback', function() end) local function pop3_then_push1() - screen:expect_after_resize([[ + screen:expect([[ line2 | line3 | line4 | -- cgit From e0763e94ade67c99f9d9f46cd51299b174969927 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 7 Aug 2017 00:26:43 +0200 Subject: test: tty-test.c: restore win32 SIGWINCH handler --- test/functional/terminal/scrollback_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index b6b0228513..f804862996 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -141,7 +141,6 @@ describe('terminal scrollback', function() describe('and the height is decreased by 1', function() local function will_hide_top_line() screen:try_resize(screen._width, screen._height - 1) - retry(nil, 100000, function() screen:expect([[ line2 | line3 | @@ -150,7 +149,6 @@ describe('terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - end) end it('will hide top line', will_hide_top_line) @@ -162,7 +160,6 @@ describe('terminal scrollback', function() end) it('will hide the top 3 lines', function() - retry(nil, 100000, function() screen:expect([[ rows: 5, cols: 30 | rows: 3, cols: 30 | @@ -177,13 +174,15 @@ describe('terminal scrollback', function() rows: 3, cols: 30 | | ]]) - end) end) end) end) end) describe('with empty lines after the cursor', function() + -- XXX: Can't test this reliably on Windows unless the cursor is _moved_ + -- by the resize. http://docs.libuv.org/en/v1.x/signal.html + -- See also: https://github.com/rprichard/winpty/issues/110 if helpers.pending_win32(pending) then return end describe('and the height is decreased by 2', function() @@ -250,7 +249,6 @@ describe('terminal scrollback', function() {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) - retry(nil, 100000, function() screen:expect([[ line4 | rows: 3, cols: 30 | @@ -258,10 +256,13 @@ describe('terminal scrollback', function() {3:-- TERMINAL --} | ]]) eq(7, curbuf('line_count')) - end) end) describe('and the height is increased by 1', function() + -- XXX: Can't test this reliably on Windows unless the cursor is _moved_ + -- by the resize. http://docs.libuv.org/en/v1.x/signal.html + -- See also: https://github.com/rprichard/winpty/issues/110 + if helpers.pending_win32(pending) then return end local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) screen:expect([[ @@ -310,7 +311,6 @@ describe('terminal scrollback', function() it('will pop 3 lines and then push one back', pop3_then_push1) describe('and then by 4', function() - if helpers.pending_win32(pending) then return end before_each(function() pop3_then_push1() feed('Gi') -- cgit From dbb404542b3dc165e8186c839b5071f6511f8f8e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 13 Aug 2017 19:54:48 +0200 Subject: test/win: place cursor at edge to tickle SIGWINCH --- test/functional/terminal/scrollback_spec.lua | 39 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index f804862996..acfa92e2f0 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -57,7 +57,7 @@ describe('terminal scrollback', function() end) end) - describe('with the cursor at the last row', function() + describe('with cursor at last row', function() before_each(function() feed_data({'line1', 'line2', 'line3', 'line4', ''}) screen:expect([[ @@ -138,16 +138,17 @@ describe('terminal scrollback', function() end) - describe('and the height is decreased by 1', function() + describe('and height decreased by 1', function() local function will_hide_top_line() - screen:try_resize(screen._width, screen._height - 1) + feed([[:]]) -- Go to cmdline-mode, so cursor is at bottom. + screen:try_resize(screen._width - 2, screen._height - 1) screen:expect([[ - line2 | - line3 | - line4 | - rows: 5, cols: 30 | - {1: } | - {3:-- TERMINAL --} | + line2 | + line3 | + line4 | + rows: 5, cols: 28 | + {2: } | + :^ | ]]) end @@ -156,23 +157,23 @@ describe('terminal scrollback', function() describe('and then decreased by 2', function() before_each(function() will_hide_top_line() - screen:try_resize(screen._width, screen._height - 2) + screen:try_resize(screen._width - 2, screen._height - 2) end) it('will hide the top 3 lines', function() screen:expect([[ - rows: 5, cols: 30 | - rows: 3, cols: 30 | - {1: } | - {3:-- TERMINAL --} | + rows: 5, cols: 28 | + rows: 3, cols: 26 | + {2: } | + :^ | ]]) eq(8, curbuf('line_count')) - feed('3k') + feed([[3k]]) screen:expect([[ - ^line4 | - rows: 5, cols: 30 | - rows: 3, cols: 30 | - | + ^line4 | + rows: 5, cols: 28 | + rows: 3, cols: 26 | + | ]]) end) end) -- cgit From 9a6eb71ebaac745198fdc4cec68e51731103c3d9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 16 Aug 2017 01:04:34 +0200 Subject: test/win: give up on this one --- test/functional/terminal/scrollback_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index acfa92e2f0..af9b414311 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -139,6 +139,7 @@ describe('terminal scrollback', function() describe('and height decreased by 1', function() + if helpers.pending_win32(pending) then return end local function will_hide_top_line() feed([[:]]) -- Go to cmdline-mode, so cursor is at bottom. screen:try_resize(screen._width - 2, screen._height - 1) -- cgit