Masterminds / glide

Package Management for Golang
https://glide.sh
Other
8.16k stars 539 forks source link

testImports doesn't handle repo: attribute #514

Open ansel1 opened 7 years ago

ansel1 commented 7 years ago

Had this under testImport: section of glide.yaml:

- package: github.com/stretchr/testify
  repo: https://github.com/ansel1/testify.git
  subpackages:
  - assert
  - require

glide up would complain that version could not be found in github.com/stretchr/testify. If I move that stanza into import: section, it works.

franciscocpg commented 7 years ago

hi @ansel1. Which glide version are you using?

franciscocpg commented 7 years ago

Well, you complain about testImport: section, so you must be using 0.11.0.

mattfarina commented 7 years ago

@ansel1 are you directly importing this in your test files or is one of your test files importing it?

ansel1 commented 7 years ago

:) I don't think I understand that question. Do you mean, is it a first-order dependencies of my tests, or a transitive dependency of my tests? It's a first-order dependency. Most of by *_test.go files directly import "github.com/stretchr/testify/assert" or "github.com/stretchr/testify/require".

They don't import the parent package ("github.com/stretchr/testify"). Not sure if that matters.

mattfarina commented 7 years ago

@ansel1 you answered my question. thanks.

I'm looking to get a 0.11.1 release out soon. I'd like to get this fixed and in that release.

ansel1 commented 7 years ago

awesome, thanks

On Wed, Jul 20, 2016 at 10:49 AM Matt Farina notifications@github.com wrote:

@ansel1 https://github.com/ansel1 you answered my question. thanks.

I'm looking to get a 0.11.1 release out soon. I'd like to get this fixed and in that release.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Masterminds/glide/issues/514#issuecomment-233972896, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGlMXENUnIqkVe6ARRTtoNm2lvG3NLTks5qXjWQgaJpZM4JQXG0 .

mattfarina commented 7 years ago

@ansel1 I'm having trouble reproducing this. Using the tip of master for Glide I see....

mfarina in ~/Code/go/src/github.com/Masterminds/example/vendor/github.com/stretchr/testify on master
± git remote -v
origin  https://github.com/ansel1/testify.git (fetch)
origin  https://github.com/ansel1/testify.git (push)

I copied and pasted your snippet. The only thing I noticed is that it's testImport and not testImports.

My exact section looks like:

testImport:
- package: github.com/stretchr/testify
  repo: https://github.com/ansel1/testify.git
  subpackages:
  - assert
  - require

I updated the glide.yaml file and then ran glide up.

Can you help me reproduce this?

ansel1 commented 7 years ago

Try using the strip vcs and strip vendor options. It looks like I have one project where it works correctly, and one which exhibits the bug, and the main difference is that the latter is stripping the VCS metadata.

On Wed, Jul 20, 2016 at 4:31 PM Matt Farina notifications@github.com wrote:

@ansel1 https://github.com/ansel1 I'm having trouble reproducing this. Using the tip of master for Glide I see....

mfarina in ~/Code/go/src/github.com/Masterminds/example/vendor/github.com/stretchr/testify on master ± git remote -v origin https://github.com/ansel1/testify.git (fetch) origin https://github.com/ansel1/testify.git (push)

I copied and pasted your snippet. The only thing I noticed is that it's testImport and not testImports.

My exact section looks like:

testImport:- package: github.com/stretchr/testify repo: https://github.com/ansel1/testify.git subpackages:

  • assert
  • require

I updated the glide.yaml file and then ran glide up.

Can you help me reproduce this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Masterminds/glide/issues/514#issuecomment-234072751, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGlMdA7zgcbS1GL94pNyxrngLz3ys2kks5qXoWggaJpZM4JQXG0 .

mattfarina commented 7 years ago

@ansel1 might you have github.com/stretchr/testify imported in a non-test file? One that doesn't end in _test.go?

ansel1 commented 7 years ago

Hmm...no, there are no references to testify in the project's source files, except for those in *_test.go files. However, there are references to it in other dependencies. i.e. testify is a transitive dependency of the project's non-test sources. Maybe that's the issue.

Seems like I should only be worried about my direct dependencies in glide.yaml, and that I should be declaring them accurately. i.e. if testify is a direct test dependency, and not a direct non-test (what's the right name for these?), then I should be declaring testify in the testImport section. The fact that it is also a transitive non-test dependency...should probably not impact how I declare my direct dependencies.

bacongobbler commented 6 years ago

I'm also seeing this. Clean environment using glide v0.12.3 in a docker container with https://github.com/kubernetes/helm/commit/787d486cf06c9d79fb38588f5c047240997a17be.

λ docker run -itv /c/Users/bacongobbler/go/src/k8s.io/helm:/go/src/k8s.io/helm golang:1.9 bash
root@e724bc173c49:/go# cd src/k8s.io/helm/
root@e724bc173c49:/go/src/k8s.io/helm# glide up
bash: glide: command not found
root@e724bc173c49:/go/src/k8s.io/helm# cd ../..
root@e724bc173c49:/go/src# mkdir -p github.com/Masterminds
root@e724bc173c49:/go/src# cd github.com/Masterminds/
root@e724bc173c49:/go/src/github.com/Masterminds# git clone https://github.com/Masterminds/glide
root@e724bc173c49:/go/src/github.com/Masterminds# cd glide/
root@e724bc173c49:/go/src/github.com/Masterminds/glide# git checkout v0.12.3
root@e724bc173c49:/go/src/github.com/Masterminds/glide# make build
root@e724bc173c49:/go/src/github.com/Masterminds/glide# mv glide /go/bin/
root@e724bc173c49:~# cd /go/src/k8s.io/helm/
root@e724bc173c49:/go/src/k8s.io/helm# glide up
[ERROR] Error scanning github.com/stretchr/testify/assert: cannot find package "." in:
        /root/.glide/cache/src/https-github.com-stretchr-testify/assert
[ERROR] Failed to retrieve a list of test dependencies: Error resolving imports

I can work around this if I do a bare git clone https://github.com/stretchr/testify /root/.glide/cache/src/https-github.com-stretchr-testify then call glide up.

The repository does not have github.com/stretchr/testify imported anywhere other than in a test file.

root@e724bc173c49:/go/src/k8s.io/helm# git grep testify
glide.lock:- name: github.com/stretchr/testify
glide.yaml:- package: github.com/stretchr/testify
pkg/chartutil/files_test.go:    "github.com/stretchr/testify/assert"

Usage: https://github.com/kubernetes/helm/blob/787d486cf06c9d79fb38588f5c047240997a17be/glide.yaml#L85-L89