From bd5007f1b97c1387d2251f374f8f2ae79a4ffd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Henrique=20Guard=C3=A3o=20Gandarez?= Date: Mon, 3 May 2021 16:52:43 -0300 Subject: [PATCH] Add test for multine submodules --- cmd/legacy/heartbeat/params.go | 4 ++++ cmd/legacy/heartbeat/params_test.go | 7 +++---- pkg/project/subversion_test.go | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/legacy/heartbeat/params.go b/cmd/legacy/heartbeat/params.go index 2423919c..3246d4c8 100644 --- a/cmd/legacy/heartbeat/params.go +++ b/cmd/legacy/heartbeat/params.go @@ -678,6 +678,10 @@ func parseBoolOrRegexList(s string) ([]regex.Regex, error) { default: splitted := strings.Split(s, "\n") for _, s := range splitted { + if s == "" { + continue + } + compiled, err := regex.Compile(s) if err != nil { return nil, fmt.Errorf("failed to compile regex %q: %s", s, err) diff --git a/cmd/legacy/heartbeat/params_test.go b/cmd/legacy/heartbeat/params_test.go index 9b523ee5..28db4623 100644 --- a/cmd/legacy/heartbeat/params_test.go +++ b/cmd/legacy/heartbeat/params_test.go @@ -15,6 +15,7 @@ import ( "github.com/wakatime/wakatime-cli/pkg/heartbeat" "github.com/wakatime/wakatime-cli/pkg/project" "github.com/wakatime/wakatime-cli/pkg/regex" + "gopkg.in/ini.v1" "github.com/spf13/pflag" "github.com/spf13/viper" @@ -1724,9 +1725,6 @@ func TestLoadParams_DisableSubmodule_False(t *testing.T) { } func TestLoadParams_DisableSubmodule_List(t *testing.T) { - // https://github.com/go-ini/ini/issues/270 - t.Skip("Skipping because ini parser does not support parsing multiple lines yet") - tests := map[string]struct { ViperValue string Expected []regex.Regex @@ -1748,7 +1746,8 @@ func TestLoadParams_DisableSubmodule_List(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { - v := viper.New() + multilineOption := viper.IniLoadOptions(ini.LoadOptions{AllowPythonMultilineValues: true}) + v := viper.NewWithOptions(multilineOption) v.Set("key", "00000000-0000-4000-8000-000000000000") v.Set("entity", "/path/to/file") v.Set("git.submodules_disabled", test.ViperValue) diff --git a/pkg/project/subversion_test.go b/pkg/project/subversion_test.go index 950f6dcf..694bb81c 100644 --- a/pkg/project/subversion_test.go +++ b/pkg/project/subversion_test.go @@ -156,6 +156,6 @@ func findSvnBinary() (string, bool) { func skipIfBinaryNotFound(t *testing.T) { _, found := findSvnBinary() if !found { - t.Skip("Skipping because the lack of svn binary in this machine.") + t.Skip("Skipping because svn binary is not installed in this machine.") } }