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 does not generate imports for .test packages #26488

Closed
ianthehat opened this issue Jul 19, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@ianthehat
Copy link

commented Jul 19, 2018

If you run go list with -json -test the special test main package package gets the Deps correct but does not specify any Imports at all.
You can reproduce easily as below.
I would have expected the imports:

"Imports": [
    "os"
    "testing"
    "testing/internal/testdeps"
    "fmt"
    "fmt_test"
]

What you get is:

% go list -e -json -test fmt
{
        "Dir": "-----/src/fmt",
        "ImportPath": "fmt",
        "Name": "fmt",
        "Doc": "Package fmt implements formatted I/O with functions analogous to C's printf and scanf.",
        "Target": "-----/pkg/linux_amd64/fmt.a",
        "Goroot": true,
        "Standard": true,
        "Root": "-----",
        "GoFiles": [
                "doc.go",
                "format.go",
                "print.go",
                "scan.go"
        ],
        "Imports": [
                "errors",
                "io",
                "math",
                "os",
                "reflect",
                "strconv",
                "sync",
                "unicode/utf8"
        ],
        "Deps": [
                "errors",
                "internal/cpu",
                "internal/poll",
                "internal/race",
                "internal/testlog",
                "io",
                "math",
                "os",
                "reflect",
                "runtime",
                "runtime/internal/atomic",
                "runtime/internal/sys",
                "strconv",
                "sync",
                "sync/atomic",
                "syscall",
                "time",
                "unicode",
                "unicode/utf8",
                "unsafe"
        ],
        "TestGoFiles": [
                "export_test.go"
        ],
        "XTestGoFiles": [
                "example_test.go",
                "fmt_test.go",
                "scan_test.go",
                "stringer_test.go"
        ],
        "XTestImports": [
                "bufio",
                "bytes",
                "errors",
                "fmt",
                "internal/race",
                "io",
                "math",
                "reflect",
                "regexp",
                "runtime",
                "strings",
                "testing",
                "testing/iotest",
                "time",
                "unicode",
                "unicode/utf8"
        ]
}
{
        "Dir": "-----/src/fmt",
        "ImportPath": "fmt.test",
        "Name": "main",
        "Root": "-----",
        "Stale": true,
        "StaleReason": "stale dependency: fmt",
        "GoFiles": [
                "-----/.cache/go-build/f6/f6943db26acec883411e9741f9538625e85b64a5d71b359f7eebed1ad4026b3f-d"
        ],
        "Deps": [
                "bufio",
                "bytes",
                "compress/flate [fmt.test]",
                "compress/gzip [fmt.test]",
                "context [fmt.test]",
                "encoding/binary",
                "errors",
                "flag [fmt.test]",
                "fmt [fmt.test]",
                "fmt_test [fmt.test]",
                "hash",
                "hash/crc32",
                "internal/cpu",
                "internal/poll",
                "internal/race",
                "internal/testlog",
                "io",
                "log [fmt.test]",
                "math",
                "math/bits",
                "os",
                "reflect",
                "regexp",
                "regexp/syntax",
                "runtime",
                "runtime/debug",
                "runtime/internal/atomic",
                "runtime/internal/sys",
                "runtime/pprof [fmt.test]",
                "runtime/trace [fmt.test]",
                "sort",
                "strconv",
                "strings",
                "sync",
                "sync/atomic",
                "syscall",
                "testing [fmt.test]",
                "testing/internal/testdeps [fmt.test]",
                "testing/iotest [fmt.test]",
                "text/tabwriter",
                "time",
                "unicode",
                "unicode/utf8",
                "unsafe"
        ]
}

@bcmills bcmills added the NeedsFix label Jul 20, 2018

@bcmills bcmills added this to the Go1.11 milestone Jul 20, 2018

@bcmills

This comment has been minimized.

Copy link
Member

commented Jul 20, 2018

@myitcv

This comment has been minimized.

Copy link
Member

commented Jul 20, 2018

Related to #25949 which looks fixed?

@ianthehat

This comment has been minimized.

Copy link
Author

commented Jul 20, 2018

Yup, I was running a version that was 2 days too old...
Thanks

@ianthehat ianthehat closed this Jul 20, 2018

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.