| 1 |
# Relative imports in command line package |
| 2 |
|
| 3 |
env GO111MODULE=off |
| 4 |
|
| 5 |
# Run tests outside GOPATH. |
| 6 |
env GOPATH=$WORK/tmp |
| 7 |
|
| 8 |
go test ./testimport/p.go ./testimport/p_test.go ./testimport/x_test.go |
| 9 |
stdout '^ok' |
| 10 |
|
| 11 |
-- testimport/p.go -- |
| 12 |
package p |
| 13 |
|
| 14 |
func F() int { return 1 } |
| 15 |
-- testimport/p1/p1.go -- |
| 16 |
package p1 |
| 17 |
|
| 18 |
func F() int { return 1 } |
| 19 |
-- testimport/p2/p2.go -- |
| 20 |
package p2 |
| 21 |
|
| 22 |
func F() int { return 1 } |
| 23 |
-- testimport/p_test.go -- |
| 24 |
package p |
| 25 |
|
| 26 |
import ( |
| 27 |
"./p1" |
| 28 |
|
| 29 |
"testing" |
| 30 |
) |
| 31 |
|
| 32 |
func TestF(t *testing.T) { |
| 33 |
if F() != p1.F() { |
| 34 |
t.Fatal(F()) |
| 35 |
} |
| 36 |
} |
| 37 |
-- testimport/x_test.go -- |
| 38 |
package p_test |
| 39 |
|
| 40 |
import ( |
| 41 |
. "../testimport" |
| 42 |
|
| 43 |
"./p2" |
| 44 |
|
| 45 |
"testing" |
| 46 |
) |
| 47 |
|
| 48 |
func TestF1(t *testing.T) { |
| 49 |
if F() != p2.F() { |
| 50 |
t.Fatal(F()) |
| 51 |
} |
| 52 |
} |