Skip to content

Commit

Permalink
Make git_bisect_run_general.sh more general purpose, with pre- and po…
Browse files Browse the repository at this point in the history
…st-commands to run around "ant clean jar".
  • Loading branch information
BanzaiMan committed Jan 23, 2012
1 parent 373629e commit eccec6d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 19 deletions.
72 changes: 64 additions & 8 deletions tool/git_bisect_run_general.sh
Original file line number Diff line number Diff line change
@@ -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}

13 changes: 2 additions & 11 deletions tool/git_bisect_run_mspec.sh
Original file line number Diff line number Diff line change
@@ -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.