make sure reports don't blow up with multi-line console messages
This commit is contained in:
parent
d8023afaee
commit
a8b066ee50
@ -20,13 +20,20 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
last_message = nil
|
||||||
@report = File.readlines(file).collect do |line|
|
@report = File.readlines(file).collect do |line|
|
||||||
type, *parts = line.split('||', -1)
|
type, *parts = line.split('||', -1)
|
||||||
parts.last.strip!
|
|
||||||
|
|
||||||
Jasmine::Headless::ReportMessage.const_get(
|
if !(report_klass = report_class_for(type))
|
||||||
Jasmine::Headless::ReportMessage.constants.find { |k| k.to_s.downcase == type.downcase }
|
if last_message.kind_of?(Jasmine::Headless::ReportMessage::Console)
|
||||||
).new_from_parts(parts)
|
last_message.message << "\n"
|
||||||
|
last_message.message << line.strip
|
||||||
|
end
|
||||||
|
else
|
||||||
|
parts.last.strip!
|
||||||
|
|
||||||
|
last_message = report_klass.new_from_parts(parts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
@ -58,6 +65,12 @@ module Jasmine::Headless
|
|||||||
def last_total
|
def last_total
|
||||||
@report.reverse.find { |entry| entry.respond_to?(:total) }
|
@report.reverse.find { |entry| entry.respond_to?(:total) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def report_class_for(type)
|
||||||
|
if constant = ReportMessage.constants.find { |k| k.to_s.downcase == type.downcase }
|
||||||
|
ReportMessage.const_get(constant)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,6 +60,20 @@ REPORT
|
|||||||
report.failed_files.should == []
|
report.failed_files.should == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'multi line console' do
|
||||||
|
before do
|
||||||
|
File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
|
||||||
|
CONSOLE||test
|
||||||
|
test2
|
||||||
|
TOTAL||1||2||3||T
|
||||||
|
REPORT
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should read the report file' do
|
||||||
|
report[0].should == Jasmine::Headless::ReportMessage::Console.new("test\ntest2")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user