lib/flashplayer/log_file.rb in flashsdk_sqe-0.0.2 vs lib/flashplayer/log_file.rb in flashsdk_sqe-0.0.3

- old
+ new

@@ -3,10 +3,12 @@ class LogFile attr_accessor :logger attr_accessor :player_pid + attr_accessor :result_string + attr_accessor :result_failure def initialize @logger = $stdout super end @@ -28,36 +30,38 @@ def read_flashlog_at path, thread=nil thread ||= fake_thread lines_put = 0 while thread.alive? do - lines_put, last_line = read_from_file path, lines_put + lines_put = read_from_file path, lines_put logger.flush - sleep(0.1) - - unless last_line.nil? + if !result_string.nil? thread.kill Process.kill('KILL', self.player_pid) if self.player_pid - raise 'FlexUnit ERROR: ' + last_line + if self.result_failure + raise self.result_string.join('') + else + logger.puts self.result_string + end end + sleep(0.1) end end def read_from_file path, lines_put - last_line = nil File.open(path, 'r') do |file| lines_read = 0 - file.readlines.each do |line| - last_line = line if line =~ /ALL TESTS ARE COMPLETED/ + all_lines = file.readlines + all_lines.each.with_index do |line, index| if(lines_read >= lines_put) - logger.puts "[trace] #{line}" - logger.flush + self.result_failure = true if line =~ /TESTS HAS FAILURES/ + self.result_string = all_lines[index+1 .. -1] if line =~ /ALL TESTS ARE COMPLETED/ && self.result_string.nil? lines_put += 1 end lines_read += 1 end end unless !File.exists?(path) - [lines_put, last_line] + lines_put end def flashlog_path begin FlashPlayer.flashlog