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

Open
dominikh opened this Issue Jul 12, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@dominikh
Copy link
Member

dominikh commented Jul 12, 2018

What did you do?

https://play.golang.org/p/0WYlebH-P3l

What did you expect to see?

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

strconv.test
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.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)

@alandonovan

This comment has been minimized.

Copy link
Contributor

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.

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Jul 12, 2018

Change https://golang.org/cl/123635 mentions this issue: go/packages: compute Package.IsTest correctly

@suzmue

This comment has been minimized.

Copy link
Contributor

suzmue commented Aug 2, 2018

Just to provide an update to this thread, IsTest is no longer a field in Package (removed by https://golang.org/cl/124388).

Here is a version of that program using the up to date go/packages API: https://play.golang.org/p/BKqQMw2whY3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment