From 61aee95efeae3f903f164da9237d452e39805f43 Mon Sep 17 00:00:00 2001 From: yangwenmai Date: Thu, 18 Feb 2021 17:11:33 +0800 Subject: [PATCH] internal/dl: simplify featured macOS file regexp The current macOS release filenames no longer include a "-osx10.8" suffix, so the featured file regexp can made shorter and simpler. Change-Id: Ia6a1b58e20909ba9485e02b51ee4b0297f6ff20e Reviewed-on: https://go-review.googlesource.com/c/website/+/293589 Reviewed-by: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov TryBot-Result: Go Bot Trust: Cherry Zhang --- internal/dl/dl.go | 2 +- internal/dl/dl_test.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/internal/dl/dl.go b/internal/dl/dl.go index 144d97ba..2ef1c9a1 100644 --- a/internal/dl/dl.go +++ b/internal/dl/dl.go @@ -160,7 +160,7 @@ var featuredFiles = []Feature{ { Platform: "Apple macOS", Requirements: "macOS 10.12 or later, Intel 64-bit processor", - fileRE: regexp.MustCompile(`\.darwin-amd64(-osx10\.8)?\.pkg$`), + fileRE: regexp.MustCompile(`\.darwin-amd64\.pkg$`), }, { Platform: "Linux", diff --git a/internal/dl/dl_test.go b/internal/dl/dl_test.go index 1744c155..1e562b3f 100644 --- a/internal/dl/dl_test.go +++ b/internal/dl/dl_test.go @@ -189,6 +189,43 @@ func TestUnstableShown(t *testing.T) { } } +func TestFilesToFeatured(t *testing.T) { + fs := []File{ + {Filename: "go1.16.3.src.tar.gz", Version: "go1.16.3", OS: "", Arch: "", Kind: "source"}, + {Filename: "go1.16.3.darwin-amd64.tar.gz", Version: "go1.16.3", OS: "darwin", Arch: "amd64", Kind: "archive"}, + {Filename: "go1.16.3.darwin-amd64.pkg", Version: "go1.16.3", OS: "darwin", Arch: "amd64", Kind: "installer"}, + {Filename: "go1.16.3.darwin-arm64.tar.gz", Version: "go1.16.3", OS: "darwin", Arch: "arm64", Kind: "archive"}, + {Filename: "go1.16.3.darwin-arm64.pkg", Version: "go1.16.3", OS: "darwin", Arch: "arm64", Kind: "installer"}, + {Filename: "go1.16.3.freebsd-386.tar.gz", Version: "go1.16.3", OS: "freebsd", Arch: "386", Kind: "archive"}, + {Filename: "go1.16.3.freebsd-amd64.tar.gz", Version: "go1.16.3", OS: "freebsd", Arch: "amd64", Kind: "archive"}, + {Filename: "go1.16.3.linux-386.tar.gz", Version: "go1.16.3", OS: "linux", Arch: "386", Kind: "archive"}, + {Filename: "go1.16.3.linux-amd64.tar.gz", Version: "go1.16.3", OS: "linux", Arch: "amd64", Kind: "archive"}, + {Filename: "go1.16.3.linux-arm64.tar.gz", Version: "go1.16.3", OS: "linux", Arch: "arm64", Kind: "archive"}, + {Filename: "go1.16.3.linux-armv6l.tar.gz", Version: "go1.16.3", OS: "linux", Arch: "armv6l", Kind: "archive"}, + {Filename: "go1.16.3.linux-ppc64le.tar.gz", Version: "go1.16.3", OS: "linux", Arch: "ppc64le", Kind: "archive"}, + {Filename: "go1.16.3.linux-s390x.tar.gz", Version: "go1.16.3", OS: "linux", Arch: "s390x", Kind: "archive"}, + {Filename: "go1.16.3.windows-386.zip", Version: "go1.16.3", OS: "windows", Arch: "386", Kind: "archive"}, + {Filename: "go1.16.3.windows-386.msi", Version: "go1.16.3", OS: "windows", Arch: "386", Kind: "installer"}, + {Filename: "go1.16.3.windows-amd64.zip", Version: "go1.16.3", OS: "windows", Arch: "amd64", Kind: "archive"}, + {Filename: "go1.16.3.windows-amd64.msi", Version: "go1.16.3", OS: "windows", Arch: "amd64", Kind: "installer"}, + } + featured := filesToFeatured(fs) + var s []string + for _, f := range featured { + s = append(s, f.Filename) + } + got := strings.Join(s, "\n") + want := strings.Join([]string{ + "go1.16.3.windows-amd64.msi", + "go1.16.3.darwin-amd64.pkg", + "go1.16.3.linux-amd64.tar.gz", + "go1.16.3.src.tar.gz", + }, "\n") + if got != want { + t.Errorf("featured files:\n%s\nwant:\n%s", got, want) + } +} + // list returns a version list string for the given releases. func list(rs []Release) string { var s string