forked from elego/rental-vertical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cov-table.sh
executable file
·69 lines (61 loc) · 1.41 KB
/
cov-table.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
addcol ()
{
if [ -n "${AWKFS}" ]; then
MAWK="/usr/bin/awk -F '${AWKFS}'";
else
MAWK=/usr/bin/awk;
fi;
${MAWK} '
BEGIN {
sum[0] = 0
maxcol = 0
n = 0
}
{
for (i = 1; i <= NF; i++) {
if (NF > maxcol) {
maxcol = NF
}
sum[i] += $i
}
n = n + 1
}
END {
printf("%d lines\n", n)
printf("sums: ")
for (i = 1; i <= maxcol; i++) {
printf("%d ", sum[i])
}
printf("\naverages: ")
for (i = 1; i <= maxcol; i++) {
printf("%.2d ", sum[i]/n)
}
printf("\n")
}
' "$@"
}
printf "| %-64s | %4s | %4s | %4s |\n" "*module*" "*lines*" "*misses*" "*percent*"
case "$1" in
*coverage-report*.txt) report="$1"; shift;;
*) report=${HOME}/Downloads/coverage-report.txt;;
esac
suma=0
sumb=0
for f in ${@:-rental_* sale_* stock_* shipment_*}; do
if [[ -s $f/__manifest__.py ]]; then
s=$(grep "rental-vertical/${f}/" ${report} | addcol | grep 'sums:')
a=$( echo $s | awk '{print $3}')
b=$( echo $s | awk '{print $4}')
if [[ -n "$a" && -n "$b" ]]; then
suma=$(( ${suma} + ${a} ))
sumb=$(( ${sumb} + ${b} ))
p=$(( ( $a - $b ) * 100 / $a ))
else
p=0
fi
printf "| %-64s |>. %4d |>. %4d |>. %4d |\n" "$f" "$a" "$b" "$p"
fi
done
p=$(( ( ${suma} - ${sumb} ) * 100 / ${suma} ))
printf "| %-64s |>. %4s |>. %4s |>. %4s |\n" "*total*" "*${suma}*" "*${sumb}*" "*${p}*"