Class: FlexUtils::TestRunner

Inherits:
Adl
  • Object
show all
Defined in:
lib/flexutils/test_runner.rb

Instance Attribute Summary collapse

Attributes inherited from Adl

#arguments, #descriptor, #height, #swf, #system_chrome, #title, #transparent, #visible, #width, #x, #y

Instance Method Summary collapse

Methods inherited from Adl

#command_string, #generate_descriptor, run

Constructor Details

#initialize(swf) ⇒ TestRunner

Returns a new instance of TestRunner.



8
9
10
11
12
13
# File 'lib/flexutils/test_runner.rb', line 8

def initialize( swf )
  super(swf)

  @fail_on_error    = true
  @exit_on_complete = false
end

Instance Attribute Details

#exit_on_complete=(value) ⇒ Object (writeonly)

Sets the attribute exit_on_complete

Parameters:

  • value

    the value to set the attribute exit_on_complete to.



5
6
7
# File 'lib/flexutils/test_runner.rb', line 5

def exit_on_complete=(value)
  @exit_on_complete = value
end

#fail_on_error=(value) ⇒ Object (writeonly)

Sets the attribute fail_on_error

Parameters:

  • value

    the value to set the attribute fail_on_error to.



5
6
7
# File 'lib/flexutils/test_runner.rb', line 5

def fail_on_error=(value)
  @fail_on_error = value
end

Instance Method Details

#run!(extra_args = [], &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/flexutils/test_runner.rb', line 15

def run!( extra_args=[], &block )
  log_file = "tests.log"

  super([log_file, "-exit-on-complete", @exit_on_complete]) do |res|
    if File.exist? log_file
      #File.read("data.txt")?
      output = File.open(log_file) { |f| f.read }
      
      puts output
      
      rm log_file
    end
    
    if @fail_on_error
      if output.nil? 
        fail "No output from tests."
      elsif output =~ /tests failed/i 
        fail "Tests failed!"
      elsif res.nil? or res.exitstatus != 0
        fail "Test runner failed!"
      end
    end
  end
end