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: go test ./... fails on go 1.6 because dependencies are tested #14417
Comments
I found a suggested workaround in some repository stating |
My proposal for this is to add the flag
Here is my CL for that: https://golang.org/cl/19972 |
Does -excludepkg work when there are non- top-level vendored packages?
E.g. pkgA/vendor/pkgB.
|
CL https://golang.org/cl/19972 mentions this issue. |
@minux yes, the packages are specified as import paths, so to exclude non- top-level vendored packages one could use |
I find this syntax confusing and unfriendly. I would really prefer if On Sat, Feb 27, 2016 at 8:05 PM, Dmitriy Dudkin notifications@github.com
|
I agree with @davecheney . Why not make a |
@davecheney @arekkas yeah, yesterday it looked better for me. |
https://golang.org/cl/19972
|
This has been discussed at length on #11659,
and I don't feel comfortable to exclude vendor
packages from testing.
I proposed that we introduce negative package
patterns to cmd/go, but that was rejected.
|
Well the issue is that things don't work any more as they used to / are expected to work. This is bad. Go is about reducing complexity and unifying the way we write code. This is why the standard lib is so awesome, powerfull and well designed. Although this has been discussed in length, it is still something that is missing a cross platform, simple solution and i guarantee that it will be something where developers run into issues and that this sort of reports will come up time and time again. I urge the maintainers to reconsider their point of view and find a viable, easy solution to cover the most basic thing in the toolchain: vendoring + testing. ----- Reply message ----- This has been discussed at length on #11659, I proposed that we introduce negative package Reply to this email directly or view it on GitHub: |
I like negative patterns/-excludepkg key better because it is more generally useful solution. But we can still go with skipping vendor tests by default as long as we will inform users about that. I think that printing something like |
If you don't want to test your vendor code, don't vendor it. (edit: it == the vendor tests) If you only want to test your vendor code sometimes, vendor it with $ go test -tags=vendortest ./... |
But I do need to vendor the code in order to have reliable builds. That's the whole point of vendoring, isn't it? |
@arekkas, no, "it" == "your vendor code's test". |
I'm really sorry, maybe I've got the terminology wrong, but I do not understand what you are saying :) The point I'm trying to make is that vendored imports often are not managed by oneself (e.g. gorilla/mux, sqlx, httprouter, ...). Test break sometimes due to the maintainer's fault or due to configuration issues (e.g. missing environment variables). I want to have an option to make testing vendored imports optional, so If I understood correctly, I could add build flags to all I want my code to be test- and buildable in 2 years as well, this is why I am vendoring all imports. Please don't take this as unwillingness or insult, I am trying to understand how to resolve the issue I described. |
If you put them in your vendor directory, it seems you have control over whether they have I'm proposing that one of the vendoring tools (or a shell script) modify the |
Ah I see! Sounds good to me :) |
@arekkas I agree with your concerns regarding CI test etc, @bradfitz and you have the same result in that tests on your build can include or exclude vendor code using a flag (see again https://go-review.googlesource.com/#/c/19972/) . Having said that, there will probably be some discussion around flagging any build that does not pass all tests including the vendored code. I think its good practice to write the *_test.go accordingly. It looks like 19972 is still open. |
In my project I'm using git submodules to manage the contents of my vendor subdirectory. I know you guys don't necessarily care about / explicitly consider git submodules when you design stuff, but I've found it's a convenient way to manage my vendored packages, and smoothly update them to new levels if I need to. Modifying all the vendored packages' tests with the build flag doesn't seem to fit smoothly with git submodules. Say I want to update the level of one of my dependencies... I would have to manage my own build flag patch over each repository, unapply my patch, merge in the new changes, re-apply my patch on top, and then commit this state of the vendored submodule. This isn't really practical for me and I probably won't use this workaround. I already have the |
I'm just some random irrelevant dude but personally I think recommending not vendoring tests isn't super fair. I've found personally that using git submodules is the nicest way to include the deps as well, but then you're stuck with their tests as well. Even if I wasn't using git submodules I don't really want to write scripts to remove the tests etc. I know everyone is against renaming ./vendor. I would rather see ./vendor and ./_vendor supported than have to deal with the tainted user experience. Go already has this ad-hoc notion of ./vendor now, so I don't see why the tooling shouldn't be aware of it as well. Go added |
I get it now, @bradfitz . Took me a few days but I finally broke the box of thought I was in. ;) I always thought of the vendor directory as something immutable, similar to Thanks for your time and explanation. Maybe this should be documented somewhere, so people like me don't get all confused. :) Closing because you're right. And cudos for not giving in, despite the lengthy discussions! This is why go rocks. |
@arekkas this isn't possible if you use submodules (which is much nicer than checking all the source in), and I would argue that since Go has a built-in notion of ./vendor that it is first-class in a sense, just like node_modules. |
@tj, whether git submodules are nicer than checking all the source is very much subjective. There are pros & cons either way, and people will weigh those differently. But if you prefer submodules yourself, you have to weigh that against the inability to alter what you check in with |
FWIW: godep hasn't saved the dependency's test files since september of last year (~v9), specifically because of this. I also fixed a bug recently where godep was vendoring more than it should have (because of old assumptions in the code). Please see the linked issue above. |
I'm using the vendor directory to avoid problems similar to leftpad, and I assume that this was its intention to begin with. The problem I'm seeing here is that if my assumption is correct, the vendor directory should be populated by modules that are from external sources and considered to have already been tested and suitable for my use. So to include them in the './...' pattern simply prolongs the feedback loop for unit tests, which is undesirable, and in the case of 'vendor' probably completely unnecessary. And I don't think having to augment the installed vendor packages is a clean solution. But maybe I don't understand Go very well. |
The idea is, that if you vendor things, you should also know what they do and if they work. If you want to skip that test, you have to do so explicitly. |
Just remember, windows users (in general) do not have access to tools like On Wed, 7 Sep 2016, 16:58 Aeneas notifications@github.com wrote:
|
💯 - I have to use git bash to test go on windows or delete vendor contents. A flag like |
One thing to note here is, that tests fail if vendored dependencies ship or use |
What version of Go are you using (go version)?
1.6
What operating system and processor architecture are you using?
Windows 10 64 bit
What did you do?
I ran
go test ./...
in a project which includes theGodeps
andvendor
directories.What did you expect to see?
I expected for my tests to pass.
What did you see instead?
The tests did not pass, because the dependencies were also tested but failed due to some error in the dependencies:
The text was updated successfully, but these errors were encountered: