cmd/gitmirror: skip some tests that require git when git isn't available
More work on getting x/build to pass.
Change-Id: Ie70919f597b72daafccc2550a106be2421c8d7ba
Reviewed-on: https://go-review.googlesource.com/c/157442
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/cmd/gitmirror/gitmirror_test.go b/cmd/gitmirror/gitmirror_test.go
index b6c3ef6..244e989 100644
--- a/cmd/gitmirror/gitmirror_test.go
+++ b/cmd/gitmirror/gitmirror_test.go
@@ -59,7 +59,14 @@
return exec.CommandContext(ctx, "echo", append([]string{cmd}, args...)...)
}
+func mustHaveGit(t *testing.T) {
+ if _, err := exec.LookPath("git"); err != nil {
+ t.Skip("skipping; git not in PATH")
+ }
+}
+
func TestRev(t *testing.T) {
+ mustHaveGit(t)
f := &fakeCmd{}
testHookArchiveCmd = f.CommandContext
defer func() { testHookArchiveCmd = nil }()
@@ -81,6 +88,7 @@
}
func TestRevNotFound(t *testing.T) {
+ mustHaveGit(t)
f := &fakeCmd{}
f2 := &fakeCmd{}
testHookArchiveCmd = f.CommandContext