monotone

monotone Mtn Source Tree

Root/contrib/bisect.sh

  • Property mtn:execute set to true
1#!/bin/sh
2
3# Script to automate use of 'mtn bisect'.
4
5usage () {
6 echo Usage: $0 --build '"foo"' --test '"bar"' [ --quiet ] >&2
7 printf "\t--build command used to build (probably 'make')\n" >&2
8 printf "\t--test command used to test, success/failure determined from\n\t\t exit code\n" >&2
9 printf "\t--quiet Hide build/test output, and instead show 'mtn bisect\n\t\t status' once per iteration\n" >&2
10 echo You need to mark at least one good and one bad revision manually before >&2
11 echo running this, with "'mtn bisect good'" and "'mtn bisect bad'" >&2
12 echo You probably also want to run "'mtn bisect reset'" when you"'"re done. >&2
13 exit 1
14}
15
16status () {
17 TMP=/tmp/bisect.$$
18 mtn bisect status 2>$TMP
19 RET=$?
20 if grep -q 'to start search' $TMP; then
21RET=1
22 fi
23 if grep -q ' 0 remaining' $TMP; then
24RET=1
25 fi
26 if [ $RET -ne 0 ]; then
27cat $TMP
28 fi
29 rm $TMP
30 return $RET
31}
32
33QUIET=false
34
35while [ $# -gt 0 ]; do
36 case $1 in
37--build)
38 shift;
39 BUILD="$1";;
40--test)
41 shift;
42 TEST="$1";;
43--quiet)
44 QUIET=true;;
45*)
46 usage;;
47 esac
48 shift
49done
50
51if [ -z "$BUILD" -o -z "$TEST" ]; then
52 usage
53fi
54
55# Make sure there's actually a bisection in progress
56status || exit 1
57
58if $QUIET; then
59 exec 3>&1
60 exec >/dev/null 2>/dev/null
61else
62 exec 3>/dev/null
63fi
64
65while status; do
66 mtn bisect status >&3 2>&3
67 (eval $BUILD)
68 if [ $? -ne 0 ]; then
69# fail build
70mtn bisect skip
71 else
72# build OK
73(eval $TEST)
74if [ $? -ne 0 ]; then
75 # test fail
76 mtn bisect bad
77else
78 # test OK
79 mtn bisect good
80fi
81 fi
82done

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status