From d67ce731ed32586edb913b5752a0a1fdaedc718b Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Wed, 3 Apr 2024 03:04:42 +0200 Subject: [PATCH] Don't initialize plugins in buffer test and rtfiles test Adding InitPlugins() to tests has caused noisy error logs when running the buffer_test.go test (although the test result is still PASS): 2024/03/23 15:14:30 Plugin does not exist: autoclose at autoclose : &{autoclose autoclose [runtime/plugins/autoclose/autoclose.lua] false true} 2024/03/23 15:14:30 Plugin does not exist: comment at comment : &{comment comment [runtime/plugins/comment/comment.lua] false true} 2024/03/23 15:14:30 Plugin does not exist: diff at diff : &{diff diff [runtime/plugins/diff/diff.lua] false true} 2024/03/23 15:14:30 Plugin does not exist: ftoptions at ftoptions : &{ftoptions ftoptions [runtime/plugins/ftoptions/ftoptions.lua] false true} ... These errors are caused simply by the fact that plugins are initialized but not loaded. Adding config.LoadAllPlugins() to buffer_test.go "fixes" this problem. However, at the moment it doesn't seem a good idea to load plugins in buffer_test.go, since buffer_test.go doesn't properly initialize Lua. It only does ulua.L = lua.NewState() but doesn't do the other stuff that init() in cmd/micro/initlua.go does. As a result, plugins will not be able to do anything correctly. So in order to initialize Lua correctly we need to be inside cmd/micro/, so we cannot do it in buffer_test.go or any other tests except micro_test.go. --- internal/buffer/buffer_test.go | 1 - internal/config/rtfiles_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/internal/buffer/buffer_test.go b/internal/buffer/buffer_test.go index 16714426..8bb7da40 100644 --- a/internal/buffer/buffer_test.go +++ b/internal/buffer/buffer_test.go @@ -21,7 +21,6 @@ type operation struct { func init() { ulua.L = lua.NewState() config.InitRuntimeFiles() - config.InitPlugins() config.InitGlobalSettings() config.GlobalSettings["backup"] = false config.GlobalSettings["fastdirty"] = true diff --git a/internal/config/rtfiles_test.go b/internal/config/rtfiles_test.go index 694e4686..de6525ef 100644 --- a/internal/config/rtfiles_test.go +++ b/internal/config/rtfiles_test.go @@ -8,7 +8,6 @@ import ( func init() { InitRuntimeFiles() - InitPlugins() } func TestAddFile(t *testing.T) {