}
}
-func TestRelativeImportsGoTest(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- tg.run("test", "./testdata/testimport")
-}
-
-func TestRelativeImportsGoTestDashI(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
-
- // don't let test -i overwrite runtime
- tg.wantNotStale("runtime", "", "must be non-stale before test -i")
-
- tg.run("test", "-i", "./testdata/testimport")
-}
-
-func TestRelativeImportsInCommandLinePackage(t *testing.T) {
- tg := testgo(t)
- defer tg.cleanup()
- // TODO: tg.parallel()
- files, err := filepath.Glob("./testdata/testimport/*.go")
- tg.must(err)
- tg.run(append([]string{"test"}, files...)...)
-}
-
func TestVersionControlErrorMessageIncludesCorrectDirectory(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
--- /dev/null
+# Relative imports in command line package
+
+# Run tests outside GOPATH.
+env GOPATH=$WORK/tmp
+
+go test ./testimport/p.go ./testimport/p_test.go ./testimport/x_test.go
+stdout '^ok'
+
+-- testimport/p.go --
+package p
+
+func F() int { return 1 }
+-- testimport/p1/p1.go --
+package p1
+
+func F() int { return 1 }
+-- testimport/p2/p2.go --
+package p2
+
+func F() int { return 1 }
+-- testimport/p_test.go --
+package p
+
+import (
+ "./p1"
+
+ "testing"
+)
+
+func TestF(t *testing.T) {
+ if F() != p1.F() {
+ t.Fatal(F())
+ }
+}
+-- testimport/x_test.go --
+package p_test
+
+import (
+ . "../testimport"
+
+ "./p2"
+
+ "testing"
+)
+
+func TestF1(t *testing.T) {
+ if F() != p2.F() {
+ t.Fatal(F())
+ }
+}
\ No newline at end of file
--- /dev/null
+# Relative imports in go test
+
+# Run tests outside GOPATH.
+env GOPATH=$WORK/tmp
+
+go test ./testimport
+stdout '^ok'
+
+-- testimport/p.go --
+package p
+
+func F() int { return 1 }
+-- testimport/p1/p1.go --
+package p1
+
+func F() int { return 1 }
+-- testimport/p_test.go --
+package p
+
+import (
+ "./p1"
+
+ "testing"
+)
+
+func TestF(t *testing.T) {
+ if F() != p1.F() {
+ t.Fatal(F())
+ }
+}
\ No newline at end of file
--- /dev/null
+# Relative imports in go test -i
+
+# Run tests outside GOPATH.
+env GOPATH=$WORK/tmp
+
+# Check that it's safe to pass -i (which installs dependencies in $GOPATH/pkg) to go test.
+! stale runtime # don't let test -i overwrite runtime
+go test -i ./testimport
+
+-- testimport/p.go --
+package p
+
+func F() int { return 1 }
+-- testimport/p1/p1.go --
+package p1
+
+func F() int { return 1 }
+-- testimport/p_test.go --
+package p
+
+import (
+ "./p1"
+
+ "testing"
+)
+
+func TestF(t *testing.T) {
+ if F() != p1.F() {
+ t.Fatal(F())
+ }
+}
\ No newline at end of file
+++ /dev/null
-package p
-
-func F() int { return 1 }
+++ /dev/null
-package p1
-
-func F() int { return 1 }
+++ /dev/null
-package p2
-
-func F() int { return 1 }
+++ /dev/null
-package p
-
-import (
- "./p1"
-
- "testing"
-)
-
-func TestF(t *testing.T) {
- if F() != p1.F() {
- t.Fatal(F())
- }
-}
+++ /dev/null
-package p_test
-
-import (
- . "../testimport"
-
- "./p2"
-
- "testing"
-)
-
-func TestF1(t *testing.T) {
- if F() != p2.F() {
- t.Fatal(F())
- }
-}