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

Glide fails to detect some dependencies #542

Closed
aeneasr opened this issue Aug 8, 2016 · 14 comments
Closed

Glide fails to detect some dependencies #542

aeneasr opened this issue Aug 8, 2016 · 14 comments
Labels
Milestone

Comments

@aeneasr
Copy link

aeneasr commented Aug 8, 2016

I have two packages in one directory. One is ladon and one is ladon_test. When running glide init or glide up, dependencies from the ladon_test do not show up in glide.yaml nor in glide.lock nor in the vendor directory. I am using glide version 0.11.0-dev.

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

glide list gives me:

INSTALLED packages:
        github.com/Sirupsen/logrus
        github.com/cenk/backoff
        github.com/davecgh/go-spew/spew
        github.com/go-errors/errors
        github.com/golang/mock/gomock
        github.com/golang/protobuf/proto
        github.com/hailocab/go-hostpool
        github.com/oleiade/reflections
        github.com/ory-am/common/compiler
        github.com/ory-am/common/pkg
        github.com/pmezard/go-difflib/difflib
        github.com/stretchr/testify/assert
        github.com/stretchr/testify/require
        golang.org/x/crypto/pbkdf2
        golang.org/x/net/context
        golang.org/x/sys/unix
        gopkg.in/dancannon/gorethink.v2
        gopkg.in/dancannon/gorethink.v2/encoding
        gopkg.in/dancannon/gorethink.v2/ql2
        gopkg.in/dancannon/gorethink.v2/types
        gopkg.in/fatih/pool.v2

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

When renaming ladon_test to ladon, everything works as expected.

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

Having packages like ladon_test around is quite important because it avoids import cycles when writing tests:

  • package a
  • package b imports package a
  • package a_test imports package b

additionally, foo_test isn't a package you can import which makes sense to keep all Test* functions out of autocomplete.

@mattfarina
Copy link
Member

@arekkas glide does handle tests. It seems you're using a dev version rather than a release. When is this dev version from? Can you try a release version?

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

i update glide using go get -u github.com/masterminds/glide

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

let me clarify, it is not about foobar_test.go, it's about naming a package package foobar_test instead of package foobar

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

Running

$ cd $GOPATH/src/github.com/Masterminds/glide
$ git checkout v0.11.1
$ go install .
$ which glide
/Users/aeneas/workspaces/go/bin/glide
$ cd other_go_project

$ glide install / up / init

yields the same outcome.

@aeneasr aeneasr changed the title Glide does not seem to handle *_test packages Glide does not seem to handle packages named <something>_test Aug 8, 2016
@aeneasr aeneasr changed the title Glide does not seem to handle packages named <something>_test Glide does not seem to handle "package mypackage_test" Aug 8, 2016
@aeneasr aeneasr changed the title Glide does not seem to handle "package mypackage_test" Glide does not analyze code packaged as "package mypackage_test" Aug 8, 2016
@mattfarina
Copy link
Member

@arekkas so, you have two packages with different names in the same directory? Is that the issue?

That should work as well. If that is the case we'll need to look into that.

@aeneasr
Copy link
Author

aeneasr commented Aug 8, 2016

@arekkas so, you have two packages with different names in the same directory? Is that the issue?

exactly, see OP:

I have two packages in one directory. One is ladon and one is ladon_test.

@aeneasr aeneasr changed the title Glide does not analyze code packaged as "package mypackage_test" Glide fails to analyze dependencies if multiple packages (foo, foo_test) are defined in the same directory Aug 9, 2016
@aeneasr
Copy link
Author

aeneasr commented Aug 9, 2016

It doesn't seem to be linked solely to having two packages in the same directory. For example: https://github.com/ory-am/fosite/blob/master/integration/helper_setup_test.go#L8

Directory /integration knows only package integration_test and is importing as the only package github.com/gorilla/mux and gorilla/mux is missing in glide.yaml/glide.lock. You can probably reproduce this by doing:

$ go get -d github.com/ory-am/fosite
$ cd $GOPATH/src/github.com/ory-am/fosite
$ rm glide.*
$ glide create
$ glide up
$ cat glide.yaml | grep mux
# should be empty
$ cat glide.lock | grep mux
# should be empty

@aeneasr aeneasr changed the title Glide fails to analyze dependencies if multiple packages (foo, foo_test) are defined in the same directory Glide fails to detect some dependencies Aug 9, 2016
@aeneasr
Copy link
Author

aeneasr commented Aug 17, 2016

This problem is annoying because you find the missing dependencies only on a clean GOPATH, which happens most likely on your CI system, which then again takes 5-10 minutes to run.

@sdboyer
Copy link
Member

sdboyer commented Aug 18, 2016

seems like the issue arises specifically when relying on the package <pkg>_test idiom? i have a feeling i might know where the issue is...

Ah, yep. The current resolver only reads build.Package.TestImports, but does not include build.Package.XTestImports. Imports from the secondary test package are kept in the latter property.

@aeneasr
Copy link
Author

aeneasr commented Aug 18, 2016

Thanks for tracing this, unfortunately I have no idea how to fix this, so it's probably better if somebody else takes a shot at it

@sdboyer
Copy link
Member

sdboyer commented Aug 18, 2016

yep, i got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants