Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 122 lines (95 sloc) 2.935 kb
#!/usr/bin/env ruby
# -*- ruby -*-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib/')
require 'mac_bacon'
require 'optparse'
automatic = false
output = 'SpecDoxOutput'
opts = OptionParser.new("", 24, ' ') { |opts|
opts.banner = "Usage: macbacon [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 "macbacon options:"
opts.on("-s", "--specdox", "do AgileDox-like output (default)") {
output = 'SpecDoxOutput'
}
opts.on("-q", "--quiet", "do Test::Unit-like non-verbose output") {
output = 'TestUnitOutput'
}
opts.on("-p", "--tap", "do TAP (Test Anything Protocol) output") {
output = 'TapOutput'
}
opts.on("-k", "--knock", "do Knock output") {
output = 'KnockOutput'
}
opts.on("-o", "--output FORMAT",
"do FORMAT (SpecDox/TestUnit/Tap) output") { |format|
output = format + "Output"
}
opts.on("-Q", "--no-backtrace", "don't print backtraces") {
Bacon.bactrackes = false
}
opts.on("-c", "--concurrent", "runs multiple specs concurrently on multiple GCD threads") {
Bacon.concurrent = true
}
opts.on("-a", "--automatic", "gather tests from ./test/, include ./lib/") {
$LOAD_PATH.unshift "ext" if File.directory? "ext"
$LOAD_PATH.unshift "lib" if File.directory? "lib"
automatic = true
}
opts.on('-n', '--name NAME', String,
"runs tests matching regexp NAME") { |n|
Bacon.restrict_name = Regexp.new(n)
}
opts.on('-t', '--testcase TESTCASE', String,
"runs tests in TestCases matching regexp TESTCASE") { |t|
Bacon.restrict_context = Regexp.new(t)
}
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
puts "macbacon #{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"]
files.concat Dir["spec/**/*_spec.rb"]
end
if files.empty?
puts opts.banner
exit 1
end
Bacon.extend Bacon.const_get(output) rescue abort "No such formatter: #{output}"
files.each { |file|
load file
}
Bacon.run
Jump to Line
Something went wrong with that request. Please try again.