Skip to content

Commit c370835

Browse files
dfinkelmatloob
authored andcommitted
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 <[email protected]> Reviewed-by: Junyang Shao <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent aea8812 commit c370835

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

src/cmd/go/internal/vcweb/script.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func newScriptEngine() *script.Engine {
4444
return script.OnceCondition(summary, func() (bool, error) { return f(), nil })
4545
}
4646
add("bzr", lazyBool("the 'bzr' executable exists and provides the standard CLI", hasWorkingBzr))
47-
add("git-min-vers", script.PrefixCondition("<suffix> indicates a minimum git version", hasAtLeastGitVersion))
47+
add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256))
4848

4949
interrupt := func(cmd *exec.Cmd) error { return cmd.Process.Signal(os.Interrupt) }
5050
gracePeriod := 30 * time.Second // arbitrary
@@ -412,10 +412,14 @@ func gitVersion() (string, error) {
412412
return "v" + string(matches[1]), nil
413413
}
414414

415-
func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
415+
func hasAtLeastGitVersion(minVers string) (bool, error) {
416416
gitVers, gitVersErr := gitVersion()
417417
if gitVersErr != nil {
418418
return false, gitVersErr
419419
}
420420
return semver.Compare(minVers, gitVers) <= 0, nil
421421
}
422+
423+
func gitSupportsSHA256() (bool, error) {
424+
return hasAtLeastGitVersion("v2.29")
425+
}

src/cmd/go/scriptconds_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func scriptConditions(t *testing.T) map[string]script.Cond {
4444
add("case-sensitive", script.OnceCondition("$WORK filesystem is case-sensitive", isCaseSensitive))
4545
add("cc", script.PrefixCondition("go env CC = <suffix> (ignoring the go/env file)", ccIs))
4646
add("git", lazyBool("the 'git' executable exists and provides the standard CLI", hasWorkingGit))
47-
add("git-min-vers", script.PrefixCondition("<suffix> indicates a minimum git version", hasAtLeastGitVersion))
47+
add("git-sha256", script.OnceCondition("the local 'git' version is recent enough to support sha256 object/commit hashes", gitSupportsSHA256))
4848
add("net", script.PrefixCondition("can connect to external network host <suffix>", hasNet))
4949
add("trimpath", script.OnceCondition("test binary was built with -trimpath", isTrimpath))
5050

@@ -171,14 +171,18 @@ func gitVersion() (string, error) {
171171
return "v" + string(matches[1]), nil
172172
}
173173

174-
func hasAtLeastGitVersion(s *script.State, minVers string) (bool, error) {
174+
func hasAtLeastGitVersion(minVers string) (bool, error) {
175175
gitVers, gitVersErr := gitVersion()
176176
if gitVersErr != nil {
177177
return false, gitVersErr
178178
}
179179
return semver.Compare(minVers, gitVers) <= 0, nil
180180
}
181181

182+
func gitSupportsSHA256() (bool, error) {
183+
return hasAtLeastGitVersion("v2.29")
184+
}
185+
182186
func hasWorkingBzr() bool {
183187
bzr, err := exec.LookPath("bzr")
184188
if err != nil {

src/cmd/go/testdata/script/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ The available conditions are:
399399
GOOS/GOARCH supports -fuzz with instrumentation
400400
[git]
401401
the 'git' executable exists and provides the standard CLI
402-
[git-min-vers:*]
403-
<suffix> indicates a minimum git version
402+
[git-sha256]
403+
the local 'git' version is recent enough to support sha256 object/commit hashes
404404
[go-builder]
405405
GO_BUILDER_NAME is non-empty
406406
[link]

src/cmd/go/testdata/script/build_git_sha256_go_get_branch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[short] skip
22
[!git] skip
3-
[!git-min-vers:v2.29] skip
3+
[!git-sha256] skip
44

55
env GOPRIVATE=vcs-test.golang.org
66

src/cmd/go/testdata/script/build_git_sha256_moddep.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[short] skip
22
[!git] skip
3-
[!git-min-vers:v2.29] skip
3+
[!git-sha256] skip
44

55
env GOPRIVATE=vcs-test.golang.org
66

src/cmd/go/testdata/script/mod_download_git_bareRepository_sha256.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[short] skip
22
[!git] skip
3-
[!git-min-vers:v2.29] skip
3+
[!git-sha256] skip
44

55
# This is a git sha256-mode copy of mod_download_git_bareRepository
66

src/cmd/go/testdata/vcstest/git/gitrepo-sha256.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[!git-min-vers:v2.29] skip
1+
[!git-sha256] skip
22

33
handle git
44

0 commit comments

Comments
 (0)