diff --git a/Makefile b/Makefile index 3c6aaf57..6282edd6 100644 --- a/Makefile +++ b/Makefile @@ -201,11 +201,15 @@ test-integration: $(MAKE) test-integration-local +# Helper target to set up SKOPEO_BINARY variable for local test targets +.eval-skopeo-binary: $(if $(SKOPEO_BINARY),,bin/skopeo) + $(eval SKOPEO_BINARY := $(or $(SKOPEO_BINARY),./bin/skopeo)) + @echo "Testing with $(SKOPEO_BINARY) ..." + # Primarily intended for CI. -test-integration-local: bin/skopeo +test-integration-local: .eval-skopeo-binary hack/warn-destructive-tests.sh - $(MAKE) PREFIX=/usr install - cd ./integration && $(GO) test $(SKOPEO_LDFLAGS) $(TESTFLAGS) $(if $(BUILDTAGS),-tags "$(BUILDTAGS)") + cd ./integration && SKOPEO_BINARY="$(abspath $(SKOPEO_BINARY))" $(GO) test $(SKOPEO_LDFLAGS) $(TESTFLAGS) $(if $(BUILDTAGS),-tags "$(BUILDTAGS)") # complicated set of options needed to run podman-in-podman test-system: @@ -220,9 +224,8 @@ test-system: exit $$rc # Primarily intended for CI. -test-system-local: $(if $(SKOPEO_BINARY),,bin/skopeo) +test-system-local: .eval-skopeo-binary hack/warn-destructive-tests.sh - @echo "Testing with $(or $(SKOPEO_BINARY),$(eval SKOPEO_BINARY := "bin/skopeo")$(SKOPEO_BINARY)) ..." bats --tap systemtest test-unit: diff --git a/integration/check_test.go b/integration/check_test.go index 01b53036..07b8382b 100644 --- a/integration/check_test.go +++ b/integration/check_test.go @@ -50,7 +50,7 @@ func (s *skopeoSuite) TearDownSuite() { func (s *skopeoSuite) TestVersion() { t := s.T() - assertSkopeoSucceeds(t, fmt.Sprintf(".*%s version %s.*", skopeoBinary, version.Version), + assertSkopeoSucceeds(t, fmt.Sprintf(".*skopeo version %s.*", version.Version), "--version") } diff --git a/integration/proxy_test.go b/integration/proxy_test.go index 4a91b252..849968b2 100644 --- a/integration/proxy_test.go +++ b/integration/proxy_test.go @@ -282,7 +282,7 @@ func newProxy() (*proxy, error) { } // Note ExtraFiles starts at 3 - proc := exec.Command("skopeo", "experimental-image-proxy", "--sockfd", "3") + proc := exec.Command(skopeoBinary, "experimental-image-proxy", "--sockfd", "3") proc.Stderr = os.Stderr cmdLifecycleToParentIfPossible(proc) proc.ExtraFiles = append(proc.ExtraFiles, theirfd) diff --git a/integration/utils_test.go b/integration/utils_test.go index 4bfbf721..554b51ba 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -20,7 +20,14 @@ import ( "go.podman.io/image/v5/manifest" ) -const skopeoBinary = "skopeo" +// FIXME: Move to SetupSuite +// https://github.com/containers/skopeo/pull/2703#discussion_r2331374730 +var skopeoBinary = func() string { + if binary := os.Getenv("SKOPEO_BINARY"); binary != "" { + return binary + } + return "skopeo" +}() const testFQIN = "docker://quay.io/libpod/busybox" // tag left off on purpose, some tests need to add a special one const testFQIN64 = "docker://quay.io/libpod/busybox:amd64"