From 3bcc27e16a2694b939fffe0219f46112d7d1eaa0 Mon Sep 17 00:00:00 2001 From: BK1603 Date: Tue, 30 Jun 2020 01:20:12 +0530 Subject: Added test --- test/functional/autoread/focus_spec.lua | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/functional/autoread/focus_spec.lua (limited to 'test/functional/autoread/focus_spec.lua') diff --git a/test/functional/autoread/focus_spec.lua b/test/functional/autoread/focus_spec.lua new file mode 100644 index 0000000000..c2ccaa3ccb --- /dev/null +++ b/test/functional/autoread/focus_spec.lua @@ -0,0 +1,64 @@ +local helpers = require('test.functional.helpers')(after_each) +local thelpers = require('test.functional.terminal.helpers') +local clear = helpers.clear +local retry = helpers.retry +local nvim_prog = helpers.nvim_prog +local feed_command = helpers.feed_command +local feed_data = thelpers.feed_data + +if helpers.pending_win32(pending) then return end + +describe('autoread TUI FocusGained/FocusLost', function() + local screen + + before_each(function() + clear() + screen = thelpers.screen_setup(0, '["'..nvim_prog + ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]') + feed_command('set autoread') + feed_data("\034\016") + end) + + it('external file change', function() + local path = 'xtest-foo' + local expected_addition = [[ + line 1 + line 2 + line 3 + line 4 + ]] + + helpers.write_file(path, '') + feed_command('edit '..path) + retry(2, 3 * screen.timeout, function() + feed_data('\027[O') + end) + + screen:expect{grid=[[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:xtest-foo }| + :edit xtest-foo | + {3:-- TERMINAL --} | + ]]} + + helpers.sleep(2000) + helpers.write_file(path, expected_addition) + + retry(2, 3 * screen.timeout, function() + feed_data('\027[I') + end) + + screen:expect{grid=[[ + {1:l}ine 1 | + line 2 | + line 3 | + line 4 | + {5:xtest-foo }| + "xtest-foo" 4L, 28C | + {3:-- TERMINAL --} | + ]]} + end) +end) -- cgit From 4da0530b004cdc156b67566347ecb3a6c6e3929a Mon Sep 17 00:00:00 2001 From: BK1603 Date: Thu, 2 Jul 2020 23:54:54 +0530 Subject: removed unnecessary feed calls --- test/functional/autoread/focus_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/autoread/focus_spec.lua') diff --git a/test/functional/autoread/focus_spec.lua b/test/functional/autoread/focus_spec.lua index c2ccaa3ccb..be1533b828 100644 --- a/test/functional/autoread/focus_spec.lua +++ b/test/functional/autoread/focus_spec.lua @@ -15,8 +15,6 @@ describe('autoread TUI FocusGained/FocusLost', function() clear() screen = thelpers.screen_setup(0, '["'..nvim_prog ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]') - feed_command('set autoread') - feed_data("\034\016") end) it('external file change', function() -- cgit From a2370a5df056c4c92a8d3dee27a543941c3836ea Mon Sep 17 00:00:00 2001 From: BK1603 Date: Thu, 2 Jul 2020 23:56:12 +0530 Subject: replaced sleep with a changed mtime for the test file --- test/functional/autoread/focus_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/autoread/focus_spec.lua') diff --git a/test/functional/autoread/focus_spec.lua b/test/functional/autoread/focus_spec.lua index be1533b828..0373f4a224 100644 --- a/test/functional/autoread/focus_spec.lua +++ b/test/functional/autoread/focus_spec.lua @@ -1,5 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') +local lfs = require('lfs') local clear = helpers.clear local retry = helpers.retry local nvim_prog = helpers.nvim_prog @@ -27,6 +28,7 @@ describe('autoread TUI FocusGained/FocusLost', function() ]] helpers.write_file(path, '') + lfs.touch(path, os.time() - 10) feed_command('edit '..path) retry(2, 3 * screen.timeout, function() feed_data('\027[O') @@ -42,7 +44,6 @@ describe('autoread TUI FocusGained/FocusLost', function() {3:-- TERMINAL --} | ]]} - helpers.sleep(2000) helpers.write_file(path, expected_addition) retry(2, 3 * screen.timeout, function() -- cgit From 8a819d44d299755f68295e69873fd142188d7eea Mon Sep 17 00:00:00 2001 From: BK1603 Date: Fri, 3 Jul 2020 00:06:14 +0530 Subject: removed retry --- test/functional/autoread/focus_spec.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'test/functional/autoread/focus_spec.lua') diff --git a/test/functional/autoread/focus_spec.lua b/test/functional/autoread/focus_spec.lua index 0373f4a224..1d52e9948f 100644 --- a/test/functional/autoread/focus_spec.lua +++ b/test/functional/autoread/focus_spec.lua @@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local lfs = require('lfs') local clear = helpers.clear -local retry = helpers.retry local nvim_prog = helpers.nvim_prog local feed_command = helpers.feed_command local feed_data = thelpers.feed_data @@ -30,9 +29,7 @@ describe('autoread TUI FocusGained/FocusLost', function() helpers.write_file(path, '') lfs.touch(path, os.time() - 10) feed_command('edit '..path) - retry(2, 3 * screen.timeout, function() - feed_data('\027[O') - end) + feed_data('\027[O') screen:expect{grid=[[ {1: } | @@ -46,9 +43,7 @@ describe('autoread TUI FocusGained/FocusLost', function() helpers.write_file(path, expected_addition) - retry(2, 3 * screen.timeout, function() - feed_data('\027[I') - end) + feed_data('\027[I') screen:expect{grid=[[ {1:l}ine 1 | -- cgit