- centralized pretty printing so people can use it more easily

- updated unity helper examples to get them working again
- got examples running again

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@65 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
mvandervoord
2010-03-21 02:53:17 +00:00
parent 07d2848dd4
commit b10a094214
11 changed files with 72 additions and 136 deletions

View File

@ -22,8 +22,8 @@ class UnityTestSummary
results = @targets.map {|target| target.gsub(/\\/,'/')}
# Dig through each result file, looking for details on pass/fail:
failure_output = ""
ignore_output = ""
failure_output = []
ignore_output = []
results.each do |result_file|
lines = File.readlines(result_file).map { |line| line.chomp }
@ -32,8 +32,8 @@ class UnityTestSummary
else
summary_line = -2
output = get_details(result_file, lines)
failure_output += output[:failures] if !output[:failures].empty?
ignore_output += output[:ignores] if !output[:ignores].empty?
failure_output << output[:failures] unless output[:failures].empty?
ignore_output << output[:ignores] unless output[:ignores].empty?
tests,failures,ignored = parse_test_summary(lines[summary_line])
@total_tests += tests
@failures += failures
@ -46,7 +46,7 @@ class UnityTestSummary
@report += "--------------------------\n"
@report += "UNITY IGNORED TEST SUMMARY\n"
@report += "--------------------------\n"
@report += ignore_output
@report += ignore_output.flatten.join("\n")
end
if @failures > 0
@ -54,7 +54,7 @@ class UnityTestSummary
@report += "--------------------------\n"
@report += "UNITY FAILED TEST SUMMARY\n"
@report += "--------------------------\n"
@report += failure_output
@report += failure_output.flatten.join("\n")
end
@report += "\n"
@ -86,53 +86,17 @@ class UnityTestSummary
@@root=nil
def get_details(result_file, lines)
fail_lines = [] # indices of lines with failures
ignore_lines = [] # indices of lines with ignores
lines.each_with_index do |line,i|
if (i < (lines.length - 2) && !(line =~ /PASS$/))
if line =~ /(^.*\.c):(\d+)/
if line =~ /IGNORED$/
ignore_lines << i
else
fail_lines << i
end
elsif line =~ /IGNORED$/
ignore_lines << i
end
results = { :failures => [], :ignores => [], :successes => [] }
lines.each do |line|
line_out = line.gsub(/\//, "\\")
src_file,src_line,test_name,status,msg = line.split(/:/)
case(status)
when 'IGNORE' then results[:ignores] << line_out
when 'FAIL' then results[:failures] << line_out
when 'PASS' then results[:successes] << line_out
end
end
failures = []
fail_lines.each do |fail_line|
if lines[fail_line] =~ /\w:/
src_file,src_line,test_name,msg = lines[fail_line].split(/:/)
src_file = "#{@root}#{src_file}" unless @root == nil || @root.length == 0
detail = "#{src_file}:#{src_line}:#{test_name}:: #{msg}"
failures << detail.gsub(/\//, "\\")
end
end
if failures.length == 0
failure_results = ""
else
failure_results = failures.join("\n") + "\n"
end
ignores = []
ignore_lines.each do |ignore_line|
if lines[ignore_line] =~ /\w:/
src_file,src_line,test_name,msg = lines[ignore_line].split(/:/)
src_file = "#{@root}#{src_file}" unless @root == nil || @root.length == 0
detail = "#{src_file}:#{src_line}:#{test_name}:: #{msg}"
ignores << detail.gsub(/\//, "\\")
end
end
if ignores.length == 0
ignore_results = ""
else
ignore_results = ignores.join("\n") + "\n"
end
results = {:failures => failure_results, :ignores => ignore_results}
return results
end
def parse_test_summary(summary)