fix(language): do not parse version when empty

relates to #423
This commit is contained in:
Jan De Dobbeleer 2021-02-16 13:45:51 +01:00 committed by Jan De Dobbeleer
parent 6dc9ded7a4
commit c7db86ed4c
2 changed files with 26 additions and 0 deletions

View file

@ -157,6 +157,9 @@ func (l *language) setVersion() error {
l.exitCode = exitErr.exitCode l.exitCode = exitErr.exitCode
return fmt.Errorf("err executing %s with %s", command.executable, command.args) return fmt.Errorf("err executing %s with %s", command.executable, command.args)
} }
if version == "" {
continue
}
err = command.parse(version) err = command.parse(version)
if err != nil { if err != nil {
return fmt.Errorf("err parsing info from %s with %s", command.executable, version) return fmt.Errorf("err parsing info from %s with %s", command.executable, version)

View file

@ -243,6 +243,29 @@ func TestLanguageEnabledMissingCommand(t *testing.T) {
assert.Equal(t, "", lang.string(), "unicorn is available and uni and corn files are found") assert.Equal(t, "", lang.string(), "unicorn is available and uni and corn files are found")
} }
func TestLanguageEnabledNoVersionData(t *testing.T) {
props := map[Property]interface{}{
DisplayVersion: true,
}
args := &languageArgs{
commands: []*cmd{
{
executable: "uni",
args: []string{"--version"},
regex: `(?:Python (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`,
},
},
extensions: []string{uni, corn},
enabledExtensions: []string{uni, corn},
enabledCommands: []string{"uni"},
version: "",
properties: props,
}
lang := bootStrapLanguageTest(args)
assert.True(t, lang.enabled())
assert.Equal(t, "", lang.string())
}
func TestLanguageEnabledMissingCommandCustomText(t *testing.T) { func TestLanguageEnabledMissingCommandCustomText(t *testing.T) {
expected := "missing" expected := "missing"
props := map[Property]interface{}{ props := map[Property]interface{}{