Class: Turn::Controller
- Inherits:
-
Object
- Object
- Turn::Controller
- Defined in:
- lib/turn/controller.rb
Overview
Controller
– TODO: Add support to test run loggging. ++
Instance Attribute Summary collapse
-
#exclude ⇒ Object
Files globs to specially exclude.
-
#format ⇒ Object
Reporter type.
-
#framework ⇒ Object
Test framework, either :minitest or :testunit.
-
#live ⇒ Object
Test against live install (i.e. Don’t use loadpath option).
-
#loadpath ⇒ Object
Add these folders to the $LOAD_PATH.
-
#log ⇒ Object
Log results? May be true/false or log file name.
-
#pattern ⇒ Object
Regexp pattern that all test name’s must match to be eligible to run.
-
#requires ⇒ Object
Libs to require when running tests.
-
#runmode ⇒ Object
Run mode.
-
#tests ⇒ Object
File glob pattern of tests to run.
-
#verbose ⇒ Object
Verbose output?.
Instance Method Summary collapse
- #files ⇒ Object
- #live? ⇒ Boolean
-
#reporter ⇒ Object
Select reporter based on output mode.
-
#runner ⇒ Object
# Insatance of Runner, selected based on format and runmode.
- #start ⇒ Object
- #verbose? ⇒ Boolean
Instance Attribute Details
#exclude ⇒ Object
Files globs to specially exclude.
20 21 22 |
# File 'lib/turn/controller.rb', line 20 def exclude @exclude end |
#format ⇒ Object
Reporter type.
33 34 35 |
# File 'lib/turn/controller.rb', line 33 def format @format end |
#framework ⇒ Object
Test framework, either :minitest or :testunit
48 49 50 |
# File 'lib/turn/controller.rb', line 48 def framework @framework end |
#live ⇒ Object
Test against live install (i.e. Don’t use loadpath option)
39 40 41 |
# File 'lib/turn/controller.rb', line 39 def live @live end |
#loadpath ⇒ Object
Add these folders to the $LOAD_PATH.
27 28 29 |
# File 'lib/turn/controller.rb', line 27 def loadpath @loadpath end |
#log ⇒ Object
Log results? May be true/false or log file name. (TODO)
42 43 44 |
# File 'lib/turn/controller.rb', line 42 def log @log end |
#pattern ⇒ Object
Regexp pattern that all test name’s must match to be eligible to run.
24 25 26 |
# File 'lib/turn/controller.rb', line 24 def pattern @pattern end |
#requires ⇒ Object
Libs to require when running tests.
30 31 32 |
# File 'lib/turn/controller.rb', line 30 def requires @requires end |
#runmode ⇒ Object
Run mode.
36 37 38 |
# File 'lib/turn/controller.rb', line 36 def runmode @runmode end |
#tests ⇒ Object
File glob pattern of tests to run. Can be an array of files/globs.
17 18 19 |
# File 'lib/turn/controller.rb', line 17 def tests @tests end |
#verbose ⇒ Object
Verbose output?
45 46 47 |
# File 'lib/turn/controller.rb', line 45 def verbose @verbose end |
Instance Method Details
#files ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/turn/controller.rb', line 115 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.(f) } ) end |
#live? ⇒ Boolean
51 |
# File 'lib/turn/controller.rb', line 51 def live? ; @live ; end |
#reporter ⇒ Object
Select reporter based on output mode.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/turn/controller.rb', line 143 def reporter @reporter ||= ( case format when :marshal require 'turn/reporters/marshal_reporter' Turn::MarshalReporter.new($stdout) when :progress require 'turn/reporters/progress_reporter' Turn::ProgressReporter.new($stdout) when :dotted require 'turn/reporters/dot_reporter' Turn::DotReporter.new($stdout) when :pretty require 'turn/reporters/pretty_reporter' Turn::PrettyReporter.new($stdout) when :cue require 'turn/reporters/cue_reporter' Turn::CueReporter.new($stdout) else require 'turn/reporters/outline_reporter' Turn::OutlineReporter.new($stdout) end ) end |
#runner ⇒ Object
# Insatance of Runner, selected based on format and runmode.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/turn/controller.rb', line 169 def runner @runner ||= ( case framework when :minitest require 'turn/runners/minirunner' else require 'turn/runners/testrunner' end case runmode when :marshal if framework == :minitest Turn::MiniRunner else Turn::TestRunner end when :solo require 'turn/runners/solorunner' Turn::SoloRunner when :cross require 'turn/runners/crossrunner' Turn::CrossRunner else if framework == :minitest Turn::MiniRunner else Turn::TestRunner end end ) end |
#start ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/turn/controller.rb', line 129 def start @files = nil # reset files just in case if files.empty? $stderr.puts "No tests." return end testrun = runner.new(self) testrun.start end |
#verbose? ⇒ Boolean
50 |
# File 'lib/turn/controller.rb', line 50 def verbose? ; @verbose ; end |