Skip to content

Commit

Permalink
Sanitize vips version string (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
AttilaTheFun authored Apr 24, 2023
1 parent cb4ae6a commit d54e310
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vips/image_golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,27 +1035,28 @@ func goldenCreateTest(
}

func getEnvironment() string {
sanitizedVersion := strings.ReplaceAll(Version, ":", "-")
switch runtime.GOOS {
case "windows":
// Missing Windows version detection. Windows is not a supported CI target right now
return "windows_" + runtime.GOARCH + "_libvips-" + Version
return "windows_" + runtime.GOARCH + "_libvips-" + sanitizedVersion
case "darwin":
out, err := exec.Command("sw_vers", "-productVersion").Output()
if err != nil {
return "macos-unknown_" + runtime.GOARCH + "_libvips-" + Version
return "macos-unknown_" + runtime.GOARCH + "_libvips-" + sanitizedVersion
}
majorVersion := strings.Split(strings.TrimSpace(string(out)), ".")[0]
return "macos-" + majorVersion + "_" + runtime.GOARCH + "_libvips-" + Version
return "macos-" + majorVersion + "_" + runtime.GOARCH + "_libvips-" + sanitizedVersion
case "linux":
out, err := exec.Command("lsb_release", "-cs").Output()
if err != nil {
return "linux-unknown_" + runtime.GOARCH
}
strout := strings.TrimSuffix(string(out), "\n")
return "linux-" + strout + "_" + runtime.GOARCH + "_libvips-" + Version
return "linux-" + strout + "_" + runtime.GOARCH + "_libvips-" + sanitizedVersion
}
// default to unknown assets otherwise
return "unknown_" + runtime.GOARCH + "_libvips-" + Version
return "unknown_" + runtime.GOARCH + "_libvips-" + sanitizedVersion
}

func assertGoldenMatch(t *testing.T, file string, buf []byte, format ImageType) {
Expand Down

0 comments on commit d54e310

Please sign in to comment.