mirror of
https://github.com/golang/go
synced 2024-11-12 08:20:22 -07:00
cmd/go: fix test.bash
Fixes #7260. Fix three broken tests in test.bash The test for issue 4568 was confused by go $ACTION . producing a package root of "", avoiding this mode fixes the test but weakens the test. The test for issue 4773 was broken on linux because math/Rand would fail to resolve as a package causing the test for duplicates to be skipped. Finally, the last breakage was a small change in the error message. Also, add test for foldDup. LGTM=iant R=iant, rsc CC=golang-codereviews https://golang.org/cl/61070044
This commit is contained in:
parent
730f51ab58
commit
414b45d91a
27
src/cmd/go/pkg_test.go
Normal file
27
src/cmd/go/pkg_test.go
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
var foldDupTests = []struct {
|
||||
list []string
|
||||
f1, f2 string
|
||||
}{
|
||||
{stringList("math/rand", "math/big"), "", ""},
|
||||
{stringList("math", "strings"), "", ""},
|
||||
{stringList("strings"), "", ""},
|
||||
{stringList("strings", "strings"), "strings", "strings"},
|
||||
{stringList("Rand", "rand", "math", "math/rand", "math/Rand"), "Rand", "rand"},
|
||||
}
|
||||
|
||||
func TestFoldDup(t *testing.T) {
|
||||
for _, tt := range foldDupTests {
|
||||
f1, f2 := foldDup(tt.list)
|
||||
if f1 != tt.f1 || f2 != tt.f2 {
|
||||
t.Errorf("foldDup(%q) = %q, %q, want %q, %q", tt.list, f1, f2, tt.f1, tt.f2)
|
||||
}
|
||||
}
|
||||
}
|
@ -427,10 +427,10 @@ d=$(TMPDIR=$tmp mktemp -d -t testgoXXX)
|
||||
mkdir -p $d/src
|
||||
(
|
||||
ln -s $d $d/src/dir1
|
||||
cd $d/src/dir1
|
||||
echo package p >p.go
|
||||
cd $d/src
|
||||
echo package p >dir1/p.go
|
||||
export GOPATH=$d
|
||||
if [ "$($old/testgo list -f '{{.Root}}' .)" != "$d" ]; then
|
||||
if [ "$($old/testgo list -f '{{.Root}}' dir1)" != "$d" ]; then
|
||||
echo Confused by symlinks.
|
||||
echo "Package in current directory $(pwd) should have Root $d"
|
||||
env|grep WD
|
||||
@ -479,14 +479,20 @@ rm -rf $d
|
||||
TEST case collisions '(issue 4773)'
|
||||
d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
|
||||
export GOPATH=$d
|
||||
mkdir -p $d/src/example/a $d/src/example/b
|
||||
mkdir -p $d/src/example/{a/pkg,a/Pkg,b}
|
||||
cat >$d/src/example/a/a.go <<EOF
|
||||
package p
|
||||
import (
|
||||
_ "math/rand"
|
||||
_ "math/Rand"
|
||||
_ "example/a/pkg"
|
||||
_ "example/a/Pkg"
|
||||
)
|
||||
EOF
|
||||
cat >$d/src/example/a/pkg/pkg.go <<EOF
|
||||
package pkg
|
||||
EOF
|
||||
cat >$d/src/example/a/Pkg/pkg.go <<EOF
|
||||
package pkg
|
||||
EOF
|
||||
if ./testgo list example/a 2>$d/out; then
|
||||
echo go list example/a should have failed, did not.
|
||||
ok=false
|
||||
@ -547,7 +553,7 @@ fi
|
||||
|
||||
# The error for go install should mention the conflicting directory.
|
||||
err=$(! ./testgo install ./testdata/shadow/root2/src/foo 2>&1)
|
||||
if [ "$err" != "go install: no install location for directory $(pwd)/testdata/shadow/root2/src/foo hidden by $(pwd)/testdata/shadow/root1/src/foo" ]; then
|
||||
if [ "$err" != "go install: no install location for $(pwd)/testdata/shadow/root2/src/foo: hidden by $(pwd)/testdata/shadow/root1/src/foo" ]; then
|
||||
echo wrong shadowed install error: "$err"
|
||||
ok=false
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user