Build a binary with an expected name (#446)
Changes introduced in onsi/gomega#410 is breaking backward compatibility
for building binaries with an expected name.
Amin Jamali authored 2 years ago
GitHub committed 2 years ago
2 | 2 |
package gexec
|
3 | 3 |
|
4 | 4 |
import (
|
5 | |
"crypto/md5"
|
6 | |
"encoding/hex"
|
7 | 5 |
"errors"
|
8 | 6 |
"fmt"
|
9 | 7 |
"go/build"
|
|
196 | 194 |
return "", errors.New("$GOPATH not provided when building " + packagePath)
|
197 | 195 |
}
|
198 | 196 |
|
199 | |
hash := md5.Sum([]byte(packagePath))
|
200 | |
filename := fmt.Sprintf("%s-%x%s", path.Base(packagePath), hex.EncodeToString(hash[:]), strings.Join(suffixes, ""))
|
201 | |
executable := filepath.Join(tmpDir, filename)
|
|
197 |
executable := filepath.Join(tmpDir, path.Base(packagePath))
|
202 | 198 |
|
203 | 199 |
if runtime.GOOS == "windows" {
|
204 | 200 |
executable += ".exe"
|
23 | 23 |
compiledPath, err := gexec.Build(packagePath)
|
24 | 24 |
Expect(err).ShouldNot(HaveOccurred())
|
25 | 25 |
Expect(compiledPath).Should(BeAnExistingFile())
|
|
26 |
Expect(filepath.Base(compiledPath)).Should(MatchRegexp(`firefly(|.exe)$`))
|
26 | 27 |
})
|
27 | 28 |
|
28 | 29 |
Context("and CleanupBuildArtifacts has been called", func() {
|