-
Notifications
You must be signed in to change notification settings - Fork 181
/
tests.sh
55 lines (43 loc) · 1.13 KB
/
tests.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
UPSTREAM=https://github.com/larsbrinkhoff/awesome-cpus
MAX_DIR_SIZE=27000
error() {
echo
echo "ERROR: $1"
exit 1
}
test_directory_size() {
echo -n "Checking that no directory is too large... "
git submodule deinit . > /dev/null
du -s * | while read i; do
set $i
if test "$1" -gt $MAX_DIR_SIZE; then
error "The $2 directory is too large"
fi
done
echo OK
}
directories_in_commit() {
git show --name-only --format=format: "$1" | grep / | wc -l
}
test_commits() {
echo -n "Checking that each commit touches only one directory... "
git remote add github-upstream $UPSTREAM
git log --format="format:%H%n" origin/master..HEAD | while read i; do
if test `directories_in_commit "$i"` -gt 1; then
h=`echo "$i" | cut -c1-7`
error "Commit $h touches more than one directory."
fi
done
git remote remove github-upstream
echo OK
}
test_readme() {
echo -n "Checking that every directory has a README.md... "
for i in *; do
if test -d "$i"; then
test -f "$i/README.md" || error "The $i directory has no README.md."
fi
done
}
test_directory_size
test_commits