mirror of https://github.com/docker/cli.git
Merge pull request #1639 from silvin-lubecki/use-gotestsum
Use gotest.tools/gotestsum for unit and e2e tests
This commit is contained in:
commit
3b345e4aad
6
Makefile
6
Makefile
|
@ -11,15 +11,15 @@ clean: ## remove build artifacts
|
||||||
rm -rf ./build/* cli/winresources/rsrc_* ./man/man[1-9] docs/yaml/gen
|
rm -rf ./build/* cli/winresources/rsrc_* ./man/man[1-9] docs/yaml/gen
|
||||||
|
|
||||||
.PHONY: test-unit
|
.PHONY: test-unit
|
||||||
test-unit: ## run unit test
|
test-unit: ## run unit tests, to change the output format use: GOTESTSUM_FORMAT=(dots|short|standard-quiet|short-verbose|standard-verbose) make test-unit
|
||||||
./scripts/test/unit $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
gotestsum -- $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: test-unit ## run tests
|
test: test-unit ## run tests
|
||||||
|
|
||||||
.PHONY: test-coverage
|
.PHONY: test-coverage
|
||||||
test-coverage: ## run test coverage
|
test-coverage: ## run test coverage
|
||||||
./scripts/test/unit-with-coverage $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
gotestsum -- -coverprofile=coverage.txt $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
|
|
11
circle.yml
11
circle.yml
|
@ -56,11 +56,16 @@ jobs:
|
||||||
- run:
|
- run:
|
||||||
name: "Unit Test with Coverage"
|
name: "Unit Test with Coverage"
|
||||||
command: |
|
command: |
|
||||||
|
mkdir test-results
|
||||||
docker build -f dockerfiles/Dockerfile.dev --tag cli-builder:$CIRCLE_BUILD_NUM .
|
docker build -f dockerfiles/Dockerfile.dev --tag cli-builder:$CIRCLE_BUILD_NUM .
|
||||||
docker run --name \
|
docker run \
|
||||||
|
-e GOTESTSUM_JUNITFILE=/tmp/junit.xml \
|
||||||
|
--name \
|
||||||
test-$CIRCLE_BUILD_NUM cli-builder:$CIRCLE_BUILD_NUM \
|
test-$CIRCLE_BUILD_NUM cli-builder:$CIRCLE_BUILD_NUM \
|
||||||
make test-coverage
|
make test-coverage
|
||||||
|
docker cp \
|
||||||
|
test-$CIRCLE_BUILD_NUM:/tmp/junit.xml \
|
||||||
|
/work/test-results/unit-tests
|
||||||
- run:
|
- run:
|
||||||
name: "Upload to Codecov"
|
name: "Upload to Codecov"
|
||||||
command: |
|
command: |
|
||||||
|
@ -70,6 +75,8 @@ jobs:
|
||||||
apk add -U bash curl
|
apk add -U bash curl
|
||||||
curl -s https://codecov.io/bash | bash || \
|
curl -s https://codecov.io/bash | bash || \
|
||||||
echo 'Codecov failed to upload'
|
echo 'Codecov failed to upload'
|
||||||
|
- store_test_results:
|
||||||
|
path: test-results
|
||||||
|
|
||||||
validate:
|
validate:
|
||||||
working_directory: /work
|
working_directory: /work
|
||||||
|
|
|
@ -16,6 +16,11 @@ RUN go get -d github.com/mjibson/esc && \
|
||||||
go build -v -o /usr/bin/esc . && \
|
go build -v -o /usr/bin/esc . && \
|
||||||
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
rm -rf /go/src/* /go/pkg/* /go/bin/*
|
||||||
|
|
||||||
|
ARG GOTESTSUM_VERSION=0.3.2
|
||||||
|
RUN curl -Ls https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz && \
|
||||||
|
tar -xf gotestsum.tar.gz gotestsum -C /usr/bin && \
|
||||||
|
rm gotestsum.tar.gz
|
||||||
|
|
||||||
ENV CGO_ENABLED=0 \
|
ENV CGO_ENABLED=0 \
|
||||||
PATH=$PATH:/go/src/github.com/docker/cli/build \
|
PATH=$PATH:/go/src/github.com/docker/cli/build \
|
||||||
DISABLE_WARN_OUTSIDE_CONTAINER=1
|
DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||||
|
|
|
@ -24,6 +24,12 @@ ARG NOTARY_VERSION=v0.6.1
|
||||||
RUN curl -Ls https://github.com/theupdateframework/notary/releases/download/${NOTARY_VERSION}/notary-Linux-amd64 -o /usr/local/bin/notary \
|
RUN curl -Ls https://github.com/theupdateframework/notary/releases/download/${NOTARY_VERSION}/notary-Linux-amd64 -o /usr/local/bin/notary \
|
||||||
&& chmod +x /usr/local/bin/notary
|
&& chmod +x /usr/local/bin/notary
|
||||||
|
|
||||||
|
ARG GOTESTSUM_VERSION=0.3.2
|
||||||
|
RUN curl -Ls https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz \
|
||||||
|
&& tar -xf gotestsum.tar.gz gotestsum \
|
||||||
|
&& mv gotestsum /usr/local/bin/gotestsum \
|
||||||
|
&& rm gotestsum.tar.gz
|
||||||
|
|
||||||
ENV CGO_ENABLED=0 \
|
ENV CGO_ENABLED=0 \
|
||||||
DISABLE_WARN_OUTSIDE_CONTAINER=1 \
|
DISABLE_WARN_OUTSIDE_CONTAINER=1 \
|
||||||
PATH=/go/src/github.com/docker/cli/build:$PATH
|
PATH=/go/src/github.com/docker/cli/build:$PATH
|
||||||
|
|
|
@ -68,9 +68,9 @@ function runtests {
|
||||||
TEST_REMOTE_DAEMON="${REMOTE_DAEMON-}" \
|
TEST_REMOTE_DAEMON="${REMOTE_DAEMON-}" \
|
||||||
TEST_SKIP_PLUGIN_TESTS="${SKIP_PLUGIN_TESTS-}" \
|
TEST_SKIP_PLUGIN_TESTS="${SKIP_PLUGIN_TESTS-}" \
|
||||||
GOPATH="$GOPATH" \
|
GOPATH="$GOPATH" \
|
||||||
PATH="$PWD/build/:/usr/bin" \
|
PATH="$PWD/build/:/usr/bin:/usr/local/bin:/usr/local/go/bin" \
|
||||||
DOCKER_CLI_E2E_PLUGINS_EXTRA_DIRS="$PWD/build/plugins-linux-amd64" \
|
DOCKER_CLI_E2E_PLUGINS_EXTRA_DIRS="$PWD/build/plugins-linux-amd64" \
|
||||||
"$(which go)" test -v ./e2e/... ${TESTFLAGS-}
|
"$(which gotestsum)" -- ./e2e/... ${TESTFLAGS-}
|
||||||
}
|
}
|
||||||
|
|
||||||
export unique_id="${E2E_UNIQUE_ID:-cliendtoendsuite}"
|
export unique_id="${E2E_UNIQUE_ID:-cliendtoendsuite}"
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -eu -o pipefail
|
|
||||||
|
|
||||||
go test -v "$@"
|
|
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -eu -o pipefail
|
|
||||||
|
|
||||||
# install test dependencies once before running tests for each package. This
|
|
||||||
# reduces the runtime from 200s down to 23s
|
|
||||||
go test -i "$@"
|
|
||||||
|
|
||||||
echo "mode: atomic" > coverage.txt
|
|
||||||
for pkg in "$@"; do
|
|
||||||
./scripts/test/unit \
|
|
||||||
-cover \
|
|
||||||
-coverprofile=profile.out \
|
|
||||||
-covermode=atomic \
|
|
||||||
"${pkg}"
|
|
||||||
|
|
||||||
if test -f profile.out; then
|
|
||||||
grep -v "^mode:" < profile.out >> coverage.txt || true
|
|
||||||
rm profile.out
|
|
||||||
fi
|
|
||||||
done
|
|
Loading…
Reference in New Issue