mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Update Unity to release 2.4.1
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
#!/usr/bin/ruby
|
||||
# !/usr/bin/ruby
|
||||
#
|
||||
# unity_test_summary.rb
|
||||
#
|
||||
@@ -15,37 +15,35 @@ class UnityTestSummary
|
||||
include FileUtils::Verbose
|
||||
|
||||
attr_reader :report, :total_tests, :failures, :ignored
|
||||
attr_writer :targets, :root
|
||||
|
||||
def initialize(opts = {})
|
||||
def initialize(_opts = {})
|
||||
@report = ''
|
||||
@total_tests = 0
|
||||
@failures = 0
|
||||
@ignored = 0
|
||||
|
||||
|
||||
end
|
||||
|
||||
def run
|
||||
# Clean up result file names
|
||||
results = @targets.map {|target| target.gsub(/\\/,'/')}
|
||||
results = @targets.map { |target| target.tr('\\', '/') }
|
||||
|
||||
# Dig through each result file, looking for details on pass/fail:
|
||||
failure_output = []
|
||||
ignore_output = []
|
||||
|
||||
results.each do |result_file|
|
||||
lines = File.readlines(result_file).map { |line| line.chomp }
|
||||
if lines.length == 0
|
||||
raise "Empty test result file: #{result_file}"
|
||||
else
|
||||
output = get_details(result_file, lines)
|
||||
failure_output << output[:failures] unless output[:failures].empty?
|
||||
ignore_output << output[:ignores] unless output[:ignores].empty?
|
||||
tests,failures,ignored = parse_test_summary(lines)
|
||||
@total_tests += tests
|
||||
@failures += failures
|
||||
@ignored += ignored
|
||||
end
|
||||
lines = File.readlines(result_file).map(&:chomp)
|
||||
|
||||
raise "Empty test result file: #{result_file}" if lines.empty?
|
||||
|
||||
output = get_details(result_file, lines)
|
||||
failure_output << output[:failures] unless output[:failures].empty?
|
||||
ignore_output << output[:ignores] unless output[:ignores].empty?
|
||||
tests, failures, ignored = parse_test_summary(lines)
|
||||
@total_tests += tests
|
||||
@failures += failures
|
||||
@ignored += ignored
|
||||
end
|
||||
|
||||
if @ignored > 0
|
||||
@@ -72,77 +70,67 @@ class UnityTestSummary
|
||||
@report += "\n"
|
||||
end
|
||||
|
||||
def set_targets(target_array)
|
||||
@targets = target_array
|
||||
end
|
||||
|
||||
def set_root_path(path)
|
||||
@root = path
|
||||
end
|
||||
|
||||
def usage(err_msg=nil)
|
||||
def usage(err_msg = nil)
|
||||
puts "\nERROR: "
|
||||
puts err_msg if err_msg
|
||||
puts "\nUsage: unity_test_summary.rb result_file_directory/ root_path/"
|
||||
puts " result_file_directory - The location of your results files."
|
||||
puts " Defaults to current directory if not specified."
|
||||
puts " Should end in / if specified."
|
||||
puts " root_path - Helpful for producing more verbose output if using relative paths."
|
||||
puts ' result_file_directory - The location of your results files.'
|
||||
puts ' Defaults to current directory if not specified.'
|
||||
puts ' Should end in / if specified.'
|
||||
puts ' root_path - Helpful for producing more verbose output if using relative paths.'
|
||||
exit 1
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_details(result_file, lines)
|
||||
results = { :failures => [], :ignores => [], :successes => [] }
|
||||
def get_details(_result_file, lines)
|
||||
results = { failures: [], ignores: [], successes: [] }
|
||||
lines.each do |line|
|
||||
src_file,src_line,test_name,status,msg = line.split(/:/)
|
||||
line_out = ((@root && (@root != 0)) ? "#{@root}#{line}" : line ).gsub(/\//, "\\")
|
||||
case(status)
|
||||
when 'IGNORE' then results[:ignores] << line_out
|
||||
when 'FAIL' then results[:failures] << line_out
|
||||
when 'PASS' then results[:successes] << line_out
|
||||
_src_file, _src_line, _test_name, status, _msg = line.split(/:/)
|
||||
line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\')
|
||||
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
|
||||
return results
|
||||
results
|
||||
end
|
||||
|
||||
def parse_test_summary(summary)
|
||||
if summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
|
||||
[$1.to_i,$2.to_i,$3.to_i]
|
||||
else
|
||||
raise "Couldn't parse test results: #{summary}"
|
||||
end
|
||||
raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
|
||||
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||
end
|
||||
|
||||
def here; File.expand_path(File.dirname(__FILE__)); end
|
||||
|
||||
def here
|
||||
File.expand_path(File.dirname(__FILE__))
|
||||
end
|
||||
end
|
||||
|
||||
if $0 == __FILE__
|
||||
|
||||
#parse out the command options
|
||||
opts, args = ARGV.partition {|v| v =~ /^--\w+/}
|
||||
opts.map! {|v| v[2..-1].to_sym }
|
||||
# parse out the command options
|
||||
opts, args = ARGV.partition { |v| v =~ /^--\w+/ }
|
||||
opts.map! { |v| v[2..-1].to_sym }
|
||||
|
||||
#create an instance to work with
|
||||
# create an instance to work with
|
||||
uts = UnityTestSummary.new(opts)
|
||||
|
||||
begin
|
||||
#look in the specified or current directory for result files
|
||||
# look in the specified or current directory for result files
|
||||
args[0] ||= './'
|
||||
targets = "#{ARGV[0].gsub(/\\/, '/')}**/*.test*"
|
||||
targets = "#{ARGV[0].tr('\\', '/')}**/*.test*"
|
||||
results = Dir[targets]
|
||||
raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty?
|
||||
uts.set_targets(results)
|
||||
uts.targets = results
|
||||
|
||||
#set the root path
|
||||
# set the root path
|
||||
args[1] ||= Dir.pwd + '/'
|
||||
uts.set_root_path(ARGV[1])
|
||||
uts.root = ARGV[1]
|
||||
|
||||
#run the summarizer
|
||||
# run the summarizer
|
||||
puts uts.run
|
||||
rescue Exception => e
|
||||
rescue StandardError => e
|
||||
uts.usage e.message
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user