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

x/tools/go/packages: dependencies recompiled for external tests have IsTest == true #26345

dominikh opened this issue Jul 12, 2018 · 3 comments


Copy link

@dominikh dominikh commented Jul 12, 2018

What did you do?

What did you expect to see?

I expected to see the packages making up strconv's tests

strconv_test [strconv.test]

What did you see instead?

Instead I saw all packages imported by the test.

context [strconv.test]
path/filepath [strconv.test]
flag [strconv.test]
runtime/pprof [strconv.test]
sort [strconv.test]
regexp [strconv.test]
log [strconv.test]
testing [strconv.test]
io/ioutil [strconv.test]
fmt [strconv.test]
runtime/debug [strconv.test]
compress/flate [strconv.test]
encoding/binary [strconv.test]
strconv_test [strconv.test]
strconv [strconv.test]
testing/internal/testdeps [strconv.test]
regexp/syntax [strconv.test]
reflect [strconv.test]
runtime/trace [strconv.test]
compress/gzip [strconv.test]

I am aware that packages imported by external tests may be distinct and probably justify being marked so. But I think that IsTest isn't the right place for this, for two reasons:

  1. The name of the field does not match what it actually means
  2. Currently, there is no way to take a test wrapper and programmatically determine the packages defining the tests. This makes it difficult to write linters that given an import path lint the package and its tests, but not any of the dependencies.

/cc @alandonovan (who is on vacation)


This comment has been minimized.

Copy link

@alandonovan alandonovan commented Jul 12, 2018

Thanks for pointing that out. I made a hasty "simplification" to the isTest predicate that was obviously not thought through.


This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jul 12, 2018

Change mentions this issue: go/packages: compute Package.IsTest correctly


This comment has been minimized.

Copy link

@suzmue suzmue commented Aug 2, 2018

Just to provide an update to this thread, IsTest is no longer a field in Package (removed by

Here is a version of that program using the up to date go/packages API:

@gopherbot gopherbot added the Tools label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.