AT: automated test loop
Junio C Hamano committed
Apr 8, 2008 at 22:21 UTC
6c48740c11f22885b949399b3a95def3e431abbf
2 files changed
+199
.gitignore
new
+3
@@ -0,0 +1,3 @@
1
+/AT.log
2
+/AT.log.bak
3
+/AT.build-logs/
AT
new
+196
@@ -0,0 +1,196 @@
1
+#!/bin/sh
2
+
3
+log=Meta/AT.log
4
+>>"$log"
5
+buildlog=Meta/AT.build-logs
6
+mkdir -p "$buildlog"
7
+t="/tmp/AT.$$"
8
+
9
+trap 'rm -f "$t.*"; exit' 0 1 2 3 15
10
+
11
+_x40="[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]"
12
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
13
+
14
+log_prune () {
15
+ cp "$log" "$log.bak"
16
+
17
+ git for-each-ref --format='%(objectname)' 'refs/heads/*/*' |
18
+ git rev-list --not ko/maint --not --stdin |
19
+ while read commit
20
+ do
21
+ git rev-parse --verify "$commit^{tree}"
22
+ done | sort -u >"$t.tree0"
23
+ sed -ne "s/A \($_x40\) .*/\1/p" "$log" | sort -u >"$t.tree1"
24
+ comm -13 "$t.tree0" "$t.tree1" | sed -e 's|.*|/^A &/d|' >"$t.prune"
25
+
26
+ next=$(git rev-parse --verify "refs/heads/next^0")
27
+ ko_next=$(git rev-parse --verify "refs/remotes/ko/next^0")
28
+ echo "/^N /{
29
+ s/^N $next /&/
30
+ t ok
31
+ s/^N $ko_next /&/
32
+ t ok
33
+ d
34
+ : ok
35
+}" >>"$t.prune"
36
+
37
+ sed -f "$t.prune" "$log" >"$t.pruned"
38
+ cat "$t.pruned" >"$log"
39
+}
40
+
41
+check_skip_test () {
42
+ GIT_SKIP_TESTS=
43
+ git diff --name-only ko/master "$1" >"$t.d"
44
+ if ! grep -q -e git-svn "$t.d"
45
+ then
46
+ GIT_SKIP_TESTS="$GIT_SKIP_TESTS t91??"
47
+ fi
48
+ if ! grep -q -e git-cvsexportcommit "$t.d"
49
+ then
50
+ GIT_SKIP_TESTS="$GIT_SKIP_TESTS t9200"
51
+ fi
52
+ if ! grep -q -e git-cvsimport "$t.d"
53
+ then
54
+ GIT_SKIP_TESTS="$GIT_SKIP_TESTS t9600"
55
+ fi
56
+ if test -n "$GIT_SKIP_TESTS"
57
+ then
58
+ export GIT_SKIP_TESTS
59
+ else
60
+ unset GIT_SKIP_TESTS
61
+ fi
62
+}
63
+
64
+autotest () {
65
+ commit=$(git rev-parse --verify "$1^0") &&
66
+ tree=$(git rev-parse --verify "$commit^{tree}") || return 1
67
+ grep -s "^A $tree " "$log" >/dev/null && return 0
68
+ o="$buildlog/$tree"
69
+
70
+ git reset -q --hard HEAD^0 &&
71
+ git checkout -q "$commit^0" || return 1
72
+
73
+ check_skip_test "$tree"
74
+
75
+ PAGER= git show -s --pretty='format:* %h %s%n' "$commit" --
76
+ if ! Meta/Make -pedantic >"$o" 2>&1
77
+ then
78
+ status="build error"
79
+ elif ! Meta/Make -pedantic test >>"$o" 2>&1
80
+ then
81
+ status="test error"
82
+ else
83
+ status=ok
84
+ rm -f "$o"
85
+ fi
86
+ : Meta/Make clean >/dev/null 2>&1
87
+ echo "A $tree $status" >>"$log"
88
+ echo "$status"
89
+}
90
+
91
+append_to_status () {
92
+ if test -z "$status"
93
+ then
94
+ status="$1"
95
+ else
96
+ status="$status; $1"
97
+ fi
98
+}
99
+
100
+nexttest () {
101
+ mb=$(git merge-base "$commit" "$next") || return 1
102
+ test "$mb" = "$commit" && return 0
103
+ grep -s "^N $next $commit " "$log" >/dev/null && return 0
104
+
105
+ branch="${refname#refs/heads/}"
106
+ git reset -q --hard next^0
107
+
108
+ echo "* $branch"
109
+
110
+ status= skip_build=
111
+ if ! git merge "$commit" >/dev/null 2>&1
112
+ then
113
+ conflict_count=$(git ls-files -u |
114
+ sed -e 's/.* //' |
115
+ sort -u |
116
+ xargs grep -e '^<<<<<<< ' |
117
+ wc -l)
118
+ if test $conflict_count = 0
119
+ then
120
+ append_to_status "rerere ok"
121
+ else
122
+ skip_build=t
123
+ append_to_status "conflict $conflict_count"
124
+ fi
125
+ fi
126
+ if test -z "$skip_build"
127
+ then
128
+ o="$buildlog/$commit"
129
+ check_skip_test "$commit"
130
+ if ! Meta/Make -pedantic >"$o" 2>&1
131
+ then
132
+ append_to_status "build error"
133
+ elif ! Meta/Make -pedantic test >>"$o" 2>&1
134
+ then
135
+ append_to_status "test error"
136
+ else
137
+ append_to_status "test ok"
138
+ rm -f "$o"
139
+ fi
140
+ fi
141
+ : Meta/Make clean >/dev/null 2>&1
142
+ echo "N $next $commit $status" >>"$log"
143
+ echo "$status"
144
+}
145
+
146
+loop () {
147
+ Meta/Make clean >/dev/null 2>&1
148
+ git reset --hard -q
149
+ git checkout -q HEAD^0
150
+ next=$(git rev-parse --verify "refs/remotes/ko/next^0")
151
+
152
+ while :
153
+ do
154
+ log_prune
155
+
156
+ date
157
+
158
+ l0=$(ls -l "$log")
159
+
160
+ git for-each-ref --format='%(objectname)' 'refs/heads/*/*' |
161
+ git rev-list --not ko/maint ko/master --not --stdin |
162
+ while read commit
163
+ do
164
+ autotest "$commit" || echo "oops?"
165
+ done
166
+
167
+ l1=$(ls -l "$log")
168
+ test "$l0" = "$l1" || continue
169
+
170
+ git for-each-ref --format='%(objectname) %(refname)' \
171
+ 'refs/heads/*/*' |
172
+ while read commit refname
173
+ do
174
+ nexttest "$commit" "$refname" || echo "oops?"
175
+ done
176
+
177
+ l1=$(ls -l "$log")
178
+ test "$l0" = "$l1" || continue
179
+
180
+ sleep 600 || exit
181
+ done
182
+}
183
+
184
+case "$#" in
185
+0)
186
+ loop
187
+ exit ;;
188
+esac
189
+
190
+(
191
+ git rev-list --no-walk "$@" 2>/dev/null || git rev-list "$@"
192
+) |
193
+while read commit
194
+do
195
+ autotest "$commit"
196
+done