diff --git a/test/integration/cluster_env_test.go b/test/integration/cluster_env_test.go index 34b9ad3659..64d5a6919c 100644 --- a/test/integration/cluster_env_test.go +++ b/test/integration/cluster_env_test.go @@ -36,7 +36,7 @@ func TestClusterEnv(t *testing.T) { dockerEnvVars := minikubeRunner.RunCommand("docker-env", true) if err := minikubeRunner.SetEnvFromEnvCmdOutput(dockerEnvVars); err != nil { - t.Fatalf("Error: No environment variables were found in docker-env command output: ", dockerEnvVars) + t.Fatalf("Error parsing output: %s", err) } path, err := exec.LookPath("docker") diff --git a/test/integration/util/util.go b/test/integration/util/util.go index a19b322b34..586094aa59 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -26,6 +26,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "testing" "time" @@ -65,17 +66,16 @@ func (m *MinikubeRunner) EnsureRunning() { } func (m *MinikubeRunner) SetEnvFromEnvCmdOutput(dockerEnvVars string) error { - lines := strings.Split(dockerEnvVars, "\n") - var envKey, envVal string + re := regexp.MustCompile("export (.+?)=(.+?)\n") + matches := re.FindAllStringSubmatch(dockerEnvVars, -1) seenEnvVar := false - for _, line := range lines { - if _, err := fmt.Sscanf(line, "export %s=%s", envKey, envVal); err != nil { - seenEnvVar = true - os.Setenv(envKey, envVal) - } + for _, m := range matches { + seenEnvVar = true + key, val := m[1], m[2] + os.Setenv(key, val) } - if seenEnvVar == false { - return fmt.Errorf("Error: No environment variables were found in docker-env command output: ", dockerEnvVars) + if !seenEnvVar { + return fmt.Errorf("Error: No environment variables were found in docker-env command output: %s", dockerEnvVars) } return nil }