# scripts/lib/render-coverage-index.awk # Render the coverage index page from summary rows. # Input CSV rows (no header): ",,,". # Per-file detail pages are expected at html/.html. # Variables: -v TITLE="..." function esc(s) { gsub(/&/, "\\&", s); gsub(//, "\\>", s) return s } function color(p) { if (p + 0 >= 80) return "#2da44e" if (p + 0 >= 50) return "#bf8700" return "#cf222e" } BEGIN { FS = ","; n = 0; tot = 0; cov = 0 } { n++ f[n] = $1; ex[n] = $2 + 0; cv[n] = $3 + 0; pc[n] = $4 + 0 tot += $2 + 0; cov += $3 + 0 } END { overall = (tot > 0 ? cov * 100.0 / tot : 0) print "" print "" esc(TITLE) "" print "" print "

" esc(TITLE) "

" printf "
Overall: %.1f%% (%d/%d executable lines)
\n", color(overall), overall, cov, tot print "" for (i = 1; i <= n; i++) { printf "", esc(f[i]), esc(f[i]) printf "", pc[i], color(pc[i]) printf "\n", pc[i], cv[i], ex[i] } print "
filecoverage%coveredexecutable
%s
%.1f%%%d%d
" }