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
Closed

cmd/go: list does not generate imports for .test packages #26488

ianthehat opened this issue Jul 19, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ianthehat
Copy link

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 The path to resolution is known, but the work has not been done. label Jul 20, 2018
@bcmills bcmills added this to the Go1.11 milestone Jul 20, 2018
@bcmills
Copy link
Contributor

bcmills commented Jul 20, 2018

CC: @rsc @matloob

@myitcv
Copy link
Member

myitcv commented Jul 20, 2018

Related to #25949 which looks fixed?

@ianthehat
Copy link
Author

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

@golang golang locked and limited conversation to collaborators Jul 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants