diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 152 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 74 | ||||
-rw-r--r-- | test/functional/ui/output_spec.lua | 51 | ||||
-rw-r--r-- | test/helpers.lua | 5 | ||||
-rw-r--r-- | test/unit/tui_spec.lua | 43 |
5 files changed, 295 insertions, 30 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 5948ab3a64..3ef41fde1d 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -727,6 +727,38 @@ describe('TUI', function() ]]) end) + it('paste: split "start paste" code', function() + feed_data('i') + -- Send split "start paste" sequence. + feed_data('\027[2') + feed_data('00~pasted from terminal\027[201~') + screen:expect([[ + pasted from terminal{1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | + ]]) + end) + + it('paste: split "stop paste" code', function() + feed_data('i') + -- Send split "stop paste" sequence. + feed_data('\027[200~pasted from terminal\027[20') + feed_data('1~') + screen:expect([[ + pasted from terminal{1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + {3:-- INSERT --} | + {3:-- TERMINAL --} | + ]]) + end) + it('allows termguicolors to be set at runtime', function() screen:set_option('rgb', true) screen:set_default_attr_ids({ @@ -1452,15 +1484,108 @@ describe("TUI", function() end) -it('TUI bg color triggers OptionSet event on terminal-response', function() - -- Only single integration test. - -- See test/unit/tui_spec.lua for unit tests. - clear() - local screen = thelpers.screen_setup(0, '["'..nvim_prog - ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile", ' - ..'"-c", "autocmd OptionSet background echo \\"did OptionSet, yay!\\""]') +describe('TUI bg color', function() + local screen + + local function setup() + -- Only single integration test. + -- See test/unit/tui_spec.lua for unit tests. + clear() + screen = thelpers.screen_setup(0, '["'..nvim_prog + ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile", ' + ..'"-c", "autocmd OptionSet background echo \\"did OptionSet, yay!\\""]') + end + + before_each(setup) + + it('triggers OptionSet event on unsplit terminal-response', function() + screen:expect([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + | + {3:-- TERMINAL --} | + ]]) + feed_data('\027]11;rgb:ffff/ffff/ffff\007') + screen:expect{any='did OptionSet, yay!'} + + feed_data(':echo "new_bg=".&background\n') + screen:expect{any='new_bg=light'} + + setup() + screen:expect([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + | + {3:-- TERMINAL --} | + ]]) + feed_data('\027]11;rgba:ffff/ffff/ffff/8000\027\\') + screen:expect{any='did OptionSet, yay!'} + + feed_data(':echo "new_bg=".&background\n') + screen:expect{any='new_bg=light'} + end) + + it('triggers OptionSet event with split terminal-response', function() + screen:expect([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + | + {3:-- TERMINAL --} | + ]]) + -- Send a background response with the OSC command part split. + feed_data('\027]11;rgb') + feed_data(':ffff/ffff/ffff\027\\') + screen:expect{any='did OptionSet, yay!'} + + feed_data(':echo "new_bg=".&background\n') + screen:expect{any='new_bg=light'} + + setup() + screen:expect([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + | + {3:-- TERMINAL --} | + ]]) + -- Send a background response with the Pt portion split. + feed_data('\027]11;rgba:ffff/fff') + feed_data('f/ffff/8000\007') + screen:expect{any='did OptionSet, yay!'} + + feed_data(':echo "new_bg=".&background\n') + screen:expect{any='new_bg=light'} + end) + + it('not triggers OptionSet event with invalid terminal-response', function() + screen:expect([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + | + {3:-- TERMINAL --} | + ]]) + feed_data('\027]11;rgb:ffff/ffff/ffff/8000\027\\') + screen:expect_unchanged() + + feed_data(':echo "new_bg=".&background\n') + screen:expect{any='new_bg=dark'} - screen:expect([[ + setup() + screen:expect([[ {1: } | {4:~ }| {4:~ }| @@ -1468,10 +1593,11 @@ it('TUI bg color triggers OptionSet event on terminal-response', function() {5:[No Name] 0,0-1 All}| | {3:-- TERMINAL --} | - ]]) - feed_data('\027]11;rgb:ffff/ffff/ffff\007') - screen:expect{any='did OptionSet, yay!'} + ]]) + feed_data('\027]11;rgba:ffff/foo/ffff/8000\007') + screen:expect_unchanged() - feed_data(':echo "new_bg=".&background\n') - screen:expect{any='new_bg=light'} + feed_data(':echo "new_bg=".&background\n') + screen:expect{any='new_bg=dark'} + end) end) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4182090732..781fdf7203 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -27,6 +27,7 @@ describe('decorations providers', function() [9] = {reverse = true}; [10] = {italic = true, background = Screen.colors.Magenta}; [11] = {foreground = Screen.colors.Red, background = tonumber('0x005028')}; + [12] = {foreground = tonumber('0x990000')}; } end) @@ -227,4 +228,77 @@ describe('decorations providers', function() ]]} end) + + it('can break an existing link', function() + insert(mulholland) + local ns1 = setup_provider() + + exec [[ + highlight OriginalGroup guifg='#990000' + highlight link LinkGroup OriginalGroup + ]] + + meths.buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) + screen:expect{grid=[[ + // just to see if there was an accident | + // on Mulholland Drive | + try_start(); {12:- not red} | + bufref_T save_buf; | + switch_buffer(&save_buf, buf); | + posp = getmark(mark, false); | + restore_buffer(&save_buf);^ | + | + ]]} + + meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue'}) + meths.set_hl_ns(ns1) + + screen:expect{grid=[[ + // just to see if there was an accident | + // on Mulholland Drive | + try_start(); {4:- not red} | + bufref_T save_buf; | + switch_buffer(&save_buf, buf); | + posp = getmark(mark, false); | + restore_buffer(&save_buf);^ | + | + ]]} + end) + + it("with 'default': do not break an existing link", function() + insert(mulholland) + local ns1 = setup_provider() + + exec [[ + highlight OriginalGroup guifg='#990000' + highlight link LinkGroup OriginalGroup + ]] + + meths.buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) + screen:expect{grid=[[ + // just to see if there was an accident | + // on Mulholland Drive | + try_start(); {12:- not red} | + bufref_T save_buf; | + switch_buffer(&save_buf, buf); | + posp = getmark(mark, false); | + restore_buffer(&save_buf);^ | + | + ]]} + + meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true}) + meths.set_hl_ns(ns1) + feed 'k' + + screen:expect{grid=[[ + // just to see if there was an accident | + // on Mulholland Drive | + try_start(); {12:- not red} | + bufref_T save_buf; | + switch_buffer(&save_buf, buf); | + posp = getmark(mark, false^); | + restore_buffer(&save_buf); | + | + ]]} + end) end) diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index d7dde6345f..3826707743 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -232,20 +232,53 @@ describe("shell command :!", function() if has_powershell() then it('powershell supports literal strings', function() set_shell_powershell() - local screen = Screen.new(30, 4) + local screen = Screen.new(45, 4) screen:attach() feed_command([[!'Write-Output $a']]) - screen:expect{any='\nWrite%-Output %$a', timeout=10000} + screen:expect([[ + :!'Write-Output $a' | + Write-Output $a | + | + Press ENTER or type command to continue^ | + ]]) feed_command([[!$a = 1; Write-Output '$a']]) - screen:expect{any='\n%$a', timeout=10000} + screen:expect([[ + :!$a = 1; Write-Output '$a' | + $a | + | + Press ENTER or type command to continue^ | + ]]) feed_command([[!"Write-Output $a"]]) - screen:expect{any='\nWrite%-Output', timeout=10000} + screen:expect([[ + :!"Write-Output $a" | + Write-Output | + | + Press ENTER or type command to continue^ | + ]]) feed_command([[!$a = 1; Write-Output "$a"]]) - screen:expect{any='\n1', timeout=10000} - feed_command(iswin() - and [[!& 'C:\\Windows\\system32\\cmd.exe' /c 'echo $a']] - or [[!& '/bin/sh' -c 'echo ''$a''']]) - screen:expect{any='\n%$a', timeout=10000} + screen:expect([[ + :!$a = 1; Write-Output "$a" | + 1 | + | + Press ENTER or type command to continue^ | + ]]) + if iswin() then + feed_command([[!& 'cmd.exe' /c 'echo $a']]) + screen:expect([[ + :!& 'cmd.exe' /c 'echo $a' | + $a | + | + Press ENTER or type command to continue^ | + ]]) + else + feed_command([[!& '/bin/sh' -c 'echo ''$a''']]) + screen:expect([[ + :!& '/bin/sh' -c 'echo ''$a''' | + $a | + | + Press ENTER or type command to continue^ | + ]]) + end end) end end) diff --git a/test/helpers.lua b/test/helpers.lua index 84148dc1a8..8dbd82cb8c 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -777,11 +777,12 @@ end function module.isCI(name) local any = (name == nil) - assert(any or name == 'appveyor' or name == 'travis' or name == 'sourcehut') + assert(any or name == 'appveyor' or name == 'travis' or name == 'sourcehut' or name == 'github') local av = ((any or name == 'appveyor') and nil ~= os.getenv('APPVEYOR')) local tr = ((any or name == 'travis') and nil ~= os.getenv('TRAVIS')) local sh = ((any or name == 'sourcehut') and nil ~= os.getenv('SOURCEHUT')) - return tr or av or sh + local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS')) + return tr or av or sh or gh end diff --git a/test/unit/tui_spec.lua b/test/unit/tui_spec.lua index e6b5c889d7..36ce4a1493 100644 --- a/test/unit/tui_spec.lua +++ b/test/unit/tui_spec.lua @@ -14,10 +14,13 @@ itp('handle_background_color', function() local handle_background_color = cinput.ut_handle_background_color local term_input = ffi.new('TermInput', {}) local events = globals.main_loop.thread_events + local kIncomplete = cinput.kIncomplete + local kNotApplicable = cinput.kNotApplicable + local kComplete = cinput.kComplete -- Short-circuit when not waiting for response. term_input.waiting_for_bg_response = 0 - eq(false, handle_background_color(term_input)) + eq(kNotApplicable, handle_background_color(term_input)) local capacity = 100 local rbuf = ffi.gc(rbuffer.rbuffer_new(capacity), rbuffer.rbuffer_free) @@ -28,7 +31,7 @@ itp('handle_background_color', function() rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) term_input.waiting_for_bg_response = 1 - eq(true, handle_background_color(term_input)) + eq(kComplete, handle_background_color(term_input)) eq(0, term_input.waiting_for_bg_response) eq(1, multiqueue.multiqueue_size(events)) @@ -97,14 +100,42 @@ itp('handle_background_color', function() assert_bg('rgba', 'f/f/f/f', 'light') - -- Incomplete sequence: not necessarily correct behavior, but tests it. + -- Incomplete sequence: necessarily correct behavior. local term_response = '\027]11;rgba:f/f/f/f' -- missing '\007 rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) term_input.waiting_for_bg_response = 1 - eq(false, handle_background_color(term_input)) + eq(kIncomplete, handle_background_color(term_input)) + eq(1, term_input.waiting_for_bg_response) + eq(#term_response, rbuf.size) + + term_response = '\007' + rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) + eq(kComplete, handle_background_color(term_input)) + eq(0, term_input.waiting_for_bg_response) + + local event = multiqueue.multiqueue_get(events) + local bg_event = ffi.cast("Event*", event.argv[1]) + eq('light', ffi.string(bg_event.argv[0])) + eq(0, multiqueue.multiqueue_size(events)) + eq(0, rbuf.size) + + term_response = '\027]11;rg' + rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) + + term_input.waiting_for_bg_response = 1 + eq(kIncomplete, handle_background_color(term_input)) + eq(1, term_input.waiting_for_bg_response) + eq(#term_response, rbuf.size) + + term_response = 'ba:f/f/f/f\007' + rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) + eq(kComplete, handle_background_color(term_input)) eq(0, term_input.waiting_for_bg_response) + event = multiqueue.multiqueue_get(events) + bg_event = ffi.cast("Event*", event.argv[1]) + eq('light', ffi.string(bg_event.argv[0])) eq(0, multiqueue.multiqueue_size(events)) eq(0, rbuf.size) @@ -114,7 +145,7 @@ itp('handle_background_color', function() rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) term_input.waiting_for_bg_response = 3 - eq(false, handle_background_color(term_input)) + eq(kNotApplicable, handle_background_color(term_input)) eq(2, term_input.waiting_for_bg_response) eq(0, multiqueue.multiqueue_size(events)) @@ -127,7 +158,7 @@ itp('handle_background_color', function() rbuffer.rbuffer_write(rbuf, to_cstr(term_response), #term_response) term_input.waiting_for_bg_response = 1 - eq(true, handle_background_color(term_input)) + eq(kComplete, handle_background_color(term_input)) eq(0, term_input.waiting_for_bg_response) eq(1, multiqueue.multiqueue_size(events)) |