diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-15 05:26:41 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-03-15 05:26:41 +0100 |
commit | b90256e6cc2ab22c552660c70462c08ba5fd984b (patch) | |
tree | 5da897493f8c9ea14300451225153c521983e41d | |
parent | 1baf4edbd97539a7d331e350d23de35eeabf68b6 (diff) | |
download | rneovim-b90256e6cc2ab22c552660c70462c08ba5fd984b.tar.gz rneovim-b90256e6cc2ab22c552660c70462c08ba5fd984b.tar.bz2 rneovim-b90256e6cc2ab22c552660c70462c08ba5fd984b.zip |
test: simplify TUI bg-detection test
Previous approach skipped the test if the expected value matched the
default value ("dark"). New approach always checks, but uses retry() to
ignore potentially wrong 'background' before the terminal response is
handled.
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 2017c57828..9d0eb5e40e 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -859,32 +859,23 @@ describe('TUI background color', function() local function assert_bg(color, bg) it('handles '..color..' as '..bg, function() - feed_data('\027:autocmd OptionSet background :echo &background\n') - - -- Wait for the child Nvim to register the OptionSet handler. - feed_data('\027:autocmd OptionSet\n') - screen:expect({any='--- Autocommands ---'}) - - feed_data('\012') -- CTRL-L: clear the screen - local expected_grid = [[ - {1: } | - {4:~ }| - {4:~ }| - {4:~ }| - {5:[No Name] 0,0-1 All}| - %-5s | - {3:-- TERMINAL --} | - ]] - screen:expect(string.format(expected_grid, '')) - feed_data('\027]11;rgb:'..color..'\007') - -- Because bg=dark is the default, we do NOT expect OptionSet event. - if bg == 'dark' then - screen:expect{unchanged=true, - grid=string.format(expected_grid, '')} - else - screen:expect(string.format(expected_grid, bg)) - end + -- Retry until the terminal response is handled. + retry(100, nil, function() + feed_data(':echo &background\n') + screen:expect({ + timeout=40, + grid=string.format([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + %-5s | + {3:-- TERMINAL --} | + ]], bg) + }) + end) end) end |