Central interface for Turn configuration.
List of file names or globs to exclude from tests
list.
Reporter type.
Test framework, either `:minitest` or `:testunit`. TODO: Is this used any more?
Test against live install (i.e. Don't use loadpath option)
Add these folders to the $LOAD_PATH.
Log results? May be true/false or log file name. (TODO)
Runtime threshold.
Regexp pattern that all test cases must match to be eligible to run.
Report modifier. These act as decorators on the reporter class.
Use natural language case names.
Regexp pattern that all test name's must match to be eligible to run.
Libs to require when running tests.
Run mode, which defaults to `nil`, but can also be `:solo`, `:cross` or `:marshal`.
List of if file names or glob pattern of tests to run.
Enable full backtrace
Verbose output?
# File lib/turn/configuration.rb, line 91 def initialize yield(self) if block_given? initialize_defaults end
# File lib/turn/configuration.rb, line 147 def ansi=(boolean) @ansi = boolean ? true : false end
# File lib/turn/configuration.rb, line 84 def ansi? @ansi end
# File lib/turn/configuration.rb, line 212 def decorate_reporter(reporter) if mode decorator_class.new(reporter) else reporter end end
# File lib/turn/configuration.rb, line 221 def decorator_class return nil unless mode class_name = mode.to_s.capitalize + "Decorator" path = "turn/decorators/#{mode}_decorator" [File.expand_path('~'), Dir.pwd].each do |dir| file = File.join(dir, ".turn", "decorators", "#{mode}_reporter.rb") path = file if File.exist?(file) end require path Turn.const_get(class_name) end
# File lib/turn/configuration.rb, line 258 def environment_ansi case ENV['ansi'] when 'true','yes','on' true when 'false','no','off' false else nil end end
# File lib/turn/configuration.rb, line 243 def environment_format ENV['rpt'] end
# File lib/turn/configuration.rb, line 248 def environment_mode ENV['mode'] end
# File lib/turn/configuration.rb, line 253 def environment_trace (ENV['backtrace'] ? ENV['backtrace'].to_i : nil) end
# File lib/turn/configuration.rb, line 159 def exclude=(paths) @exclude = list_option(paths) end
Test files.
# File lib/turn/configuration.rb, line 168 def files @files ||= ( fs = tests.map do |t| File.directory?(t) ? Dir[File.join(t, '**', '*')] : Dir[t] end fs = fs.flatten.reject{ |f| File.directory?(f) } ex = exclude.map do |x| File.directory?(x) ? Dir[File.join(x, '**', '*')] : Dir[x] end ex = ex.flatten.reject{ |f| File.directory?(f) } (fs - ex).uniq.map{ |f| File.expand_path(f) } ).flatten end
# File lib/turn/configuration.rb, line 74 def live? @live end
# File lib/turn/configuration.rb, line 155 def loadpath=(paths) @loadpath = list_option(paths) end
# File lib/turn/configuration.rb, line 79 def natural? @natural end
Get selected reporter with any mode decorator.
# File lib/turn/configuration.rb, line 190 def reporter @reporter ||= decorate_reporter(reporter_class.new($stdout, reporter_options)) end
Load reporter based on output mode and return its class.
# File lib/turn/configuration.rb, line 195 def reporter_class rpt_format = format || :pretty class_name = rpt_format.to_s.capitalize + "Reporter" path = "turn/reporters/#{rpt_format}_reporter" [File.expand_path('~'), Dir.pwd].each do |dir| file = File.join(dir, ".turn", "reporters", "#{rpt_format}_reporter.rb") path = file if File.exist?(file) end require path Turn.const_get(class_name) end
# File lib/turn/configuration.rb, line 238 def reporter_options { :trace=>trace, :natural=>natural?, :verbose=>verbose?, :mark=>mark } end
# File lib/turn/configuration.rb, line 163 def requires=(paths) @requires = list_option(paths) end
TODO: Better name ?
# File lib/turn/configuration.rb, line 185 def suite_name files.map{ |path| File.dirname(path).sub(Dir.pwd+'/','') }.uniq.join(',') end
# File lib/turn/configuration.rb, line 151 def tests=(paths) @tests = list_option(paths) end
# File lib/turn/configuration.rb, line 69 def verbose? @verbose end
# File lib/turn/configuration.rb, line 97 def initialize_defaults @loadpath ||= ['lib'] @tests ||= ["test/**/{test,}*{,test}.rb"] @exclude ||= [] @requires ||= [] @live ||= false @log ||= true #@runner ||= RUBY_VERSION >= "1.9" ? MiniRunner : TestRunner @matchcase ||= nil @pattern ||= /.*/ @natural ||= false @verbose ||= false @format ||= environment_format @mode ||= environment_mode @trace ||= environment_trace @ansi ||= environment_ansi @files = nil # reset files just in case end
# File lib/turn/configuration.rb, line 134 def list_option(list) case list when nil [] when Array list else list.split(/[:;]/) end end