mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
aea881230d
commit
c3708350a4
7 changed files with 18 additions and 10 deletions
|
|
@ -44,7 +44,7 @@ func newScriptEngine() *script.Engine {
|
||||||
return script.OnceCondition(summary, func() (bool, error) { return f(), nil })
|
return script.OnceCondition(summary, func() (bool, error) { return f(), nil })
|
||||||
}
|
}
|
||||||
add("bzr", lazyBool("the 'bzr' executable exists and provides the standard CLI", hasWorkingBzr))
|
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) }
|
interrupt := func(cmd *exec.Cmd) error { return cmd.Process.Signal(os.Interrupt) }
|
||||||
gracePeriod := 30 * time.Second // arbitrary
|
gracePeriod := 30 * time.Second // arbitrary
|
||||||
|
|
@ -412,10 +412,14 @@ func gitVersion() (string, error) {
|
||||||
return "v" + string(matches[1]), nil
|
return "v" + string(matches[1]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
|
func hasAtLeastGitVersion(minVers string) (bool, error) {
|
||||||
gitVers, gitVersErr := gitVersion()
|
gitVers, gitVersErr := gitVersion()
|
||||||
if gitVersErr != nil {
|
if gitVersErr != nil {
|
||||||
return false, gitVersErr
|
return false, gitVersErr
|
||||||
}
|
}
|
||||||
return semver.Compare(minVers, gitVers) <= 0, nil
|
return semver.Compare(minVers, gitVers) <= 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gitSupportsSHA256() (bool, error) {
|
||||||
|
return hasAtLeastGitVersion("v2.29")
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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("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("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", 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("net", script.PrefixCondition("can connect to external network host <suffix>", hasNet))
|
||||||
add("trimpath", script.OnceCondition("test binary was built with -trimpath", isTrimpath))
|
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
|
return "v" + string(matches[1]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
|
func hasAtLeastGitVersion(minVers string) (bool, error) {
|
||||||
gitVers, gitVersErr := gitVersion()
|
gitVers, gitVersErr := gitVersion()
|
||||||
if gitVersErr != nil {
|
if gitVersErr != nil {
|
||||||
return false, gitVersErr
|
return false, gitVersErr
|
||||||
|
|
@ -179,6 +179,10 @@ func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
|
||||||
return semver.Compare(minVers, gitVers) <= 0, nil
|
return semver.Compare(minVers, gitVers) <= 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gitSupportsSHA256() (bool, error) {
|
||||||
|
return hasAtLeastGitVersion("v2.29")
|
||||||
|
}
|
||||||
|
|
||||||
func hasWorkingBzr() bool {
|
func hasWorkingBzr() bool {
|
||||||
bzr, err := exec.LookPath("bzr")
|
bzr, err := exec.LookPath("bzr")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
4
src/cmd/go/testdata/script/README
vendored
4
src/cmd/go/testdata/script/README
vendored
|
|
@ -399,8 +399,8 @@ The available conditions are:
|
||||||
GOOS/GOARCH supports -fuzz with instrumentation
|
GOOS/GOARCH supports -fuzz with instrumentation
|
||||||
[git]
|
[git]
|
||||||
the 'git' executable exists and provides the standard CLI
|
the 'git' executable exists and provides the standard CLI
|
||||||
[git-min-vers:*]
|
[git-sha256]
|
||||||
<suffix> indicates a minimum git version
|
the local 'git' version is recent enough to support sha256 object/commit hashes
|
||||||
[go-builder]
|
[go-builder]
|
||||||
GO_BUILDER_NAME is non-empty
|
GO_BUILDER_NAME is non-empty
|
||||||
[link]
|
[link]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[short] skip
|
[short] skip
|
||||||
[!git] skip
|
[!git] skip
|
||||||
[!git-min-vers:v2.29] skip
|
[!git-sha256] skip
|
||||||
|
|
||||||
env GOPRIVATE=vcs-test.golang.org
|
env GOPRIVATE=vcs-test.golang.org
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[short] skip
|
[short] skip
|
||||||
[!git] skip
|
[!git] skip
|
||||||
[!git-min-vers:v2.29] skip
|
[!git-sha256] skip
|
||||||
|
|
||||||
env GOPRIVATE=vcs-test.golang.org
|
env GOPRIVATE=vcs-test.golang.org
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[short] skip
|
[short] skip
|
||||||
[!git] skip
|
[!git] skip
|
||||||
[!git-min-vers:v2.29] skip
|
[!git-sha256] skip
|
||||||
|
|
||||||
# This is a git sha256-mode copy of mod_download_git_bareRepository
|
# This is a git sha256-mode copy of mod_download_git_bareRepository
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[!git-min-vers:v2.29] skip
|
[!git-sha256] skip
|
||||||
|
|
||||||
handle git
|
handle git
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue