mirror of
https://github.com/containers/skopeo.git
synced 2025-09-02 23:26:29 +00:00
Merge pull request #760 from mtrmac/test-failures
Support running tests from c/image
This commit is contained in:
17
Makefile
17
Makefile
@@ -26,10 +26,11 @@ GO ?= go
|
|||||||
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
|
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
|
||||||
GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man')
|
GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man')
|
||||||
|
|
||||||
GO_BUILD=$(GO) build
|
# Go module support: set `-mod=vendor` to use the vendored sources.
|
||||||
# Go module support: set `-mod=vendor` to use the vendored sources
|
# See also hack/make.sh.
|
||||||
ifeq ($(shell go help mod >/dev/null 2>&1 && echo true), true)
|
ifeq ($(shell go help mod >/dev/null 2>&1 && echo true), true)
|
||||||
GO_BUILD=GO111MODULE=on $(GO) build -mod=vendor
|
GO:=GO111MODULE=on $(GO)
|
||||||
|
MOD_VENDOR=-mod=vendor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
@@ -100,10 +101,10 @@ binary-static: cmd/skopeo
|
|||||||
|
|
||||||
# Build w/o using containers
|
# Build w/o using containers
|
||||||
binary-local:
|
binary-local:
|
||||||
$(GPGME_ENV) $(GO_BUILD) ${GO_DYN_FLAGS} -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo
|
$(GPGME_ENV) $(GO) build $(MOD_VENDOR) ${GO_DYN_FLAGS} -ldflags "-X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo
|
||||||
|
|
||||||
binary-local-static:
|
binary-local-static:
|
||||||
$(GPGME_ENV) $(GO_BUILD) -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo
|
$(GPGME_ENV) $(GO) build $(MOD_VENDOR) -ldflags "-extldflags \"-static\" -X main.gitCommit=${GIT_COMMIT}" -gcflags "$(GOGCFLAGS)" -tags "$(BUILDTAGS)" -o skopeo ./cmd/skopeo
|
||||||
|
|
||||||
build-container:
|
build-container:
|
||||||
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" .
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -t "$(IMAGE)" .
|
||||||
@@ -152,8 +153,8 @@ test-integration: build-container
|
|||||||
# complicated set of options needed to run podman-in-podman
|
# complicated set of options needed to run podman-in-podman
|
||||||
test-system: build-container
|
test-system: build-container
|
||||||
DTEMP=$(shell mktemp -d --tmpdir=/var/tmp podman-tmp.XXXXXX); \
|
DTEMP=$(shell mktemp -d --tmpdir=/var/tmp podman-tmp.XXXXXX); \
|
||||||
$(CONTAINER_CMD) --privileged --net=host \
|
$(CONTAINER_CMD) --privileged \
|
||||||
-v $$DTEMP:/var/lib/containers:Z \
|
-v $$DTEMP:/var/lib/containers:Z -v /run/systemd/journal/socket:/run/systemd/journal/socket \
|
||||||
"$(IMAGE)" \
|
"$(IMAGE)" \
|
||||||
bash -c 'BUILDTAGS="$(BUILDTAGS)" hack/make.sh test-system'; \
|
bash -c 'BUILDTAGS="$(BUILDTAGS)" hack/make.sh test-system'; \
|
||||||
rc=$$?; \
|
rc=$$?; \
|
||||||
@@ -174,7 +175,7 @@ validate-local:
|
|||||||
hack/make.sh validate-git-marks validate-gofmt validate-lint validate-vet
|
hack/make.sh validate-git-marks validate-gofmt validate-lint validate-vet
|
||||||
|
|
||||||
test-unit-local:
|
test-unit-local:
|
||||||
$(GPGME_ENV) $(GO) test -tags "$(BUILDTAGS)" $$($(GO) list -tags "$(BUILDTAGS)" -e ./... | grep -v '^github\.com/containers/skopeo/\(integration\|vendor/.*\)$$')
|
$(GPGME_ENV) $(GO) test $(MOD_VENDOR) -tags "$(BUILDTAGS)" $$($(GO) list $(MOD_VENDOR) -tags "$(BUILDTAGS)" -e ./... | grep -v '^github\.com/containers/skopeo/\(integration\|vendor/.*\)$$')
|
||||||
|
|
||||||
vendor:
|
vendor:
|
||||||
export GO111MODULE=on \
|
export GO111MODULE=on \
|
||||||
|
14
hack/make.sh
14
hack/make.sh
@@ -57,7 +57,15 @@ DEFAULT_BUNDLES=(
|
|||||||
test-integration
|
test-integration
|
||||||
)
|
)
|
||||||
|
|
||||||
TESTFLAGS+=" -test.timeout=10m"
|
TESTFLAGS+=" -test.timeout=15m"
|
||||||
|
|
||||||
|
# Go module support: set `-mod=vendor` to use the vendored sources
|
||||||
|
# See also the top-level Makefile.
|
||||||
|
mod_vendor=
|
||||||
|
if go help mod >/dev/null 2>&1; then
|
||||||
|
export GO111MODULE=on
|
||||||
|
mod_vendor='-mod=vendor'
|
||||||
|
fi
|
||||||
|
|
||||||
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
|
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
|
||||||
# You can use this to select certain tests to run, eg.
|
# You can use this to select certain tests to run, eg.
|
||||||
@@ -72,10 +80,10 @@ TESTFLAGS+=" -test.timeout=10m"
|
|||||||
go_test_dir() {
|
go_test_dir() {
|
||||||
dir=$1
|
dir=$1
|
||||||
(
|
(
|
||||||
echo '+ go test' $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} "${SKOPEO_PKG}${dir#.}"
|
echo '+ go test' $mod_vendor $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"} "${SKOPEO_PKG}${dir#.}"
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
export DEST="$ABS_DEST" # we're in a subshell, so this is safe -- our integration-cli tests need DEST, and "cd" screws it up
|
export DEST="$ABS_DEST" # we're in a subshell, so this is safe -- our integration-cli tests need DEST, and "cd" screws it up
|
||||||
go test $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"}
|
go test $mod_vendor $TESTFLAGS ${BUILDTAGS:+-tags "$BUILDTAGS"}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
errors=$(go vet $(go list -e ./... | grep -v "$SKOPEO_PKG"/vendor))
|
errors=$(go vet $mod_vendor $(go list $mod_vendor -e ./...))
|
||||||
|
|
||||||
if [ -z "$errors" ]; then
|
if [ -z "$errors" ]; then
|
||||||
echo 'Congratulations! All Go source files have been vetted.'
|
echo 'Congratulations! All Go source files have been vetted.'
|
||||||
|
@@ -27,7 +27,7 @@ func init() {
|
|||||||
const (
|
const (
|
||||||
v2DockerRegistryURL = "localhost:5555" // Update also policy.json
|
v2DockerRegistryURL = "localhost:5555" // Update also policy.json
|
||||||
v2s1DockerRegistryURL = "localhost:5556"
|
v2s1DockerRegistryURL = "localhost:5556"
|
||||||
knownWindowsOnlyImage = "docker://mcr.microsoft.com/windows/servercore:ltsc2019"
|
knownWindowsOnlyImage = "docker://mcr.microsoft.com/windows/nanoserver:1909"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CopySuite struct {
|
type CopySuite struct {
|
||||||
|
Reference in New Issue
Block a user