if godog package is not a module, make sure it is installed
Этот коммит содержится в:
родитель
d3842ecb6a
коммит
34d2595d5b
3 изменённых файлов: 60 добавлений и 7 удалений
|
@ -161,6 +161,16 @@ func Build(bin string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !isModule(godogImportPath, mods) {
|
||||
// must make sure that package is installed
|
||||
// modules are installed on download
|
||||
cmd := exec.Command("go", "install", "-i", godogPkg.ImportPath)
|
||||
cmd.Env = os.Environ()
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("failed to install godog package: %s, reason: %v", string(out), err)
|
||||
}
|
||||
}
|
||||
|
||||
// compile godog testmain package archive
|
||||
// we do not depend on CGO so a lot of checks are not necessary
|
||||
testMainPkgOut := filepath.Join(testdir, "main.a")
|
||||
|
@ -488,3 +498,17 @@ func readModules() []*module {
|
|||
}
|
||||
return mods
|
||||
}
|
||||
|
||||
func isModule(name string, mods []*module) bool {
|
||||
if mods == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, mod := range mods {
|
||||
if pkg := mod.match(name); pkg != nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -11,8 +11,13 @@ import (
|
|||
)
|
||||
|
||||
func TestGodogBuildWithModuleOutsideGopath(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
|
||||
dir := filepath.Join(os.TempDir(), "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
err = buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
if err != nil {
|
||||
os.RemoveAll(dir)
|
||||
t.Fatal(err)
|
||||
|
@ -48,9 +53,13 @@ func TestGodogBuildWithModuleOutsideGopath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGodogBuildWithModuleInsideGopath(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
gopath := filepath.Join(os.TempDir(), "_gp")
|
||||
dir := filepath.Join(gopath, "src", "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
err = buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
if err != nil {
|
||||
os.RemoveAll(gopath)
|
||||
t.Fatal(err)
|
||||
|
|
|
@ -92,8 +92,12 @@ func buildTestPackage(dir, feat, src, testSrc string) error {
|
|||
}
|
||||
|
||||
func TestGodogBuildWithSourceNotInGoPath(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
dir := filepath.Join(os.TempDir(), "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
err = buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
if err != nil {
|
||||
os.RemoveAll(dir)
|
||||
t.Fatal(err)
|
||||
|
@ -124,8 +128,12 @@ func TestGodogBuildWithSourceNotInGoPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGodogBuildWithoutSourceNotInGoPath(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
dir := filepath.Join(os.TempDir(), "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, "", "")
|
||||
err = buildTestPackage(dir, builderFeatureFile, "", "")
|
||||
if err != nil {
|
||||
os.RemoveAll(dir)
|
||||
t.Fatal(err)
|
||||
|
@ -156,8 +164,12 @@ func TestGodogBuildWithoutSourceNotInGoPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGodogBuildWithoutTestSourceNotInGoPath(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
dir := filepath.Join(os.TempDir(), "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, "")
|
||||
err = buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, "")
|
||||
if err != nil {
|
||||
os.RemoveAll(dir)
|
||||
t.Fatal(err)
|
||||
|
@ -188,9 +200,13 @@ func TestGodogBuildWithoutTestSourceNotInGoPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGodogBuildWithinGopath(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
gopath := filepath.Join(os.TempDir(), "_gp")
|
||||
dir := filepath.Join(gopath, "src", "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
err = buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
if err != nil {
|
||||
os.RemoveAll(gopath)
|
||||
t.Fatal(err)
|
||||
|
@ -233,9 +249,13 @@ func TestGodogBuildWithinGopath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGodogBuildWithVendoredGodog(t *testing.T) {
|
||||
_, err := exec.LookPath("godog")
|
||||
if err != nil {
|
||||
t.SkipNow() // no command installed
|
||||
}
|
||||
gopath := filepath.Join(os.TempDir(), "_gp")
|
||||
dir := filepath.Join(gopath, "src", "godogs")
|
||||
err := buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
err = buildTestPackage(dir, builderFeatureFile, builderMainCodeFile, builderTestFile)
|
||||
if err != nil {
|
||||
os.RemoveAll(gopath)
|
||||
t.Fatal(err)
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче