1
0
mirror of https://github.com/golang/go synced 2024-11-25 00:07:56 -07:00

Add test.

This commit is contained in:
Max Neverov 2024-11-18 18:56:43 +01:00
parent f43af96ae3
commit e0537d1088
2 changed files with 5 additions and 24 deletions

View File

@ -1,24 +0,0 @@
package clean
import (
"os/exec"
"strings"
"testing"
)
func TestCleanCache(t *testing.T) {
cmd := exec.Command("go", "clean", "-cache")
// See issue 69997. GOCACHE must be an absolute path.
cmd.Env = append(cmd.Environ(), "GOCACHE='.cache'")
_, err := cmd.Output()
if err != nil {
ee, ok := err.(*exec.ExitError)
if !ok || ee.ExitCode() != 1 || !strings.Contains(string(ee.Stderr), "GOCACHE is not an absolute path") {
t.Errorf("\"go clean -cache\" failed. expected status 1 != %d; error: %s", ee.ExitCode(), ee.Stderr)
}
} else {
t.Errorf("expected go clean -cache to fail")
}
}

View File

@ -18,6 +18,11 @@ go clean -cache
! go clean -cache .
stderr 'go: clean -cache cannot be used with package arguments'
# GOCACHE must be an absolute path.
env GOCACHE=.
! go clean -cache
stderr 'go: GOCACHE is not an absolute path'
-- main.go --
package main