Skip to content

Commit f2cd826

Browse files
author
Natalie Arellano
committed
Fix tests
- WCOW units by checking for 'windows' in error string - LCOW acceptance by printing a log line and checking it instead of expecting an error Signed-off-by: Natalie Arellano <narellano@vmware.com>
1 parent 6f50db6 commit f2cd826

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

acceptance/acceptance_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,17 +2517,15 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]
25172517
if hostArch := imageManager.HostArch(); hostArch == wrongArch {
25182518
wrongArch = "amd64"
25192519
}
2520-
// FIXME: on an M1 with emulation enabled this test might pass when we expect it to fail
25212520
})
25222521

25232522
it("uses the builder with the desired platform", func() {
2524-
output, err := pack.Run(
2523+
output, _ := pack.Run(
25252524
"build", repoName,
25262525
"-p", filepath.Join("testdata", "mock_app"),
25272526
"--platform", fmt.Sprintf("linux/%s", wrongArch),
25282527
)
2529-
h.AssertNotNil(t, err)
2530-
h.AssertContains(t, output, "was found but does not match the specified platform")
2528+
h.AssertContainsMatch(t, output, fmt.Sprintf("Pulling image '.+' with platform 'linux/%s'", wrongArch))
25312529
})
25322530
})
25332531
})

pkg/image/fetcher.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/base64"
66
"encoding/json"
7+
"fmt"
78
"io"
89
"strings"
910

@@ -108,14 +109,20 @@ func (f *Fetcher) Fetch(ctx context.Context, name string, options FetchOptions)
108109
}
109110
}
110111

111-
f.logger.Debugf("Pulling image %s", style.Symbol(name))
112+
msg := fmt.Sprintf("Pulling image %s", style.Symbol(name))
113+
if options.Platform != "" {
114+
msg = fmt.Sprintf("Pulling image %s with platform %s", style.Symbol(name), style.Symbol(options.Platform))
115+
}
116+
f.logger.Debug(msg)
112117
if err = f.pullImage(ctx, name, options.Platform); err != nil {
113118
// FIXME: this matching is brittle and the fallback should be removed when https://github.com/buildpacks/pack/issues/2079
114119
// has been fixed for a sufficient amount of time.
115120
// Sample error from docker engine:
116121
// `image with reference <image> was found but does not match the specified platform: wanted linux/amd64, actual: linux`
117122
if strings.Contains(err.Error(), "does not match the specified platform") &&
118-
strings.HasSuffix(strings.TrimSpace(err.Error()), "actual: linux") {
123+
(strings.HasSuffix(strings.TrimSpace(err.Error()), "actual: linux") ||
124+
strings.HasSuffix(strings.TrimSpace(err.Error()), "actual: windows")) {
125+
f.logger.Debugf(fmt.Sprintf("Pulling image %s", style.Symbol(name)))
119126
err = f.pullImage(ctx, name, "")
120127
}
121128
}

0 commit comments

Comments
 (0)