mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests/e2e,etcdctl,etcdmain: Fix go test --tags cov -v ./tests/e2e
This CL fixes: COVERDIR=./coverage PASSES="build_cov" && go test --tags cov -v ./tests/e2e and is part of the effort to make: COVERDIR=coverage PASSES="build_cov cov" ./test fully pass. The args passed to ./bin/etcd_test and ./bin/etcdctl_test binaries were mismatched. The protocol of passing the arguments using environment variables has been replaces with proper passing of flags. How the measurement of coverage by e2e tests works: 1. COVERDIR=./coverage PASSES="build_cov" are generating ./bin/etcd_test and ./bin/etcdctl_test binaries. 2. These binaries are tests (as coverage can be computed only for tests) [see ./main_test.go ./etcdctl/main_test.go], but this tests are running the main logic of the server and uppon termination (or SIGTERM signal) are writting proper .coverprofile files in the $COVERDIR folder. The binaries used to take arguments using env variables, but its not needed any longer. The binaries can consume any command line arguments that either test (so --test.fooo) or the original binary can consume. 3. The tests/e2e (when compiled with the --tags cov) are starting the _test binaries instead of the original binaries, such that the coverage is being collected.
This commit is contained in:
4
test
4
test
@@ -304,6 +304,9 @@ function cov_pass {
|
||||
# strip out generated files (using GNU-style sed)
|
||||
sed --in-place '/generated.go/d' "$COVERDIR"/cover.out || true
|
||||
|
||||
echo -e "\nTo generate coverage report use:"
|
||||
echo -e " go tool cover --html=$COVERDIR/cover.out\n"
|
||||
|
||||
# held failures to generate the full coverage file, now fail
|
||||
if [ -n "$failed" ]; then
|
||||
for f in $failed; do
|
||||
@@ -665,6 +668,7 @@ function build_cov_pass {
|
||||
out="bin"
|
||||
if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
|
||||
go test -mod=mod -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcd_test"
|
||||
|
||||
go test -mod=mod -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcdctl_test" "${REPO_PATH}/etcdctl"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user