improves builder to use go env in order to find compiler and linker,

closes #64
Этот коммит содержится в:
gedi 2017-08-02 11:03:12 +03:00
родитель c316cae832
коммит aea8188613
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 56604CDCCC201556
2 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -28,7 +28,8 @@ files.
**Godog** acts similar compared to **go test** command, by using go **Godog** acts similar compared to **go test** command, by using go
compiler and linker tool in order to produce test executable. Godog compiler and linker tool in order to produce test executable. Godog
contexts need to be exported the same way as **Test** functions for go contexts need to be exported the same way as **Test** functions for go
tests. tests. Note, that if you use **godog** command tool, it will use `go`
executable to determine compiler and linker.
**Godog** ships gherkin parser dependency as a subpackage. This will **Godog** ships gherkin parser dependency as a subpackage. This will
ensure that it is always compatible with the installed version of godog. ensure that it is always compatible with the installed version of godog.

Просмотреть файл

@ -17,8 +17,9 @@ import (
"unicode" "unicode"
) )
var compiler = filepath.Join(build.ToolDir, "compile") var tooldir = findToolDir()
var linker = filepath.Join(build.ToolDir, "link") var compiler = filepath.Join(tooldir, "compile")
var linker = filepath.Join(tooldir, "link")
var gopaths = filepath.SplitList(build.Default.GOPATH) var gopaths = filepath.SplitList(build.Default.GOPATH)
var goarch = build.Default.GOARCH var goarch = build.Default.GOARCH
var goos = build.Default.GOOS var goos = build.Default.GOOS
@ -78,7 +79,7 @@ func Build(bin string) error {
// go does it better // go does it better
out, err := exec.Command("go", "test", "-i").CombinedOutput() out, err := exec.Command("go", "test", "-i").CombinedOutput()
if err != nil { if err != nil {
return fmt.Errorf("failed to compile package %s:\n%s", pkg.Name, string(out)) return fmt.Errorf("failed to compile package: %s, reason: %v, output: %s", pkg.Name, err, string(out))
} }
// let go do the dirty work and compile test // let go do the dirty work and compile test
@ -95,7 +96,7 @@ func Build(bin string) error {
// go has built. We will reuse it for our suite workdir. // go has built. We will reuse it for our suite workdir.
out, err = exec.Command("go", "test", "-c", "-work", "-o", temp).CombinedOutput() out, err = exec.Command("go", "test", "-c", "-work", "-o", temp).CombinedOutput()
if err != nil { if err != nil {
return fmt.Errorf("failed to compile tested package %s:\n%s", pkg.Name, string(out)) return fmt.Errorf("failed to compile tested package: %s, reason: %v, output: %s", pkg.Name, err, string(out))
} }
defer os.Remove(temp) defer os.Remove(temp)
@ -140,7 +141,7 @@ func Build(bin string) error {
cmd.Env = os.Environ() cmd.Env = os.Environ()
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
return fmt.Errorf("failed to install godog package:\n%s", string(out)) return fmt.Errorf("failed to install godog package: %s, reason: %v", string(out), err)
} }
// collect all possible package dirs, will be // collect all possible package dirs, will be
@ -173,7 +174,7 @@ func Build(bin string) error {
cmd.Env = os.Environ() cmd.Env = os.Environ()
out, err = cmd.CombinedOutput() out, err = cmd.CombinedOutput()
if err != nil { if err != nil {
return fmt.Errorf("failed to compile testmain package:\n%s", string(out)) return fmt.Errorf("failed to compile testmain package: %v - output: %s", err, string(out))
} }
// link test suite executable // link test suite executable
@ -324,3 +325,10 @@ func processPackageTestFiles(packs ...[]string) ([]string, error) {
} }
return ctxs, nil return ctxs, nil
} }
func findToolDir() string {
if out, err := exec.Command("go", "env", "GOTOOLDIR").Output(); err != nil {
return filepath.Clean(strings.TrimSpace(string(out)))
}
return filepath.Clean(build.ToolDir)
}