mirror of
https://github.com/golang/go
synced 2024-11-22 05:44:41 -07:00
Add test.
This commit is contained in:
parent
f43af96ae3
commit
e0537d1088
@ -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")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
5
src/cmd/go/testdata/script/clean_cache_n.txt
vendored
5
src/cmd/go/testdata/script/clean_cache_n.txt
vendored
@ -18,6 +18,11 @@ go clean -cache
|
|||||||
! go clean -cache .
|
! go clean -cache .
|
||||||
stderr 'go: clean -cache cannot be used with package arguments'
|
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 --
|
-- main.go --
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user