#!/bin/sh : ${RANGE:=origin/master..origin/seen} ${J:=j32} ${OKNG:="(OK|NG)"} test_it () { type=$1 commit=$2 subject=$3 log=".Cycle/log.$commit" rm -f "$log" git ls-files -x Meta -x .Cycle -o -z | xargs -r -0 rm -rf ( echo "*** log for $subject ***" && case "$type" in C) # Single parent commit on a topic Meta/Make -$J && Meta/Make -$J -- SPARSE_FLAGS=-Wsparse-error sparse ;; M) # Merges on the first-parent chain on seen Meta/Make -$J -- SPARSE_FLAGS=-Wsparse-error sparse && Meta/Make -$J -- test ;; T) # Commit at the tip of a topic Meta/Make -$J SANITIZE=address,undefined -- test && Meta/Make -$J -- doc ;; esac status=$? # Does 'distclean' clean them up properly? Meta/Make -- $D distclean >/dev/null case $(git ls-files -x Meta -x .Cycle -o | wc -l) in 0) exit "$status" ;; *) git ls-files -x Meta -x .Cycle -o exit 1 ;; esac ) >"$log" 2>&1 case $? in 0) rm -f "$log" ;; *) return 1 ;; esac } tested () { # sign=$1 commit=$2 egrep "^$OKNG $1($2|$(git rev-parse "$2^{tree}"))" .Cycle/log >/dev/null } test_them () { while read merge parent sides do case "$parent" in ?*) tested M $merge && continue echo "TEST M $merge" for tip in $sides do git rev-parse --verify --quiet "$tip" || continue tested T $tip && continue echo "TEST $tip $merge" done ;; '') commit=$merge git rev-parse --verify --quiet "$commit" || continue tested C $commit && continue echo "TEST C $commit" esac done | sed -n -e 's/^TEST //p' >.Cycle/plan count=$(wc -l <.Cycle/plan) case $count in 0) return ;; esac total=$count echo TEST $count ON $(date) >>.Cycle/log while read tip merge do case "$tip" in M) type=M commit=$merge subject=$(git show -s --format="%s" "$commit") ;; C) type=C commit=$merge subject=$(git show -s --format="%s" "$commit") ;; *) type=T commit=$tip subject=$( git show -s --format="%s" "$merge" | sed -e 's/^Merge branch '\''\(.*\)'\'' into .*/\1/' ) ;; esac echo >&2 -n "$count/$total ?? $subject " if test_it $type $commit "$subject" then OK=OK else OK=NG fi echo "$OK $type$commit $count" >>.Cycle/log echo "$OK $type$(git rev-parse $commit^{tree}) $count" >>.Cycle/log echo >&2 "$count/$total $OK $subject" count=$(( $count - 1 )) done <.Cycle/plan } : >>.Cycle/log git reflog expire --expire=now --expire-unreachable=now --all git gc for l in .Cycle/log.[0-9a-f]* do x=${l##*.} git rev-parse --verify "$x" >/dev/null 2>&1 || rm -f "$l" done git fetch ( git rev-list --no-merges $RANGE git rev-list --first-parent --parents $RANGE ) | test_them