Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: list import map incorrectly has test variant #26880

Closed
suzmue opened this issue Aug 8, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@suzmue
Copy link
Contributor

commented Aug 8, 2018

What version of Go are you using (go version)?

go version devel +e7bce08493 Wed Aug 8 16:54:21 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

What did you do?

go list -json -test -- a b

a/a.go: package a; import _ "b"
b/b.go: package b
b/b_test.go: package b
b/bx_test.go: package b_test; import _ "a"

What did you expect to see?

I expected the Imports of package a to be "b" not the test variant "b [b.test]

{
        "Dir": "/Users/suzmue/go/src/a",
        "ImportPath": "a",
        "Name": "a",
        "Target": "/Users/suzmue/go/pkg/darwin_amd64/a.a",
        "Root": "/Users/suzmue/go",
        "Stale": true,
        "StaleReason": "stale dependency: b",
        "GoFiles": [
                "a.go"
        ],
        "Imports": [
                "b"
        ],
        "Deps": [
                "b"
        ]
}
{
        "Dir": "/Users/suzmue/go/src/b",
        "ImportPath": "b [b.test]",
        "Name": "b",
        "Root": "/Users/suzmue/go",
        "ForTest": "b",
        "Stale": true,
        "StaleReason": "build ID mismatch",
        "GoFiles": [
                "b.go",
                "b_test.go"
        ],
        "TestGoFiles": [
                "b_test.go"
        ],
        "XTestGoFiles": [
                "bx_test.go"
        ],
        "XTestImports": [
                "a",
                "b"
        ]
}
...

What did you see instead?

{
        "Dir": "/Users/suzmue/go/src/a",
        "ImportPath": "a",
        "Name": "a",
        "Target": "/Users/suzmue/go/pkg/darwin_amd64/a.a",
        "Root": "/Users/suzmue/go",
        "Stale": true,
        "StaleReason": "stale dependency: b",
        "GoFiles": [
                "a.go"
        ],
        "Imports": [
                "b [b.test]"
        ],
        "ImportMap": {
                "b": "b [b.test]"
        },
        "Deps": [
                "b"
        ]
}
{
        "Dir": "/Users/suzmue/go/src/b",
        "ImportPath": "b [b.test]",
        "Name": "b",
        "Root": "/Users/suzmue/go",
        "ForTest": "b",
        "Stale": true,
        "StaleReason": "build ID mismatch",
        "GoFiles": [
                "b.go",
                "b_test.go"
        ],
        "TestGoFiles": [
                "b_test.go"
        ],
        "XTestGoFiles": [
                "bx_test.go"
        ],
        "XTestImports": [
                "a",
                "b"
        ]
}
...

cc @bcmills

@suzmue suzmue changed the title cmd/go: cmd/go: list import map incorrectly has test variant Aug 8, 2018

@suzmue

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2018

I believe this is the underlying cause of #26847

@bcmills bcmills added the NeedsFix label Aug 8, 2018

@bcmills bcmills added this to the Go1.11 milestone Aug 8, 2018

@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

CC: @rsc

@gopherbot

This comment has been minimized.

Copy link

commented Aug 9, 2018

Change https://golang.org/cl/128836 mentions this issue: cmd/go: list -test reports the correct import path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.