diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2007-05-31 14:18:00 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2007-05-31 14:18:00 +0200 |
commit | f2c89a8c06919e82b17145392a68e0cd402e6c0b (patch) | |
tree | 13fa0d3a1da3c018265eb050bb8619386b54b36e | |
parent | 5cb7e3156507e000c747aab0b981e9ee2bb636c5 (diff) | |
download | bacon-f2c89a8c06919e82b17145392a68e0cd402e6c0b.tar.gz bacon-f2c89a8c06919e82b17145392a68e0cd402e6c0b.tar.xz bacon-f2c89a8c06919e82b17145392a68e0cd402e6c0b.zip |
Add standalone runner, bin/bacon
darcs-hash:20070531121800-4fc50-d453e659c8055bbbab8e381c1632007d55869bc4.gz
-rwxr-xr-x | bin/bacon | 98 | ||||
-rw-r--r-- | lib/bacon.rb | 3 |
2 files changed, 101 insertions, 0 deletions
diff --git a/bin/bacon b/bin/bacon new file mode 100755 index 0000000..404ceb5 --- /dev/null +++ b/bin/bacon @@ -0,0 +1,98 @@ +#!/usr/bin/env ruby +# -*- ruby -*- + +require 'optparse' + +automatic = false + +opts = OptionParser.new("", 24, ' ') { |opts| + opts.banner = "Usage: bacon [options] [files | -a] [-- untouched arguments]" + + opts.separator "" + opts.separator "Ruby options:" + + lineno = 1 + opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line| + eval line, TOPLEVEL_BINDING, "-e", lineno + lineno += 1 + } + + opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") { + $DEBUG = true + } + opts.on("-w", "--warn", "turn warnings on for your script") { + $-w = true + } + + opts.on("-I", "--include PATH", + "specify $LOAD_PATH (may be used more than once)") { |path| + $LOAD_PATH.unshift(*path.split(":")) + } + + opts.on("-r", "--require LIBRARY", + "require the library, before executing your script") { |library| + require library + } + + opts.separator "" + opts.separator "bacon options:" + + opts.on("-s", "--specdox", "do AgileDox-like output (default)") { } + opts.on("-q", "--quiet", "do Test::Unit-like non-verbose output") { + # TODO + } + + opts.on("-a", "--automatic", "gather tests from ./test/, include ./lib/") { + $LOAD_PATH.unshift "lib" if File.directory? "lib" + automatic = true + } + + opts.on('-n', '--name NAME', String, + "runs tests matching regexp NAME") { |n| + # TODO + } + + opts.on('-t', '--testcase TESTCASE', String, + "runs tests in TestCases matching regexp TESTCASE") { |t| + # TODO + } + + opts.separator "" + opts.separator "Common options:" + + opts.on_tail("-h", "--help", "Show this message") do + puts opts + exit + end + + opts.on_tail("--version", "Show version") do + require 'bacon' + puts "bacon #{Bacon::VERSION}" + exit + end + + opts.parse! ARGV +} + +files = ARGV + +if automatic + files.concat Dir["test/test_*.rb"] + files.concat Dir["test/spec_*.rb"] + files.concat Dir["spec/spec_*.rb"] +end + +if files.empty? + puts opts.banner + exit 1 +end + +require 'bacon' + +files.each { |file| + load file +} + +puts Bacon::ErrorLog +puts Bacon.result_string +p Bacon::Counter diff --git a/lib/bacon.rb b/lib/bacon.rb index 200aab9..df2cee6 100644 --- a/lib/bacon.rb +++ b/lib/bacon.rb @@ -1,6 +1,9 @@ # Bacon -- small RSpec clone. +# "Truth will sooner come out from error than from confusion." ---Francis Bacon module Bacon + VERSION = "0.2" + Counter = Hash.new(0) ErrorLog = "" |