Permalink
Browse files

Make git_bisect_run_general.sh more general purpose, with pre- and po…

…st-commands to run around "ant clean jar".
  • Loading branch information...
BanzaiMan committed Jan 23, 2012
1 parent 373629e commit eccec6d183ef252ea864336c5ea22169afadbc92
Showing with 66 additions and 19 deletions.
  1. +64 −8 tool/git_bisect_run_general.sh
  2. +2 −11 tool/git_bisect_run_mspec.sh
@@ -1,16 +1,72 @@
-#! /bin/sh
+#! /bin/bash
# simple script for use with 'git bisect run'
-# e.g., git bisect run tool/git_bisect_run_mspec.sh <args>
-# arguments will be passed on to jruby
+# e.g., git bisect run tool/git_bisect_run.sh -T--1.9 spec/ruby/language/defined_spec.rb
+
+PRE_COMMAND=''
+POST_COMMAND=''
+COMMAND='-v' # an empty $COMMAND will put the script in interactive mode, which may be confusing
+V=''
+
+function print_usage {
+ echo "usage: $0 [-c command] [-p pre] [-P post] [-v]"
+}
+
+function build {
+ ant clean jar
+ if [ $? -gt 0 ]; then
+ exit 125
+ fi
+}
+
+function print_var {
+ if [[ -n $V ]]; then
+ eval "VAR=\$$1"
+ echo "$1: $VAR"
+ fi
+}
+
+# opts
+while getopts "c:hp:P:v" opt; do
+ case $opt in
+ c)
+ COMMAND=${OPTARG}
+ if [[ -z $COMMAND ]]; then
+ echo "COMMAND is empty. Aborting."
+ exit 1
+ fi
+ ;;
+ h)
+ print_usage
+ exit 0
+ ;;
+ p)
+ PRE_COMMAND=${OPTARG}
+ ;;
+ P)
+ POST_COMMAND=${OPTARG}
+ ;;
+ v)
+ V='VERBOSE'
+ ;;
+ esac
+done
cd `dirname $0`/..
if [ ! -e spec/mspec ]; then
ant fetch-stable-specs
fi
-ant clean jar
-if [ $? -gt 0 ]; then
- exit 125
-fi
-./bin/jruby $*
+print_var 'PRE_COMMAND'
+${PRE_COMMAND}
+
+build
+
+print_var 'COMMAND'
+./bin/jruby ${COMMAND}
+EXIT_STATUS=$?
+
+print_var 'POST_COMMAND'
+${POST_COMMAND}
+exit ${EXIT_STATUS}
+
@@ -1,13 +1,4 @@
#! /bin/sh
-# simple script for use with 'git bisect run'
-# e.g., git bisect run tool/git_bisect_run_mspec.sh -T--1.9 spec/ruby/language/defined_spec.rb
-# arguments will be passed on to mspec.
-
-cd `dirname $0`/..
-if [ ! -e spec/mspec ]; then
- ant fetch-stable-specs
-fi
-
-ant clean jar
-jruby spec/mspec/bin/mspec $*
+# see git_bisect_run_general.sh for more explanation
+exec `dirname $0`/git_bisect_run_general.sh -c "spec/mspec/bin/mspec $*"

0 comments on commit eccec6d

Please sign in to comment.