echo "go get -d -u $url succeeded with wrong remote repo"
cat $d/err
ok=false
- elif ! grep 'should be from' $d/err >/dev/null; then
+ elif ! grep 'is a custom import path for' $d/err >/dev/null; then
echo "go get -d -u $url failed for wrong reason"
cat $d/err
ok=false
rm -rf $d
}
-testmove hg rsc.io/x86/x86asm x86 rsc.io/x86/.hg/hgrc
testmove git rsc.io/pdf pdf rsc.io/pdf/.git/config
-testmove svn code.google.com/p/rsc-svn/trunk - -
+
+# TODO(rsc): Set up a test case on bitbucket for hg.
+# testmove hg rsc.io/x86/x86asm x86 rsc.io/x86/.hg/hgrc
+
+# TODO(rsc): Set up a test case on SourceForge (?) for svn.
+# testmove svn code.google.com/p/rsc-svn/trunk - -
export GOPATH=$(pwd)/testdata/importcom
TEST 'import comment - match'
fi
rm -f fmt.test
-TEST 'Issue 7573: cmd/cgo: undefined reference when linking a C-library using gccgo'
-d=$(mktemp -d -t testgoXXX)
-export GOPATH=$d
-mkdir -p $d/src/cgoref
-ldflags="-L alibpath -lalib"
-echo "
-package main
-// #cgo LDFLAGS: $ldflags
-// void f(void) {}
-import \"C\"
-
-func main() { C.f() }
-" >$d/src/cgoref/cgoref.go
-go_cmds="$(./testgo build -n -compiler gccgo cgoref 2>&1 1>/dev/null)"
-ldflags_count="$(echo "$go_cmds" | egrep -c "^gccgo.*$(echo $ldflags | sed -e 's/-/\\-/g')" || true)"
-if [ "$ldflags_count" -lt 1 ]; then
- echo "No Go-inline "#cgo LDFLAGS:" (\"$ldflags\") passed to gccgo linking stage."
- ok=false
+if which gccgo >/dev/null; then
+ TEST 'Issue 7573: cmd/cgo: undefined reference when linking a C-library using gccgo'
+ d=$(mktemp -d -t testgoXXX)
+ export GOPATH=$d
+ mkdir -p $d/src/cgoref
+ ldflags="-L alibpath -lalib"
+ echo "
+ package main
+ // #cgo LDFLAGS: $ldflags
+ // void f(void) {}
+ import \"C\"
+
+ func main() { C.f() }
+ " >$d/src/cgoref/cgoref.go
+ go_cmds="$(./testgo build -n -compiler gccgo cgoref 2>&1 1>/dev/null)"
+ ldflags_count="$(echo "$go_cmds" | egrep -c "^gccgo.*$(echo $ldflags | sed -e 's/-/\\-/g')" || true)"
+ if [ "$ldflags_count" -lt 1 ]; then
+ echo "No Go-inline "#cgo LDFLAGS:" (\"$ldflags\") passed to gccgo linking stage."
+ ok=false
+ fi
+ rm -rf $d
+ unset ldflags_count
+ unset go_cmds
+ unset ldflags
+ unset GOPATH
fi
-rm -rf $d
-unset ldflags_count
-unset go_cmds
-unset ldflags
-unset GOPATH
TEST list template can use context function
if ! ./testgo list -f "GOARCH: {{context.GOARCH}}"; then
echo "file with non-runnable example was not built"
ok=false
fi
+rm -f testdata/std.out
TEST 'go generate handles simple command'
if ! ./testgo generate ./testdata/generate/test1.go > testdata/std.out; then
TEST go vet with external tests
d=$(mktemp -d -t testgoXXX)
+export GOPATH=$d
+./testgo get golang.org/x/tools/cmd/vet
export GOPATH=$(pwd)/testdata
if ./testgo vet vetpkg >$d/err 2>&1; then
echo "go vet vetpkg passes incorrectly"
# clean up
if $started; then stop; fi
-rm -rf testdata/bin testdata/bin1
+rm -rf testdata/bin testdata/bin1 testdata/std.out
rm -f testgo
if $allok; then
p.Dir = ctxt.joinPath(srcDir, path)
}
// Determine canonical import path, if any.
+ // Exclude results where the import path would include /testdata/.
+ inTestdata := func(sub string) bool {
+ return strings.Contains(sub, "/testdata/") || strings.HasSuffix(sub, "/testdata") || strings.HasPrefix(sub, "testdata/") || sub == "testdata"
+ }
if ctxt.GOROOT != "" {
root := ctxt.joinPath(ctxt.GOROOT, "src")
- if sub, ok := ctxt.hasSubdir(root, p.Dir); ok {
+ if sub, ok := ctxt.hasSubdir(root, p.Dir); ok && !inTestdata(sub) {
p.Goroot = true
p.ImportPath = sub
p.Root = ctxt.GOROOT
all := ctxt.gopath()
for i, root := range all {
rootsrc := ctxt.joinPath(root, "src")
- if sub, ok := ctxt.hasSubdir(rootsrc, p.Dir); ok {
+ if sub, ok := ctxt.hasSubdir(rootsrc, p.Dir); ok && !inTestdata(sub) {
// We found a potential import path for dir,
// but check that using it wouldn't find something
// else first.