forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquality-gate.sh
executable file
·63 lines (56 loc) · 1.92 KB
/
quality-gate.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
#!/bin/bash
set -e
list-hd () {
N=301
LIST_HD=$(git grep -r --count 'List.hd' -- **/*.ml | cut -d ':' -f 2 | paste -sd+ - | bc)
if [ "$LIST_HD" -eq "$N" ]; then
echo "OK counted $LIST_HD usages"
else
echo "ERROR expected $N List.hd usages, got $LIST_HD" 1>&2
exit 1
fi
}
verify-cert () {
N=9
NONE=$(git grep -r --count 'verify_cert:None' -- **/*.ml | cut -d ':' -f 2 | paste -sd+ - | bc)
if [ "$NONE" -eq "$N" ]; then
echo "OK counted $NONE usages of verify_cert:None"
else
echo "ERROR expected $N verify_cert:None usages, got $NONE" 1>&2
exit 1
fi
}
mli-files () {
N=319
# do not count ml files from the tests in ocaml/{tests/perftest/quicktest}
MLIS=$(git ls-files -- '**/*.mli' | grep -vE "ocaml/tests|ocaml/perftest|ocaml/quicktest" | xargs -I {} sh -c "echo {} | cut -f 1 -d '.'" \;)
MLS=$(git ls-files -- '**/*.ml' | grep -vE "ocaml/tests|ocaml/perftest|ocaml/quicktest" | xargs -I {} sh -c "echo {} | cut -f 1 -d '.'" \;)
num_mls_without_mlis=$(comm -23 <(sort <<<"$MLS") <(sort <<<"$MLIS") | wc -l)
if [ "$num_mls_without_mlis" -eq "$N" ]; then
echo "OK counted $num_mls_without_mlis .ml files without an .mli"
else
echo "ERROR expected $N .ml files without .mlis, got $num_mls_without_mlis."\
"If you created some .ml files, they are probably missing corresponding .mli's" 1>&2
exit 1
fi
}
structural-equality () {
N=1
EQ=$(git grep -r --count ' == ' -- '**/*.ml' ':!ocaml/sdk-gen/**/*.ml' | cut -d ':' -f 2 | paste -sd+ - | bc)
if [ "$EQ" -eq "$N" ]; then
echo "OK counted $EQ usages of ' == '"
else
echo "ERROR expected $N usages of ' == '; use = rather than ==" 1>&2
exit 1
fi
if git grep -r --count ' != ' -- '**/*.ml' ':!ocaml/sdk-gen/**/*.ml'; then
echo "ERROR expected no usages of ' != '; use <> rather than !=" 1>&2
exit 1
else
echo "OK found no usages of ' != '"
fi
}
list-hd
verify-cert
mli-files
structural-equality