aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/screen.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-11-27 10:33:54 +0100
committerbfredl <bjorn.linse@gmail.com>2022-11-27 11:51:10 +0100
commit942f26279d373fcdebcb41363e526a2871b09a71 (patch)
tree97660b67740882f34d3568531475b9b5a2098182 /test/functional/ui/screen.lua
parent3098064f332ffbc59c342545402e2d2da798a458 (diff)
downloadrneovim-942f26279d373fcdebcb41363e526a2871b09a71.tar.gz
rneovim-942f26279d373fcdebcb41363e526a2871b09a71.tar.bz2
rneovim-942f26279d373fcdebcb41363e526a2871b09a71.zip
fix(tests): only get the color map once, even for multiple test files
Problem: test/functional/ui/screen.lua would be reloaded for each *_spec.lua file, which causes an extra nvim session to be started to get the color map each time. solution: Mark screen.lua as a preloaded file, but defer the loading of the color map to the first time Screen object is initialised.
Diffstat (limited to 'test/functional/ui/screen.lua')
-rw-r--r--test/functional/ui/screen.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index c44e147c4d..79927273a6 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -101,13 +101,10 @@ end
local default_screen_timeout = default_timeout_factor * 3500
-do
- local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog
- local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--embed'})
+function Screen._init_colors(session)
local status, rv = session:request('nvim_get_color_map')
if not status then
- print('failed to get color map')
- os.exit(1)
+ error('failed to get color map')
end
local colors = rv
local colornames = {}
@@ -116,12 +113,15 @@ do
-- this is just a helper to get any canonical name of a color
colornames[rgb] = name
end
- session:close()
Screen.colors = colors
Screen.colornames = colornames
end
function Screen.new(width, height)
+ if not Screen.colors then
+ Screen._init_colors(get_session())
+ end
+
if not width then
width = 53
end