Skip to content

Commit c493e14

Browse files
authored
Merge pull request zyedidia#3220 from dmaluka/tests-rtfiles-fix
Don't initialize plugins and user settings in tests
2 parents 828871a + 69dc54b commit c493e14

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

cmd/micro/micro.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func main() {
254254
screen.TermMessage(err)
255255
}
256256

257-
config.InitRuntimeFiles()
257+
config.InitRuntimeFiles(true)
258258
config.InitPlugins()
259259

260260
err = config.ReadSettings()

cmd/micro/micro_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func startup(args []string) (tcell.SimulationScreen, error) {
3535
return nil, err
3636
}
3737

38-
config.InitRuntimeFiles()
38+
config.InitRuntimeFiles(true)
3939
config.InitPlugins()
4040

4141
err = config.ReadSettings()

internal/action/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func reloadRuntime(reloadPlugins bool) {
348348
}
349349
}
350350

351-
config.InitRuntimeFiles()
351+
config.InitRuntimeFiles(true)
352352

353353
if reloadPlugins {
354354
config.InitPlugins()

internal/buffer/buffer_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ type operation struct {
2020

2121
func init() {
2222
ulua.L = lua.NewState()
23-
config.InitRuntimeFiles()
24-
config.InitPlugins()
23+
// TODO: uncomment InitRuntimeFiles once we fix races between syntax
24+
// highlighting and buffer editing.
25+
// config.InitRuntimeFiles(false)
2526
config.InitGlobalSettings()
2627
config.GlobalSettings["backup"] = false
2728
config.GlobalSettings["fastdirty"] = true

internal/buffer/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
2020
} else if option == "statusline" {
2121
screen.Redraw()
2222
} else if option == "filetype" {
23-
config.InitRuntimeFiles()
23+
config.InitRuntimeFiles(true)
2424
err := config.ReadSettings()
2525
if err != nil {
2626
screen.TermMessage(err)

internal/config/rtfiles.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ type RuntimeFile interface {
3939
var allFiles [][]RuntimeFile
4040
var realFiles [][]RuntimeFile
4141

42+
func init() {
43+
initRuntimeVars()
44+
}
45+
4246
func initRuntimeVars() {
4347
allFiles = make([][]RuntimeFile, NumTypes)
4448
realFiles = make([][]RuntimeFile, NumTypes)
@@ -166,10 +170,14 @@ func ListRealRuntimeFiles(fileType RTFiletype) []RuntimeFile {
166170
return realFiles[fileType]
167171
}
168172

169-
// InitRuntimeFiles initializes all assets file and the config directory
170-
func InitRuntimeFiles() {
173+
// InitRuntimeFiles initializes all assets files and the config directory.
174+
// If `user` is false, InitRuntimeFiles ignores the config directory and
175+
// initializes asset files only.
176+
func InitRuntimeFiles(user bool) {
171177
add := func(fileType RTFiletype, dir, pattern string) {
172-
AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern)
178+
if user {
179+
AddRuntimeFilesFromDirectory(fileType, filepath.Join(ConfigDir, dir), pattern)
180+
}
173181
AddRuntimeFilesFromAssets(fileType, path.Join("runtime", dir), pattern)
174182
}
175183

internal/config/rtfiles_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import (
77
)
88

99
func init() {
10-
InitRuntimeFiles()
11-
InitPlugins()
10+
InitRuntimeFiles(false)
1211
}
1312

1413
func TestAddFile(t *testing.T) {

0 commit comments

Comments
 (0)