cmd/go: tests: rename git-min-vers->git-sha256

Follow-up cleanup on go.dev/cl/698835. Clarify the tests by replacing
git-min-vers with a more-puposeful git-sha256 verb in the cmd tests.

Updates: #73704

Change-Id: I4361356431d567a6a3bb3a50eadfaa9e3ba37d90
Reviewed-on: https://go-review.googlesource.com/c/go/+/720481
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
David Finkel 2025-11-13 20:43:11 -05:00 committed by Michael Matloob
parent aea881230d
commit c3708350a4
7 changed files with 18 additions and 10 deletions

View file

@ -44,7 +44,7 @@ func newScriptEngine() *script.Engine {
return script.OnceCondition(summary, func() (bool, error) { return f(), nil })
}
add("bzr", lazyBool("the 'bzr' executable exists and provides the standard CLI", hasWorkingBzr))
add("git-min-vers", script.PrefixCondition("<suffix> indicates a minimum git version", hasAtLeastGitVersion))
add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256))
interrupt := func(cmd *exec.Cmd) error { return cmd.Process.Signal(os.Interrupt) }
gracePeriod := 30 * time.Second // arbitrary
@ -412,10 +412,14 @@ func gitVersion() (string, error) {
return "v" + string(matches[1]), nil
}
func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
func hasAtLeastGitVersion(minVers string) (bool, error) {
gitVers, gitVersErr := gitVersion()
if gitVersErr != nil {
return false, gitVersErr
}
return semver.Compare(minVers, gitVers) <= 0, nil
}
func gitSupportsSHA256() (bool, error) {
return hasAtLeastGitVersion("v2.29")
}

View file

@ -44,7 +44,7 @@ func scriptConditions(t *testing.T) map[string]script.Cond {
add("case-sensitive", script.OnceCondition("$WORK filesystem is case-sensitive", isCaseSensitive))
add("cc", script.PrefixCondition("go env CC = <suffix> (ignoring the go/env file)", ccIs))
add("git", lazyBool("the 'git' executable exists and provides the standard CLI", hasWorkingGit))
add("git-min-vers", script.PrefixCondition("<suffix> indicates a minimum git version", hasAtLeastGitVersion))
add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256))
add("net", script.PrefixCondition("can connect to external network host <suffix>", hasNet))
add("trimpath", script.OnceCondition("test binary was built with -trimpath", isTrimpath))
@ -171,7 +171,7 @@ func gitVersion() (string, error) {
return "v" + string(matches[1]), nil
}
func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
func hasAtLeastGitVersion(minVers string) (bool, error) {
gitVers, gitVersErr := gitVersion()
if gitVersErr != nil {
return false, gitVersErr
@ -179,6 +179,10 @@ func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
return semver.Compare(minVers, gitVers) <= 0, nil
}
func gitSupportsSHA256() (bool, error) {
return hasAtLeastGitVersion("v2.29")
}
func hasWorkingBzr() bool {
bzr, err := exec.LookPath("bzr")
if err != nil {

View file

@ -399,8 +399,8 @@ The available conditions are:
GOOS/GOARCH supports -fuzz with instrumentation
[git]
the 'git' executable exists and provides the standard CLI
[git-min-vers:*]
<suffix> indicates a minimum git version
[git-sha256]
the local 'git' version is recent enough to support sha256 object/commit hashes
[go-builder]
GO_BUILDER_NAME is non-empty
[link]

View file

@ -1,6 +1,6 @@
[short] skip
[!git] skip
[!git-min-vers:v2.29] skip
[!git-sha256] skip
env GOPRIVATE=vcs-test.golang.org

View file

@ -1,6 +1,6 @@
[short] skip
[!git] skip
[!git-min-vers:v2.29] skip
[!git-sha256] skip
env GOPRIVATE=vcs-test.golang.org

View file

@ -1,6 +1,6 @@
[short] skip
[!git] skip
[!git-min-vers:v2.29] skip
[!git-sha256] skip
# This is a git sha256-mode copy of mod_download_git_bareRepository

View file

@ -1,4 +1,4 @@
[!git-min-vers:v2.29] skip
[!git-sha256] skip
handle git