Skip to content

Commit 4a169ff

Browse files
committed
test(e2e): set aside a counter file a node left short instead of failing the report
Signed-off-by: Bugs5382 <12115015+Bugs5382@users.noreply.github.com>
1 parent eef2c72 commit 4a169ff

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎test/image/coverage.sh‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ out="${2:?output dir}"
1717

1818
log() { printf '[e2e:image coverage] %s\n' "$*" >&2; }
1919

20+
cd "$root"
21+
22+
# A node can stop mid-write (a reboot or the harness stopping the VM), which
23+
# leaves a short counter file that covdata refuses outright. Check each file
24+
# on its own and set aside the ones that do not read.
25+
check="$(mktemp -d)"
26+
trap 'rm -rf "$check"' EXIT
27+
for f in "$counters"/*/covcounters.*; do
28+
[ -e "$f" ] || continue
29+
rm -rf "${check:?}"/*
30+
cp "$(dirname "$f")"/covmeta.* "$check"/ 2>/dev/null || true
31+
cp "$f" "$check"/
32+
if ! go tool covdata percent -i="$check" >/dev/null 2>&1; then
33+
log "unreadable counter file set aside: $f"
34+
mv "$f" "$f.unreadable"
35+
fi
36+
done
37+
2038
dirs=()
2139
for d in "$counters"/*/; do
2240
d="${d%/}"
@@ -33,8 +51,6 @@ if [ "${#dirs[@]}" -eq 0 ]; then
3351
exit 1
3452
fi
3553
inputs="$(IFS=,; echo "${dirs[*]}")"
36-
37-
cd "$root"
3854
go tool covdata percent -i="$inputs" | sort >"$out/coverage-percent.txt"
3955
go tool covdata textfmt -i="$inputs" -o "$out/coverage.txt"
4056
go tool cover -html="$out/coverage.txt" -o "$out/coverage.html"

0 commit comments

Comments
 (0)