monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: 81b1f0ed293ff2b8a0c0329fc4


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: 81b1f0ed293ff2b8a0c0329fc400a2809ebb37d5
Date: Sat, 27 Nov 2010 23:37:04 GMT

revision:            81b1f0ed293ff2b8a0c0329fc400a2809ebb37d5
date:                2010-11-27T23:36:51
author:              Timothy Brownawell  <address@hidden>
branch:              net.venge.monotone
changelog:
Running 'mtn bisect' manually is a pain. This is a script
to automate it.

manifest:
format_version "1"

new_manifest [aab3797fd3903777bfa57b53a5bdcfea58160b89]

old_revision [07b91bd7bb49a7ef5d09d1eac37ac4bbee5c0f03]

add_file "contrib/bisect.sh"
 content [d804602c7dad25f424c43b1b5daf9102892ab8a9]

  set "contrib/bisect.sh"
 attr "mtn:execute"
value "true"
============================================================
--- /dev/null	
+++ contrib/bisect.sh	d804602c7dad25f424c43b1b5daf9102892ab8a9
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+# Script to automate use of 'mtn bisect'.
+
+usage () {
+    echo Usage: $0 --build '"foo"' --test '"bar"' [ --quiet ] >&2
+    printf "\t--build  command used to build (probably 'make')\n" >&2
+    printf "\t--test   command used to test, success/failure determined from\n\t\t exit code\n" >&2
+    printf "\t--quiet  Hide build/test output, and instead show 'mtn bisect\n\t\t status' once per iteration\n" >&2
+    echo You need to mark at least one good and one bad revision manually before >&2
+    echo running this, with "'mtn bisect good'" and "'mtn bisect bad'" >&2
+    echo You probably also want to run "'mtn bisect reset'" when you"'"re done. >&2
+    exit 1
+}
+
+status () {
+    TMP=/tmp/bisect.$$
+    mtn bisect status 2>$TMP
+    RET=$?
+    if grep -q 'to start search' $TMP; then
+	RET=1
+    fi
+    if grep -q ' 0 remaining' $TMP; then
+	RET=1
+    fi
+    if [ $RET -ne 0 ]; then
+	cat $TMP
+    fi
+    rm $TMP
+    return $RET
+}
+
+QUIET=false
+
+while [ $# -gt 0 ]; do
+    case $1 in
+	--build)
+	    shift;
+	    BUILD="$1";;
+	--test)
+	    shift;
+	    TEST="$1";;
+	--quiet)
+	    QUIET=true;;
+	*)
+	    usage;;
+    esac
+    shift
+done
+
+if [ -z "$BUILD" -o -z "$TEST" ]; then
+    usage
+fi
+
+# Make sure there's actually a bisection in progress
+status || exit 1
+
+if $QUIET; then
+    exec 3>&1
+    exec >/dev/null 2>/dev/null
+else
+    exec 3>/dev/null
+fi
+
+while status; do
+    mtn bisect status >&3 2>&3
+    (eval $BUILD)
+    if [ $? -ne 0 ]; then
+	# fail build
+	mtn bisect skip
+    else
+	# build OK
+	(eval $TEST)
+	if [ $? -ne 0 ]; then
+	    # test fail
+	    mtn bisect bad
+	else
+	    # test OK
+	    mtn bisect good
+	fi
+    fi
+done

reply via email to

[Prev in Thread] Current Thread [Next in Thread]