Class: Zucchini::Runner
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Zucchini::Runner
- Defined in:
- lib/runner.rb
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
Instance Method Summary collapse
- #detect_features(path) ⇒ Object
- #detect_template ⇒ Object
- #detection_error(path) ⇒ Object
- #execute ⇒ Object
- #run ⇒ Object
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
2 3 4 |
# File 'lib/runner.rb', line 2 def features @features end |
Instance Method Details
#detect_features(path) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/runner.rb', line 47 def detect_features(path) features = [] if File.exists?("#{path}/feature.zucchini") features << Zucchini::Feature.new(path) else raise detection_error(path) if Dir["#{path}/*"].empty? Dir.glob("#{path}/*").each do |dir| unless dir.match /support/ if File.exists?("#{dir}/feature.zucchini") features << Zucchini::Feature.new(dir) else raise detection_error(dir) end end end end features end |
#detect_template ⇒ Object
71 72 73 74 75 76 |
# File 'lib/runner.rb', line 71 def detect_template path = `xcode-select -print-path`.gsub(/\n/, '') path += "/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate" raise "Instruments template at #{path} does not exist" unless File.exists? path path end |
#detection_error(path) ⇒ Object
67 68 69 |
# File 'lib/runner.rb', line 67 def detection_error(path) "#{path} is not a feature directory" end |
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/runner.rb', line 10 def execute raise "Directory #{path} does not exist" unless File.exists?(path) @path = File.(path) Zucchini::Config.base_path = File.exists?("#{path}/feature.zucchini") ? File.dirname(path) : path raise "ZUCCHINI_DEVICE environment variable not set" unless ENV['ZUCCHINI_DEVICE'] @device = Zucchini::Config.device(ENV['ZUCCHINI_DEVICE']) @template = detect_template exit run end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/runner.rb', line 24 def run compare_threads = {} features.each do |f| f.device = @device f.template = @template if collect? then f.collect elsif compare? then f.compare else f.collect; compare_threads[f.name] = Thread.new { f.compare } end end compare_threads.each { |name, t| t.abort_on_exception = true; t.join } Zucchini::Report.present(features, ci?) unless (collect? && !compare?) features.inject(true){ |result, feature| result &= feature.succeeded } end |