Skip to content
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

gexec.Build should create a binary with an expected name #446

Merged
merged 1 commit into from May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions gexec/build.go
Expand Up @@ -3,8 +3,6 @@
package gexec

import (
"crypto/md5"
"encoding/hex"
"errors"
"fmt"
"go/build"
Expand Down Expand Up @@ -197,9 +195,7 @@ func newExecutablePath(gopath, packagePath string, suffixes ...string) (string,
return "", errors.New("$GOPATH not provided when building " + packagePath)
}

hash := md5.Sum([]byte(packagePath))
filename := fmt.Sprintf("%s-%x%s", path.Base(packagePath), hex.EncodeToString(hash[:]), strings.Join(suffixes, ""))
executable := filepath.Join(tmpDir, filename)
executable := filepath.Join(tmpDir, path.Base(packagePath))

if runtime.GOOS == "windows" {
executable += ".exe"
Expand Down
1 change: 1 addition & 0 deletions gexec/build_test.go
Expand Up @@ -24,6 +24,7 @@ var _ = Describe(".Build", func() {
compiledPath, err := gexec.Build(packagePath)
Expect(err).ShouldNot(HaveOccurred())
Expect(compiledPath).Should(BeAnExistingFile())
Expect(filepath.Base(compiledPath)).Should(MatchRegexp(`firefly(|.exe)$`))
})

Context("and CleanupBuildArtifacts has been called", func() {
Expand Down