Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit f25c7b2

Browse files
committed
Fix docker-app search for e2e on CI
The executable name has the platform as suffix on CI. Signed-off-by: Mathieu Champlon <[email protected]>
1 parent 88c04d4 commit f25c7b2

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

e2e/binary_test.go

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,40 @@ func getBinary(t *testing.T) string {
2525
if dockerApp != "" {
2626
return dockerApp
2727
}
28-
dockerApp = os.Getenv("DOCKERAPP_BINARY")
29-
if dockerApp == "" {
30-
binName := "docker-app"
31-
if runtime.GOOS == "windows" {
32-
binName += ".exe"
33-
}
34-
locations := []string{".", "../_build"}
35-
for _, l := range locations {
36-
b := path.Join(l, binName)
37-
if _, err := os.Stat(b); err == nil {
38-
dockerApp = b
39-
break
40-
}
41-
}
42-
}
43-
if dockerApp == "" {
28+
binName := findBinary()
29+
if binName == "" {
4430
t.Error("cannot locate docker-app binary")
4531
}
46-
cmd := exec.Command(dockerApp, "version")
47-
_, err := cmd.CombinedOutput()
48-
assert.NilError(t, err, "failed to execute docker-app binary")
32+
cmd := exec.Command(binName, "version")
33+
err := cmd.Run()
34+
assert.NilError(t, err, "failed to execute %s", binName)
35+
dockerApp = binName
4936
return dockerApp
5037
}
5138

39+
func findBinary() string {
40+
binNames := []string{
41+
os.Getenv("DOCKERAPP_BINARY"),
42+
"./docker-app-" + runtime.GOOS + binExt(),
43+
"./docker-app" + binExt(),
44+
"../_build/docker-app-" + runtime.GOOS + binExt(),
45+
"../_build/docker_app" + binExt(),
46+
}
47+
for _, binName := range binNames {
48+
if _, err := os.Stat(binName); err == nil {
49+
return binName
50+
}
51+
}
52+
return ""
53+
}
54+
55+
func binExt() string {
56+
if runtime.GOOS == "windows" {
57+
return ".exe"
58+
}
59+
return ""
60+
}
61+
5262
func TestRenderBinary(t *testing.T) {
5363
getBinary(t)
5464
apps, err := ioutil.ReadDir("render")

0 commit comments

Comments
 (0)