...

Text file src/cmd/go/testdata/script/test_relative_cmdline.txt

Documentation: cmd/go/testdata/script

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

View as plain text