aboutsummaryrefslogtreecommitdiff
path: root/internal/stdlib/stdlib_test.go
AgeCommit message (Collapse)Author
2024-02-21internal/stdlib: remove support for special branchesJonathan Amsterdam
Remove support for the dev.boringcrypto and dev.fuzz branches. They are no longer relevant. For golang/go#65205. Change-Id: If0e7060b148fe3ebff9139a6ce2f418b928a0bd6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/557415 kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org>
2023-08-31internal/stdlib: mark TestResolveSupportedBranches as requiring gitMichael Matloob
ResolveSupportedBranches uses the git command, and the Windows longtest builders don't have git, so skip the test when git isn't present. For golang/go#61209 Change-Id: I230793c76702ad0c3e153f9d70031a370b20ac30 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/524799 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2023-07-19internal/stdlib: remove dependency on github.com/go-git/go-git/v5Michael Matloob
Instead of using the in-memory git library implementation, just run all git operations using git commands. Add the MustHaveExecPath function from the internal/testenv library in the Go repo to our internal/testenv (with a modification to drop MustHaveExec because we don't really need it) so that we can check that git exists on the test platform before running tests that use this code because now we need a git binary to do git operations. For #61399 For #61341 Change-Id: I53441ee1638353a23935ba6a5ac70e2965b546f9 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/510415 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Michael Matloob <matloob@golang.org>
2023-07-12internal/stdlib: update to account for .0 major version suffixesRob Findley
Starting with go1.21.0, the first version of new major Go versions will include the .0 suffix (compare go1.20). Update pkgsite logic to account for this switch, and add unit+integration test support. Fixes golang/go#60373 Change-Id: Ibdac8a3413a48f925427a5aae366bed2f691cfa6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/508937 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2023-07-06internal/testenv: add and use MustHaveExternalNetwork functionMichael Matloob
This CL adds a copy of the MustHaveExternalNetwork function from the testenv package in the Go repo for use for filtering out tests that need the network access from running on builders that don't guarantee it. (External network access is only enabled on longtest builders). It also calls the function from two tests that are failing because they make external network calls. For #61209 Change-Id: I68ed1d3f8bb65697b1025bca0ba40aa0ab7423a3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/508295 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Michael Matloob <matloob@google.com> TryBot-Bypass: Michael Matloob <matloob@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2023-03-15internal/stdlib: fix versions pages for packages only in masterJamal Carvalho
Fixes golang/go#58594. Change-Id: I13c9879a12ae070d1aa07d8e152bafa07cfb7952 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/474536 TryBot-Result: kokoro <noreply+kokoro@google.com> Run-TryBot: Jamal Carvalho <jamal@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-13internal/stdlib: refactor go repo logicJonathan Amsterdam
Add a goRepo interface, implemented for remote, local and test repos. Functions of stdlib use a global instance that interface instead of if statements. Also, improve and rewrite some tests. For golang/go#50229 Change-Id: I73641813e6c7a6bb9667f44a672e37dce964b17a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/378094 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-09-14internal/{worker,stdlib}: /fetch-std-master: avoid cloning go repoJonathan Amsterdam
On each call of the /fetch-std-master endpoint, we cloned the Go repo for each supported branch to determine its current commit. Although not a big deal, that is a bit wasteful and it also would occasionally fail obscurely. Instead we use git's remote list feature to get all the repo's refs in one call. We then compare the hashes with the stored pseudo-versions to see if the branch has moved. Change-Id: I1d70e63668fcf6d35b90b9c231255faec614a04e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/349753 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-09-03internal/stdlib: support opening local repoJonathan Amsterdam
By calling stdlib.SetGoRepoPath, users can point to a local clone of the Go repo for stdlib to use. This can save download time. The intent is to use it for cmd/pkgsite. Change-Id: I20d89f283b7b0b4f333599846eee1038d09cb50e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347404 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-09-03internal/stdlib: refactor getGoRepo, add clone testsJonathan Amsterdam
Refactor getGoRepo to handle both test and cloned repos. This will enable adding a third option, getting the Go repo from a local copy. Also add a test for checking the contents of a cloned repo, to make sure the clone logic is correct. Flag-protect it because it's slow and hits an external server. Change-Id: I9de50bf12fccbd4fa35aa0566bdee3cddb25edf8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347403 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-08-23internal/stdlib: add ContentDir functionJonathan Amsterdam
Add a function that returns the content directory of the stdlib module. Remove the part of the test that checks go.mod; it was never executing, because there is no go.mod file in any of the repos being tested. For golang/go#47834 Change-Id: Idc982620f6736ec60fe9a295f0372fd272745457 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/343965 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-07-12internal: support std@dev.fuzzJulie Qiu
It is now possible to fetch std@dev.fuzz and view /std@dev.fuzz on the frontend. For golang/go#46910 Change-Id: I2fd7259840ba32ff35ca323d07412988e533ffba Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/330413 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-03-01internal: do not display README at /stdJulie Qiu
The README is no longer displayed at pkg.go.dev/std. It is also no longer stored in the database when a std module is fetched. For golang/go#44356 Change-Id: I6b1605389bc3c97694b6ec2b06e28006a38be999 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296950 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-02-22internal/stdlib: fix Zip for master versionJulie Qiu
An error is fixed when creating the zipfile for std@master, which prevented the module from being fetched. A test is also added. For golang/go#44390 Change-Id: I279146aef10311822f47f16259a2223c879140c2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294831 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-01-27internal/stdlib: return pseudo-version for masterJonathan Amsterdam
When fetching std@master, create a pseudo-version so the module is stored under the commit that is the current value of master. Fixes golang/go#43890 Change-Id: I99af482b1cc16a7bbb396c5b072f8e8d60a71b68 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/287213 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-01-25internal: resolve default branch versions for each fetchJulie Qiu
The target for @main and @master is maintained in the version_map table, while @latest and a specific semantic version is determined using the modules and units tables. As a result, these versions can be out of sync. Resolve the master/main version when a module is fetched and disableProxyFetch is off, so that the targets are up to date with the new version. Fixes golang/go#43096 Change-Id: I86dde167639c0f180ab67b0d3243316240956fc4 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/286212 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-01-19internal/stdlib: added ability to fetch master versionSai Kiran Dasika
Added the ability to fetch the master version of a module Fixes golang/go#39973 Change-Id: I66ea0dc3a2249ac4757a3d3b478c428f13c2ec89 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/279292 Reviewed-by: Jonathan Amsterdam <jba@google.com> Trust: Julie Qiu <julie@golang.org>
2020-11-20internal: rename tc to testJulie Qiu
The variable tc is renamed to test when used to refer to a test case, for consistency throughout the rest of the codebase, which uses the variable test in most cases. Change-Id: I88a87aa020928af98e8579a299f3111718dfa044 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/271809 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Trust: Julie Qiu <julie@golang.org>
2020-09-18internal/stdlib: Zip takes resolved versionJonathan Amsterdam
In the only call to this function, we already know the resolved version. For golang/go#41452 Change-Id: I96e5ebdf5acb0aeec45288b25b555e5c6cbb52ee Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/255757 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-09-18internal/fetch: refactor to get info separatelyJonathan Amsterdam
Reorganize FetchModule into two functions. First, one calls GetModuleInfo to get some prelimary, cheap information, including the size of the zip. Then one calls FetchModule with the result of GetModuleInfo. This allows us to make decisions based on the zip size before downloading the entire zip. For golang/go#41452 Change-Id: Ifbffa5882488e31a72e78670caf69c3d97a80546 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/255738 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-08-07internal: support fetching the latest version of stdlibJulie Qiu
This change adds support for resolving the latest version of the std module, using stdlib.Zip. Updates golang/go#39973 Change-Id: I0e27303bf2290f67c9dbc80fadf66b2e5c73e886 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241604 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-27internal/stdlib: fix stdlib README for new data modelJulie Qiu
The overview tab for the stdlib package is currently displaying src/README.vendor, instead of README.md, when the use-directories experiment flag is on. This is because based on the way the std module zip is constructed, both README.md and README.vendor are present at the root for version v1.4.0-beta.1 and higher. The fetch process will then choose README.vendor to include, since it comes after README.md alphabetically. The README.vendor file is no longer included in the std zip. For golang/go#39629 Change-Id: I1c9d8fcd1776f7b58be08f5f1ec1dc1b735e736d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/244608 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27internal/fetch: check for mismatched pathJonathan Amsterdam
Read the go.mod file from the proxy, and check if its path differs from the module path. If they do differ, fail with an AlternativeModule error, and record the relationship between the two paths in a table for future use. This change means that the discovery site will not serve modules that: - are case variants of the canonical path e.g. github.com/Sirupsen/logrus vs. the correct github.com/sirupsen/logrus - bypass the vanity import path e.g. github.com/gonum/gonum vs. the correct gonum.org/v1/gonum - are "soft forks" of the module's repo: forks with an unchanged go.mod path e.g. github.com/alice02/kubernetes vs. the correct k8s.io/kubernetes Change-Id: If78c94744440112f5720750885fe10f6a7dc7ab8 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/623922 Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27all: use golang.org/x/modJonathan Amsterdam
Use the semver and module packages from golang.org/x/mod. Remove them from internal/thirdparty. We also rename Encode{Version,Path} to Escape{Version,Path} because golang.org/x/module does that. Fixes b/133841935. Change-Id: I0e52c6dd7109fbd488a030c750cdc06736356868 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/619244 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/stdlib: handle go1Jonathan Amsterdam
Handle the idiosyncratic mapping of go1 to v1.0.0. The following frontend paths changed behavior: - std@go1?tab=versions and archive/tar@go1?tab=versions both work now - std@go1.0 and archive/tar@go1.0 now return 4xx Fixes b/144364761. Change-Id: I2345faeedb1e418028422feaf7d9ad0233bc08ff Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/597504 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/postgres: ignore self-imports in imported-by countsJonathan Amsterdam
Do not count package A as importing package B if they are in the same module. Change-Id: Ic0f98af8d72b8fff29e105779c6eb619214335e9 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/596525 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/frontend: fix major version for stdJonathan Amsterdam
Display the major version as "go1", not "v1". Also, fix the tooltip. Fixes b/143529585. Fixes b/143613230. Change-Id: I3379e8295a90f79c375f6e54e3593eee2391a335 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/589902 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/stdlib: export VersionForTagJulie Qiu
VersionForTag will be used in internal/frontend in the next set of CLs for the new URL design. Updates b/140191811 Change-Id: I85c11ac0d6e8c5e8c1040f2dbdc6a385a3e4ee09 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/567617 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27stdlib: support rc prereleasesJonathan Amsterdam
Also, simplify versionForTag by writing a single regexp. Fixes b/140659468. Change-Id: I139f833202da450f481075a269f5ee5727e7458a Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/550975 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27internal/etl: compute which stdlib versions to fetchJonathan Amsterdam
Look at the recent versions tagged in the Go repo to determine which Go versions to fetch. Also, remove support in stdlib for getting the latest version. It isn't needed. Fixes b/140413605. Change-Id: I27fee9153f593561ab4648328ced782e5b32d740 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/543855 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27internal/etl: use stdlib.Zip to fetch std moduleJonathan Amsterdam
Change the fetch logic for module "std" to use the stdlib package, which clones the Go repo instead of using the proxy. Also: - Change stdlib.Zip to return a zip.Reader - Provide a test mode for stdlib.Zip that makes it use the stripped-down Go repos in testdata Fixes b/138649628. Change-Id: I9b8a73c00452873225776b258ae743d88814ff77 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/542349 Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27internal/stdlib: package for handling the Go standard libraryJonathan Amsterdam
Add a new package containing all code for treating the standard library as a special module, "std". Includes a constant for the module path, the function to convert semvers to Go tags, and a new function for building a zip file from the Go repo. Note: adding the go-git package also updated some other packages in go.mod. Updates b/138649628. Change-Id: I0fc2fe43a37825e722b8e635a39f4db3d7350766 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/538930 Reviewed-by: Julie Qiu <julieqiu@google.com>