Raw
1 #!/bin/sh
2
3 NWD=contrib/workdir/git-new-workdir
4 MASTER=master
5
6 section () {
7 printf "\033]0;%s %s\007" "$branch" "$*"
8
9 printf "\n\n\n"
10 printf "############ %s %s\n" "$branch" "$*"
11 printf "\n\n\n"
12 }
13
14 inst_prefix=$(
15 IFS=:
16 for p in $PATH
17 do
18 probed=${p%/git-active/bin}
19 if test "$probed" != "$p"
20 then
21 echo "$probed"
22 exit
23 fi
24 done
25 echo $HOME
26 )
27
28 force= with_dash= test_long= M= install= doc= notest= bootstrap= branches= jobs=
29 scratch= noprove= memtrash=--memtrash with_cocci= with_leaks= with_sha256= san=
30 clean= with_meson= breaking= test_vars=
31
32 while case "$1" in
33 --pedantic | --locale=* | --loose) M="$M $1" ;;
34 --force) force=$1 ;;
35 --dash) with_dash=y ;;
36 --clean) clean=y ;;
37 --cocci) with_cocci=y ;;
38 --no-cocci) with_cocci= ;;
39 --long) test_long=--long ;;
40 --noinstall) install=noinstall ;;
41 --nodoc) doc=no ;;
42 --asciidoc) doc=asciidoc ;;
43 --asciidoctor) doc=ascidoctor ;;
44 --notest) notest=y ;;
45 --nomemtrash) memtrash= ;;
46 --memtrash) memtrash=--memtrash ;;
47 --test=*) test="$1" ;;
48 --scratch) scratch=y ;;
49 --breaking) breaking=breaking ;;
50 --no-breaking) breaking= ;;
51 --bootstrap) bootstrap=y ;;
52 --base=*) BUILDBASE=${1#*=} ;;
53 --branches=*) branches=${1#*=} ;;
54 --noprove) noprove=$1 ;;
55 --san) san=t ;;
56 --no-san) san= ;;
57 --leaks) with_leaks=t ;;
58 --no-leaks) with_leaks= ;;
59 --sha256) with_sha256=t ;;
60 --no-sha256) with_sha256= ;;
61 --meson) with_meson=t ;;
62 --test-vars) test_vars=test_vars ;;
63 -j*) jobs=$1 ;;
64 --) shift; break ;;
65 -*) echo >&2 "Unknown option: $1"; exit 1 ;;
66 *) break ;;
67 esac
68 do
69 shift
70 done
71
72 if test -n "$doc"
73 then
74 : ;# happy with whatever specified
75 elif sh -c 'asciidoc --version >/dev/null 2>&1'
76 then
77 doc=asciidoc
78 elif sh -c 'asciidoctor --version >/dev/null 2>&1'
79 then
80 doc=asciidoctor
81 else
82 doc=no
83 fi
84
85 if test "$doc" = asciidoctor
86 then
87 USE_ASCIIDOCTOR=YesPlease
88 else
89 USE_ASCIIDOCTOR=
90 fi
91
92 GIT_TEST_CHAIN_LINT=1
93 export GIT_TEST_CHAIN_LINT
94
95 GIT_PROVE_OPTS="${GIT_PROVE_OPTS:+$GIT_PROVE_OPTS }--state=slow,save"
96 export GIT_PROVE_OPTS
97
98 TEST_CONTRIB_TOO=YesPlease
99 export TEST_CONTRIB_TOO
100
101 test -f /bin/dash || with_dash=
102 if test -z "$BUILDBASE"
103 then
104 if test -d "$inst_prefix/buildfarm"
105 then
106 BUILDBASE="$inst_prefix/buildfarm"
107 elif test -d "../buildfarm"
108 then
109 BUILDBASE=../buildfarm
110 else
111 echo >&2 "Buildbase unknown"
112 exit 1
113 fi
114 fi
115 test -n "$branches" || branches="next $MASTER maint jch seen"
116 test -n "$jobs" || jobs=-j32
117
118 find_installed () {
119 branch=$1
120 test -f "$inst_prefix/git-$branch/bin/git" &&
121 installed=$($inst_prefix/git-$branch/bin/git version) &&
122 if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
123 then
124 :
125 elif version=v$(expr "$installed" : \
126 'git version \(.*\)\.rc[0-9]*$')
127 then
128 version="$version"-$(expr "$installed" : \
129 'git version .*\.\(rc[0-9]*\)$')
130 else
131 version=v$(expr "$installed" : 'git version \(.*\)')
132 fi &&
133 git rev-parse --verify "$version^0" 2>/dev/null
134 }
135
136 installed_source_trees=" "
137 for branch in $branches
138 do
139 if v=$(find_installed $branch) &&
140 test -n "$v" &&
141 v=$(git rev-parse --verify "$v^{tree}" 2>/dev/null)
142 then
143 installed_source_trees="$installed_source_trees$v "
144 fi
145 done
146
147 for branch in $branches
148 do
149 echo "** $branch **"
150 revision=$(git show-ref -s --verify "refs/heads/$branch") || {
151 echo "** No $branch"
152 continue
153 }
154
155 if test ! -d "$BUILDBASE/$branch"
156 then
157 if test -z "$bootstrap"
158 then
159 echo "** No $BUILDBASE/$branch"
160 continue
161 fi
162 "$NWD" . "$BUILDBASE/$branch" $branch &&
163 ln -s "$(pwd)/Meta" "$BUILDBASE/$branch/Meta" || {
164 echo "** Failed to bootstrap $BUILDBASE/$branch"
165 continue
166 }
167 fi
168
169 version=$(find_installed $branch)
170 if test "z$version" = "z$revision"
171 then
172 echo "* up-to-date version is already installed from $branch"
173 test -n "$force" || continue
174 fi
175
176 private=$(git rev-parse -q --verify private-$branch 2>/dev/null)
177 case $? in 0|1) ;; *) exit $? ;; esac
178
179 vtree=$(git rev-parse --verify "$version^{tree}")
180 rtree=$(git rev-parse --verify "$revision^{tree}")
181 (
182 skip_test=$notest
183 case "$doc" in no) skip_doc=1 ;; *) skip_doc= ;; esac
184 case "$force" in
185 ?*)
186 ;;
187 '')
188 for xtree in $installed_source_trees $vtree
189 do
190 if test "z$xtree" = "z$rtree" ||
191 git diff --quiet "$xtree" "$rtree" -- . \
192 ':!GIT-VERSION-GEN' \
193 ':!RelNotes' \
194 ':!Documentation/'
195 then
196 skip_test=1
197 break
198 fi
199 done
200
201 dvtree=$(git rev-parse --verify "$version:Documentation/")
202 drtree=$(git rev-parse --verify "$revision:Documentation/")
203 if test "z$dvtree" = "z$drtree"
204 then
205 skip_doc=1
206 fi
207 ;;
208 esac
209
210 case "$skip_test" in
211 ?*) dotest= ;;
212 '') dotest=test ;;
213 esac
214
215 cd "$BUILDBASE/$branch"
216 git reset --hard &&
217
218 case "$scratch$clean" in
219 '')
220 ;;
221 *y*)
222 saveMeta=$(readlink Meta)
223 Meta/Make distclean
224 git clean -f -x -d
225 ln -s "$saveMeta" Meta
226 ;;
227 esac &&
228
229 case "$(git symbolic-ref HEAD)" in
230 "refs/heads/$branch")
231 : ;;
232 *)
233 git checkout "$branch" &&
234 git reset --hard || exit
235 esac &&
236
237 case "$clean" in
238 y) exit 0 ;;
239 esac &&
240
241 case "$private" in
242 '')
243 ;;
244 ?*)
245 git merge --squash --no-commit "$private" || {
246 echo >&2 "** Cannot apply private edition changes"
247 git reset --hard
248 }
249 ;;
250 esac &&
251
252 save=$(git rev-parse HEAD) &&
253
254 if test -n "$with_meson" && test -f "meson.build"
255 then
256 section meson
257 rm -fr "../.$branch.boson" &&
258 meson setup "../.$branch.boson" &&
259 (
260 cd "../.$branch.boson" &&
261 meson compile &&
262 meson test
263 ) || exit $?
264 fi &&
265
266 # cocci
267 if test -n "$with_cocci"
268 then
269 section coccicheck
270 Meta/Make $M $jobs -- coccicheck
271 fi &&
272
273 # sparse
274 section sparse
275 Meta/Make $M $jobs -- NO_REGEX=NoThanks \
276 SPARSE_FLAGS=-Wsparse-error sparse &&
277 rm -f compat/regex/regex.o &&
278
279 # hdr
280 section hdr-check
281 Meta/Make $M $jobs -- hdr-check &&
282
283 # test-lint
284 section test-lint
285 Meta/Make -- -C t test-lint &&
286
287 did_test=
288 if test -n "$san"
289 then
290 section SANITIZE=address,undefined
291 did_test=did_test
292 SANITIZE=address,undefined Meta/Make $M $jobs $T test &&
293 rm -f compat/mmap.o &&
294 Meta/Make >/dev/null distclean
295 fi &&
296 if test -n "$with_leaks"
297 then
298 section leaks
299 did_test=did_test
300 SANITIZE=leak \
301 GIT_TEST_PASSING_SANITIZE_LEAK=true \
302 Meta/Make $jobs $T CC=clang test &&
303 Meta/Make >/dev/null distclean
304 fi &&
305 if test -n "$with_sha256"
306 then
307 section sha256
308 did_test=did_test
309 GIT_TEST_DEFAULT_HASH=sha256 Meta/Make $jobs $T test
310 fi &&
311 if test -n "$test_vars"
312 then
313 section "test vars"
314 did_test=did_test
315 (
316 export OPENSSL_SHA1_UNSAFE=YesPlease
317 export GIT_TEST_SPLIT_INDEX=yes
318 export GIT_TEST_FULL_IN_PACK_ARRAY=true
319 export GIT_TEST_OE_SIZE=10
320 export GIT_TEST_OE_DELTA_SIZE=5
321 export GIT_TEST_COMMIT_GRAPH=1
322 export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
323 export GIT_TEST_MULTI_PACK_INDEX=1
324 export GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=1
325 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
326 export GIT_TEST_NO_WRITE_REV_INDEX=1
327 export GIT_TEST_CHECKOUT_WORKERS=2
328 export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
329 Meta/Make >/dev/null distclean &&
330 Meta/Make $jobs $T test &&
331 Meta/Make >/dev/null distclean
332 )
333 fi &&
334 if test -n "$breaking"
335 then
336 section breaking
337 did_test=did_test
338 Meta/Make >/dev/null distclean &&
339 Meta/Make $jobs WITH_BREAKING_CHANGES=YesPlease $T test &&
340 Meta/Make >/dev/null distclean
341 fi &&
342
343 if test "$did_test$dotest" = test
344 then
345 section test
346 Meta/Make $M $noprove ${test+"$test"} $jobs $test_long \
347 $memtrash \
348 -- ${with_dash:+SHELL_PATH=/bin/dash} "$@" $T $dotest
349 fi &&
350
351 # docs
352 {
353 test -n "$skip_doc" ||
354 if test "$save" = "$(git rev-parse HEAD)"
355 then
356 section docs
357 Meta/Make $M $jobs -- check-docs &&
358 Meta/Make $M $jobs -- $USE_ASCIIDOCTOR doc &&
359 Meta/Make $M -- install-man install-html
360 else
361 echo >&2 "Head moved--not installing docs"
362 fi
363 } &&
364
365 {
366 test z$install = znoinstall ||
367 if test "$save" = "$(git rev-parse HEAD)"
368 then
369 section install
370 Meta/Make >/dev/null distclean &&
371 Meta/Make $jobs $M \
372 -- ${with_dash:+SHELL_PATH=/bin/dash} "$@" install
373 else
374 echo >&2 "Head moved--not installing"
375 fi
376 } || exit $?
377
378 git reset --hard
379 ) </dev/null || exit $?
380
381 installed_source_trees="$installed_source_trees$rtree "
382 done