Blender finder: report only the first line of stdout
This commit is contained in:
parent
8b494dc448
commit
86bccf3aa9
@ -92,6 +92,11 @@ func getBlenderVersion(ctx context.Context, commandline string) (string, error)
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
version := strings.TrimSpace(string(stdoutStderr))
|
version := string(stdoutStderr)
|
||||||
return version, nil
|
lines := strings.SplitN(version, "\n", 2)
|
||||||
|
if len(lines) > 0 {
|
||||||
|
version = lines[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.TrimSpace(version), nil
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ func TestGetBlenderVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
path, err := exec.LookPath("blender")
|
path, err := exec.LookPath("blender")
|
||||||
|
if err != nil {
|
||||||
|
path, err = fileAssociation()
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
t.Fatal("running with -withBlender requires having a `blender` command on $PATH")
|
t.Fatal("running with -withBlender requires having a `blender` command on $PATH or a file association to .blend files")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@ -29,6 +32,8 @@ func TestGetBlenderVersion(t *testing.T) {
|
|||||||
version, err := getBlenderVersion(ctx, path)
|
version, err := getBlenderVersion(ctx, path)
|
||||||
if assert.NoError(t, err) {
|
if assert.NoError(t, err) {
|
||||||
assert.Contains(t, version, "Blender")
|
assert.Contains(t, version, "Blender")
|
||||||
|
assert.NotContains(t, version, "\n", "Everything after the first newline should be skipped")
|
||||||
|
assert.NotContains(t, version, "\r", "Everything after the first line feed should be skipped")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try non-existing executable:
|
// Try non-existing executable:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user