class Detroit::Turn
The Turn
tool your TestUnit or MiniTest unit tests using Turn
.
NOTE: This tool currently shells out to the command line.
Constants
- DEFAULT_TESTS
Default test file patterns.
Attributes
exclude[R]
Test file patterns to specially exclude.
live[RW]
Test against live install (i.e. Don’t use loadpath option).
loadpath[R]
Add these folders to the $LOAD_PATH.
log[RW]
Either a log file name or true
/false
.
requires[R]
Libs to require when running tests.
tests[RW]
File glob pattern of tests to run.
Public Class Methods
man_page()
click to toggle source
# File lib/detroit-turn.rb, line 192 def self.man_page File.dirname(__FILE__)+'/../man/detroit-turn.5' end
Public Instance Methods
assemble(station, options={})
click to toggle source
# File lib/detroit-turn.rb, line 67 def assemble(station, options={}) case station when :test run end end
assemble?(station, options={})
click to toggle source
# File lib/detroit-turn.rb, line 59 def assemble?(station, options={}) case station when :test true end end
exclude=(val)
click to toggle source
Special writer to ensure the value is a list.
# File lib/detroit-turn.rb, line 43 def exclude=(val) @exclude = val.to_list end
loadpath=(val)
click to toggle source
Special writer to ensure the value is a list.
# File lib/detroit-turn.rb, line 38 def loadpath=(val) @loadpath = val.to_list end
logfile()
click to toggle source
# File lib/detroit-turn.rb, line 78 def logfile case log when String project.log + log else project.log + 'turn.log' end end
requires=(val)
click to toggle source
Special writer to ensure the value is a list.
# File lib/detroit-turn.rb, line 48 def requires=(val) @requires = val.to_list end
Also aliased as: require=
run()
click to toggle source
# File lib/detroit-turn.rb, line 88 def run run_tests end
Private Instance Methods
initialize_defaults()
click to toggle source
Setup default attribute values.
# File lib/detroit-turn.rb, line 95 def initialize_defaults @loadpath = metadata.loadpath @tests = DEFAULT_TESTS @exclude = [] @reqiures = [] @live = false end
initialize_requires()
click to toggle source
# File lib/detroit-turn.rb, line 186 def initialize_requires #require 'turn/command' end
run_tests()
click to toggle source
Run unit tests. Unlike test-solo and test-cross this loads all tests and runs them together in a single process.
Note that this shells out to the testrb program.
TODO: Generate a test log entry?
# File lib/detroit-turn.rb, line 129 def run_tests tests = self.tests exclude = self.exclude loadpath = self.loadpath requires = self.requires live = self.live #log = options['log'] != false #logfile = File.join('log', apply_naming_policy('test', 'log')) # what about arguments for selecting specific tests? #tests = EVN['TESTS'] if ENV['TESTS'] #unless live # loadpath.each do |lp| # $LOAD_PATH.unshift(File.expand_path(lp)) # end #end files = multiglob_r(*tests) - multiglob_r(*exclude) if files.empty? report "WARNING: NO TESTS TO RUN" return end filelist = files.select{|file| !File.directory?(file) } argv = [] if !live argv.concat ['-I', loadpath.join(':')] end # TODO: Use a subdirectory for log? # TODO: Does turn logging work? if log argv.concat ['--log', logfile] end argv.concat filelist command = "turn " + argv.join(' ') trace command # TODO: Make sure turn returns a failing exist code if tests fail. success = sh(command) #, :show=>true) # TODO: Why can't we do this? It just says 'No tests'. #begin # success = ::Turn::Command.main(*argv) #rescue SystemExit => err #end end