diff options
Diffstat (limited to 'test/functional/ui/output_spec.lua')
-rw-r--r-- | test/functional/ui/output_spec.lua | 103 |
1 files changed, 47 insertions, 56 deletions
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 5e340af89c..4f6454a0fb 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -1,19 +1,21 @@ +local t = require('test.testutil') +local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') -local helpers = require('test.functional.helpers')(after_each) -local child_session = require('test.functional.terminal.helpers') -local assert_alive = helpers.assert_alive -local mkdir, write_file, rmdir = helpers.mkdir, helpers.write_file, helpers.rmdir -local eq = helpers.eq -local feed = helpers.feed -local feed_command = helpers.feed_command -local clear = helpers.clear -local command = helpers.command -local testprg = helpers.testprg -local nvim_dir = helpers.nvim_dir -local has_powershell = helpers.has_powershell -local set_shell_powershell = helpers.set_shell_powershell -local skip = helpers.skip -local is_os = helpers.is_os +local tt = require('test.functional.terminal.testutil') + +local assert_alive = n.assert_alive +local mkdir, write_file, rmdir = t.mkdir, t.write_file, n.rmdir +local eq = t.eq +local feed = n.feed +local feed_command = n.feed_command +local clear = n.clear +local command = n.command +local testprg = n.testprg +local nvim_dir = n.nvim_dir +local has_powershell = n.has_powershell +local set_shell_powershell = n.set_shell_powershell +local skip = t.skip +local is_os = t.is_os clear() -- for has_powershell() @@ -21,7 +23,7 @@ describe('shell command :!', function() local screen before_each(function() clear() - screen = child_session.setup_child_nvim({ + screen = tt.setup_child_nvim({ '-u', 'NONE', '-i', @@ -29,7 +31,7 @@ describe('shell command :!', function() '--cmd', 'colorscheme vim', '--cmd', - helpers.nvim_set .. ' notermguicolors', + n.nvim_set .. ' notermguicolors', }) screen:expect([[ {1: } | @@ -40,14 +42,14 @@ describe('shell command :!', function() end) after_each(function() - child_session.feed_data('\3') -- Ctrl-C + tt.feed_data('\3') -- Ctrl-C end) it('displays output without LF/EOF. #4646 #4569 #3772', function() skip(is_os('win')) -- NOTE: We use a child nvim (within a :term buffer) -- to avoid triggering a UI flush. - child_session.feed_data(':!printf foo; sleep 200\n') + tt.feed_data(':!printf foo; sleep 200\n') screen:expect([[ | {4:~ }|*2 @@ -61,7 +63,7 @@ describe('shell command :!', function() it('throttles shell-command output greater than ~10KB', function() skip(is_os('openbsd'), 'FIXME #10804') skip(is_os('win')) - child_session.feed_data((':!%s REP 30001 foo\n'):format(testprg('shell-test'))) + tt.feed_data((':!%s REP 30001 foo\n'):format(testprg('shell-test'))) -- If we observe any line starting with a dot, then throttling occurred. -- Avoid false failure on slow systems. @@ -80,7 +82,7 @@ describe('shell command :!', function() {3:-- TERMINAL --} | ]], { - -- test/functional/helpers.lua defaults to background=light. + -- test/functional/testnvim.lua defaults to background=light. [1] = { reverse = true }, [3] = { bold = true }, [10] = { foreground = 2 }, @@ -107,20 +109,15 @@ describe('shell command :!', function() it('handles control codes', function() skip(is_os('win'), 'missing printf') local screen = Screen.new(50, 4) - screen:set_default_attr_ids { - [1] = { bold = true, reverse = true }, - [2] = { bold = true, foreground = Screen.colors.SeaGreen }, - [3] = { foreground = Screen.colors.Blue }, - } screen:attach() -- Print TAB chars. #2958 feed([[:!printf '1\t2\t3'<CR>]]) screen:expect { grid = [[ - {1: }| + {3: }| :!printf '1\t2\t3' | 1 2 3 | - {2:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]], } feed([[<CR>]]) @@ -130,10 +127,10 @@ describe('shell command :!', function() feed([[:!printf '\007\007\007\007text'<CR>]]) screen:expect { grid = [[ - {1: }| + {3: }| :!printf '\007\007\007\007text' | text | - {2:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]], condition = function() eq(true, screen.bell) @@ -144,10 +141,10 @@ describe('shell command :!', function() -- Print BS control code. feed([[:echo system('printf ''\010\n''')<CR>]]) screen:expect([[ - {1: }| - {3:^H} | + {3: }| + {18:^H} | | - {2:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) feed([[<CR>]]) @@ -156,7 +153,7 @@ describe('shell command :!', function() screen:expect([[ :!printf '\n' | |*2 - {2:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) feed([[<CR>]]) end) @@ -170,12 +167,6 @@ describe('shell command :!', function() write_file('bang_filter_spec/f2', 'f2') write_file('bang_filter_spec/f3', 'f3') screen = Screen.new(53, 10) - screen:set_default_attr_ids({ - [1] = { bold = true, foreground = Screen.colors.Blue1 }, - [2] = { foreground = Screen.colors.Blue1 }, - [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, - [4] = { bold = true, reverse = true }, - }) screen:attach() end) @@ -195,13 +186,13 @@ describe('shell command :!', function() screen:expect([[ | {1:~ }|*2 - {4: }| + {3: }| ]] .. result .. [[ | f1 | f2 | f3 | | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) end) @@ -212,14 +203,14 @@ describe('shell command :!', function() grid = [[ | {1:~ }| - {4: }| + {3: }| :!cat test/functional/fixtures/shell_data.txt | - {2:^@^A^B^C^D^E^F^H} | - {2:^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_} | - ö 한글 {2:<a5><c3>} | - t {2:<ff>} | + {18:^@^A^B^C^D^E^F^H} | + {18:^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_} | + ö 한글 {18:<a5><c3>} | + t {18:<ff>} | | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]], condition = function() eq(true, screen.bell) @@ -234,7 +225,7 @@ describe('shell command :!', function() -- Note: only the first example of split composed char works screen:expect([[ | - {4: }| + {3: }| :]] .. cmd .. [[ | å | ref: å̲ | @@ -242,7 +233,7 @@ describe('shell command :!', function() 2: å ̲ | 3: å ̲ | | - {3:Press ENTER or type command to continue}^ | + {6:Press ENTER or type command to continue}^ | ]]) end) end) @@ -256,28 +247,28 @@ describe('shell command :!', function() :!'Write-Output $a' | Write-Output $a | | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) feed_command([[!$a = 1; Write-Output '$a']]) screen:expect([[ :!$a = 1; Write-Output '$a' | $a | | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) feed_command([[!"Write-Output $a"]]) screen:expect([[ :!"Write-Output $a" | Write-Output | | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) feed_command([[!$a = 1; Write-Output "$a"]]) screen:expect([[ :!$a = 1; Write-Output "$a" | 1 | | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) if is_os('win') then feed_command([[!& 'cmd.exe' /c 'echo $a']]) @@ -285,7 +276,7 @@ describe('shell command :!', function() :!& 'cmd.exe' /c 'echo $a' | $a | | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) else feed_command([[!& '/bin/sh' -c 'echo ''$a''']]) @@ -293,7 +284,7 @@ describe('shell command :!', function() :!& '/bin/sh' -c 'echo ''$a''' | $a | | - Press ENTER or type command to continue^ | + {6:Press ENTER or type command to continue}^ | ]]) end end) |