Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add pycat, minitest runner and rcogr

  • Loading branch information...
commit fbb189e6f4bdc8a6d92b7195f55a5626004b419e 1 parent 218a200
@txus txus authored
Showing with 119 additions and 0 deletions.
  1. +44 −0 bin/minitest
  2. +11 −0 bin/pycat
  3. +64 −0 bin/run-command-on-git-revisions
View
44 bin/minitest
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -e
+shopt -s globstar
+
+# Public: Resolves files to be run by the test runner.
+#
+# path - Can be either a test file, or a directory that contains tests at any
+# depth.
+#
+# Returns a glob expression.
+resolve_files ()
+{
+ if [[ $1 =~ .rb$ ]] ; then
+ # if provided a file ending in .rb execute a single test
+ echo $1
+ elif [[ -n "$1" ]] ; then
+ # if provided any other argument execute all tests under one folder
+ for file in $1/**/*_test.rb
+ do
+ echo " -r./$file"
+ done
+ else
+ # run all tests by default
+ for file in test/**/*_test.rb
+ do
+ echo " -r./$file"
+ done
+ fi
+}
+
+# Handle -h argument and show usage banner
+while getopts :h o
+do
+ case "$o" in
+ h) echo "Usage: $0 file_or_path"
+ exit 1;
+ esac
+done
+
+# Run the tests!
+path=$(resolve_files $1)
+
+echo $path
+env ruby -e\"nil\" -Ilib:test -rminitest/autorun $path
View
11 bin/pycat
@@ -0,0 +1,11 @@
+#!/bin/bash
+if [ ! -t 0 ];then
+ file=/dev/stdin
+elif [ -f $1 ];then
+ file=$1
+else
+ echo "Usage: $0 code.c"
+ echo "or e.g. head code.c|$0"
+ exit 1
+fi
+pygmentize -f terminal -g $file
View
64 bin/run-command-on-git-revisions
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# This script runs a given command over a range of Git revisions. Note that it
+# will check past revisions out! Exercise caution if there are important
+# untracked files in your working tree.
+#
+# This came from Gary Bernhardt's dotfiles:
+# https://github.com/garybernhardt/dotfiles
+#
+# Example usage:
+# $ run-command-on-git-revisions origin/master master 'python runtests.py'
+
+set -e
+
+if [[ $1 == -v ]]; then
+ verbose=1
+ shift
+fi
+start_ref=$1
+end_ref=$2
+test_command=$3
+
+main() {
+ enforce_usage
+ run_tests
+}
+
+enforce_usage() {
+ if [ -z "$test_command" ]; then
+ usage
+ exit $E_BADARGS
+ fi
+}
+
+usage() {
+ echo "usage: `basename $0` start_ref end_ref test_command"
+}
+
+run_tests() {
+ revs=`log_command git rev-list --reverse ${start_ref}..${end_ref}`
+
+ for rev in $revs; do
+ debug "Checking out: $(git log --oneline -1 $rev)"
+ log_command git checkout --quiet $rev
+ log_command $test_command
+ log_command git reset --hard
+ done
+ log_command git checkout --quiet $end_ref
+ debug "OK for all revisions!"
+}
+
+log_command() {
+ debug "=> $*"
+ eval $*
+}
+
+debug() {
+ if [ $verbose ]; then
+ echo $* >&2
+ fi
+}
+
+main
+
Please sign in to comment.
Something went wrong with that request. Please try again.