From 07421b44338e09dd7376a4ac30a480929c9e9d3a Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 26 Jan 2018 15:58:17 -0800 Subject: [PATCH] test vmware workstation version checking --- builder/vmware/common/driver_workstation_unix.go | 9 ++++++--- .../vmware/common/driver_workstation_unix_test.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 builder/vmware/common/driver_workstation_unix_test.go diff --git a/builder/vmware/common/driver_workstation_unix.go b/builder/vmware/common/driver_workstation_unix.go index c4217d9be..2931396a4 100644 --- a/builder/vmware/common/driver_workstation_unix.go +++ b/builder/vmware/common/driver_workstation_unix.go @@ -66,14 +66,17 @@ func workstationVerifyVersion(version string) error { if err := cmd.Run(); err != nil { return err } + return workstationTestVersion(version, stderr.String()) +} +func workstationTestVersion(wanted, versionOutput string) error { versionRe := regexp.MustCompile(`(?i)VMware Workstation (\d+)\.`) - matches := versionRe.FindStringSubmatch(stderr.String()) + matches := versionRe.FindStringSubmatch(versionOutput) if matches == nil { return fmt.Errorf( - "Could not find VMware WS version in output: %s", stderr.String()) + "Could not find VMware WS version in output: %s", wanted) } log.Printf("Detected VMware WS version: %s", matches[1]) - return compareVersions(matches[1], version, "Workstation") + return compareVersions(matches[1], wanted, "Workstation") } diff --git a/builder/vmware/common/driver_workstation_unix_test.go b/builder/vmware/common/driver_workstation_unix_test.go new file mode 100644 index 000000000..e0e3e6ecf --- /dev/null +++ b/builder/vmware/common/driver_workstation_unix_test.go @@ -0,0 +1,15 @@ +// +build !windows + +package common + +import ( + "testing" +) + +func TestWorkstationVersion_ws14(t *testing.T) { + input := `VMware Workstation Information: +VMware Workstation 14.1.1 build-7528167 Release` + if err := workstationTestVersion("10", input); err != nil { + t.Fatal(err) + } +}