-
Notifications
You must be signed in to change notification settings - Fork 256
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
support vendoring #35
Comments
indeed, sadly |
well, this one requires some changes in build process. will need to think on this to find better ways for implementation. for now you can depend on GOPATH vendored package, since it is a test dependency it should not be critical to production. |
I guess vendoring still doesn't work, failed to compile testmain package:
/tmp/go-build862242248/playlyfe.com/go-potential/features/_test/_testmain.go:12: cannot use suite (type *"github.com/DATA-DOG/godog".Suite) as type *"playlyfe.com/go-potential/vendor/github.com/DATA-DOG/godog".Suite in argument to main.FeatureContext |
hm interesting, which version of go? and did you have godog in vendor? |
do you still have godog in GOPATH? it could conflict |
if you rename the import to github.com/DATA-DOG/godog it should work fine. I'm trying to reproduce it now |
When I'm importing the suite library, I'm doing so from the vendored package, package main
import (
"github.com/DATA-DOG/godog"
)
func FeatureContext(s *godog.Suite) {
//some stuff
} But when I run the go: 1.6.2 And I have godog in vendor |
Wait I removed It just now from the GOPATH
Godog version is: v0.5.0 This is what i get now?
I think I have to run the godog tool from the directory which contains the vendor directory and not in the features directory? Since its searching there? |
The path is not valid: /home/pyros2097/Code/src/playlyfe.com/go-potential//features/vendor/github.com/DATA-DOG/godog there are two slashes |
maybe your GOPATH ends with / slash? probably need to trim it on my Build script |
could you |
Opps That was a typo I fixed it, |
|
It works when I run godog from the project folder, |
well, currently godog works exactly from the directory you are testing. you have to run it from the package being tested and having _test.go files there. it may be a little different compared to cucumber ruby. but the point is that, in go packages are isolated as a separate set of features. godog tries to follow that isolation and works at the package level. it can access everything what the tested package can with it's public or private interfaces. |
in general, godog works like go test except that for grammar it uses feature files.. hope it makes sense? :) |
Yeah .. I think it was directory structure, I had trimmed the path the go-potential/features to reduce the long line and thats where the typo came into being, go-potential/common/types/catalyst/features/quiz.feature
go-potential/common/types/catalyst/features/main.go
go-potential/common/types/catalyst/features/main_test.go If I run it like this it doesn't work,
So the way I was running it was like this to make it work after moving the main files to the topmost parent, go-potential/ $ godog common/types/catalyst/features/quiz.feature and then it could find the vendored packages, |
OK, I'll have a look someday later. but as far as I can tell, godog looks only into vendor directory from where it runs. godog itself uses godog to test itself, it could be a fine example from usage point of view. |
I can confirm that I see the same @pyros2097 with v0.5.0 and tested with Go 1.6.2 and Go 1.7Beta1. |
@l3pp4rd could you re-open this issue or should I move it to a new one? It doesn't seem to be solved for me. |
I'll explain it in more details. I think you are using godog with unintended layout. Expected godog usageGiven you have an API service package named: api
When you run godog, even without any go files Imagine it as using go test command at the package level. features directory should contain only gherkin files describing your package features. Other sub packages are compiled together as dependencies. but godog (same as go test) does not have any visibility over test files. Your usage
You create another package features (which in terms of go) is a separate package. Maybe it make sense to look for it's dependencies and look for godog in their vendor directories. In this case api package. But if you would not have any go files but only gherkin features described in features directory. It will be impossible for godog to know where to look for it's package. since it is in parent/vendor directory which is not included anywhere at this stage. In my opinion, having a separate features package does not conform to practices I would like to promote because of reasons mentioned above.
In this situation it would just be not possible to run godog inside features directory to generate snippets. What is your opinion? |
@nightlyone we can implement the behavior you expect, but godog will not be fully functional for such support. If you still think that it is reasonable then we can open a separate issue |
thanks @l3pp4rd for making this clear! May I suggest to error out when you have *.go files in the same directory as *.feature files? I thinks this leads to confusion for people not from ruby. That might also be easier than making the other style work. |
I'll probably update a general example instead. because you may have In go we have a package level isolation, which we should respect in my opinion. even |
I'm sorry @l3pp4rd, but even with pure features directories it still doesn't work. So I Built an isolated test-case using vendoring at /~https://github.com/nightlyone/godog-issue for you to play with. I don't know what I'm doing different than you. |
I made two versions in separate branches: see /~https://github.com/l3pp4rd/godog-issue And with subpackage |
ok @l3pp4rd there seem to be something funny about finding the vendored copy. With this minimal changes the testcase works beautifully without any changes: diff --git a/builder.go b/builder.go
index a43fa9a..7802068 100644
--- a/builder.go
+++ b/builder.go
@@ -58,6 +58,11 @@ func Build() (string, error) {
return "", err
}
+ absup, err := filepath.Abs("..")
+ if err != nil {
+ return "", err
+ }
+
bin := filepath.Join(abs, "godog.test")
// suffix with .exe for windows
if goos == "windows" {
@@ -130,7 +135,7 @@ func Build() (string, error) {
// but we need it for our testmain package.
// So we look it up in available source paths
// including vendor directory, supported since 1.5.
- try := []string{filepath.Join(abs, "vendor", godogImportPath)}
+ try := []string{filepath.Join(abs, "vendor", godogImportPath), filepath.Join(absup, "vendor", godogImportPath)}
for _, d := range build.Default.SrcDirs() {
try = append(try, filepath.Join(d, godogImportPath))
} I guess a full implementation needs to implement directory traversal upward until |
OK I see that this is an issue to you, I'll update the library even if it is not the way I would like godog to be used.. but anyway hope that will solve it for good. |
this should make you happy @nightlyone :) I'll tag it with 0.5.1 soon |
Works like a charm now! Many thanks @l3pp4rd 👍 |
In a project using vendoring, I cannot use the vendored copy of godog.
Steps to reproduce:
** "foo" the package implementing things
** "features" where I have my
*.feature
files andstep_test.go
** "vendor" where I vendored all my dependencies using
govendor add '+all,^vendor,^local,^std'
using /~https://github.com/kardianos/govendor (including "github.com/DATA-DOG/godog")rm -rf $GOPATHsrc/github.com/DATA-DOG/godog
godog ./features/*.features
leads toIt also doesn't work, when I go to the "features" directory and run
godog *.features
as well.The text was updated successfully, but these errors were encountered: