Skip to content

Commit

Permalink
Don't initialize plugins and user settings in tests
Browse files Browse the repository at this point in the history
Adding InitRuntimeFiles() and InitPlugins() to buffer_test.go in
PR #3062 (instead of just initializing runtime vars with empty values,
as it was before) seems to cause sporadic failures of MacOS build tests
on github, with crashes in various places but all beginning with lots of
plugin failures:

2024/03/26 00:16:23 Plugin does not exist: autoclose at autoclose : &{autoclose autoclose <nil> [runtime/plugins/autoclose/autoclose.lua] false true}
2024/03/26 00:16:23 Plugin does not exist: comment at comment : &{comment comment <nil> [runtime/plugins/comment/comment.lua] false true}
2024/03/26 00:16:23 Plugin does not exist: diff at diff : &{diff diff <nil> [runtime/plugins/diff/diff.lua] false true}
2024/03/26 00:16:23 Plugin does not exist: ftoptions at ftoptions : &{ftoptions ftoptions <nil> [runtime/plugins/ftoptions/ftoptions.lua] false true}
...

I suppose tests should not rely on plugins, and more importantly, should
not be affected by the contents of ~/.config/micro/ on the host.
  • Loading branch information
dmaluka committed Mar 26, 2024
1 parent 3903859 commit 4a6c1db
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion cmd/micro/micro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func startup(args []string) (tcell.SimulationScreen, error) {
}

config.InitRuntimeFiles()
config.InitPlugins()

err = config.ReadSettings()
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions internal/buffer/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ type operation struct {

func init() {
ulua.L = lua.NewState()
config.InitRuntimeFiles()
config.InitPlugins()
config.InitGlobalSettings()
config.GlobalSettings["backup"] = false
config.GlobalSettings["fastdirty"] = true
Expand Down
4 changes: 4 additions & 0 deletions internal/config/rtfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ type RuntimeFile interface {
var allFiles [][]RuntimeFile
var realFiles [][]RuntimeFile

func init() {
initRuntimeVars()
}

func initRuntimeVars() {
allFiles = make([][]RuntimeFile, NumTypes)
realFiles = make([][]RuntimeFile, NumTypes)
Expand Down
1 change: 0 additions & 1 deletion internal/config/rtfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

func init() {
InitRuntimeFiles()
InitPlugins()
}

func TestAddFile(t *testing.T) {
Expand Down

0 comments on commit 4a6c1db

Please sign in to comment.