look into more vendor directories for godog package, fixes #35
Этот коммит содержится в:
родитель
abc6b65c1c
коммит
6e2c1b291a
1 изменённых файлов: 18 добавлений и 1 удалений
19
builder.go
19
builder.go
|
@ -130,7 +130,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 := maybeVendorPaths(abs)
|
||||
for _, d := range build.Default.SrcDirs() {
|
||||
try = append(try, filepath.Join(d, godogImportPath))
|
||||
}
|
||||
|
@ -261,6 +261,23 @@ func buildTestMain(pkg *build.Package) ([]byte, bool, error) {
|
|||
return buf.Bytes(), len(contexts) > 0, nil
|
||||
}
|
||||
|
||||
// maybeVendorPaths determines possible vendor paths
|
||||
// which goes levels down from given directory
|
||||
// until it reaches GOPATH source dir
|
||||
func maybeVendorPaths(dir string) []string {
|
||||
paths := []string{filepath.Join(dir, "vendor", godogImportPath)}
|
||||
for _, gopath := range gopaths {
|
||||
if !strings.HasPrefix(dir, gopath) {
|
||||
continue
|
||||
}
|
||||
|
||||
for p := filepath.Dir(dir); p != filepath.Join(gopath, "src"); p = filepath.Dir(p) {
|
||||
paths = append(paths, filepath.Join(p, "vendor", godogImportPath))
|
||||
}
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
||||
// processPackageTestFiles runs through ast of each test
|
||||
// file pack and looks for godog suite contexts to register
|
||||
// on run
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче