mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
Finished updating all Ruby scripts to match our coding standard. Woo!
This commit is contained in:
@@ -21,12 +21,11 @@ end
|
|||||||
|
|
||||||
class ColourCommandLine
|
class ColourCommandLine
|
||||||
def initialize
|
def initialize
|
||||||
if RUBY_PLATFORM =~ /(win|w)32$/
|
return unless RUBY_PLATFORM =~ /(win|w)32$/
|
||||||
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
|
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
|
||||||
@set_console_txt_attrb =
|
@set_console_txt_attrb =
|
||||||
Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I')
|
Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I')
|
||||||
@hout = get_std_handle.call(-11)
|
@hout = get_std_handle.call(-11)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_to(new_colour)
|
def change_to(new_colour)
|
||||||
@@ -34,7 +33,7 @@ class ColourCommandLine
|
|||||||
@set_console_txt_attrb.call(@hout, win32_colour(new_colour))
|
@set_console_txt_attrb.call(@hout, win32_colour(new_colour))
|
||||||
else
|
else
|
||||||
"\033[30;#{posix_colour(new_colour)};22m"
|
"\033[30;#{posix_colour(new_colour)};22m"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def win32_colour(colour)
|
def win32_colour(colour)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def report(message)
|
|||||||
line.chomp!
|
line.chomp!
|
||||||
colour = case line
|
colour = case line
|
||||||
when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i
|
when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i
|
||||||
Regexp.last_match(1).to_i == 0 ? :green : :red
|
Regexp.last_match(1).to_i.zero? ? :green : :red
|
||||||
when /PASS/
|
when /PASS/
|
||||||
:green
|
:green
|
||||||
when /^OK$/
|
when /^OK$/
|
||||||
@@ -30,7 +30,7 @@ def report(message)
|
|||||||
:white
|
:white
|
||||||
else
|
else
|
||||||
:silver
|
:silver
|
||||||
end
|
end
|
||||||
colour_puts(colour, line)
|
colour_puts(colour, line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ File.expand_path(File.join(File.dirname(__FILE__), 'colour_prompt'))
|
|||||||
class UnityTestRunnerGenerator
|
class UnityTestRunnerGenerator
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
@options = UnityTestRunnerGenerator.default_options
|
@options = UnityTestRunnerGenerator.default_options
|
||||||
case (options)
|
case options
|
||||||
when NilClass then @options
|
when NilClass then @options
|
||||||
when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
|
when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
|
||||||
when Hash then @options.merge!(options)
|
when Hash then @options.merge!(options)
|
||||||
else raise 'If you specify arguments, it should be a filename or a hash of options'
|
else raise 'If you specify arguments, it should be a filename or a hash of options'
|
||||||
end
|
end
|
||||||
require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer"
|
require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer"
|
||||||
end
|
end
|
||||||
@@ -43,16 +43,11 @@ class UnityTestRunnerGenerator
|
|||||||
options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
|
options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
|
||||||
raise "No :unity or :cmock section found in #{config_file}" unless options
|
raise "No :unity or :cmock section found in #{config_file}" unless options
|
||||||
end
|
end
|
||||||
(options)
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(input_file, output_file, options = nil)
|
def run(input_file, output_file, options = nil)
|
||||||
tests = []
|
|
||||||
testfile_includes = []
|
|
||||||
used_mocks = []
|
|
||||||
|
|
||||||
@options.merge!(options) unless options.nil?
|
@options.merge!(options) unless options.nil?
|
||||||
module_name = File.basename(input_file)
|
|
||||||
|
|
||||||
# pull required data from source file
|
# pull required data from source file
|
||||||
source = File.read(input_file)
|
source = File.read(input_file)
|
||||||
@@ -80,15 +75,16 @@ class UnityTestRunnerGenerator
|
|||||||
create_header(output, used_mocks, testfile_includes)
|
create_header(output, used_mocks, testfile_includes)
|
||||||
create_externs(output, tests, used_mocks)
|
create_externs(output, tests, used_mocks)
|
||||||
create_mock_management(output, used_mocks)
|
create_mock_management(output, used_mocks)
|
||||||
create_suite_setup_and_teardown(output)
|
create_suite_setup(output)
|
||||||
|
create_suite_teardown(output)
|
||||||
create_reset(output, used_mocks)
|
create_reset(output, used_mocks)
|
||||||
create_main(output, input_file, tests, used_mocks)
|
create_main(output, input_file, tests, used_mocks)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:header_file] && !@options[:header_file].empty?
|
return unless @options[:header_file] && !@options[:header_file].empty?
|
||||||
File.open(@options[:header_file], 'w') do |output|
|
|
||||||
create_h_file(output, @options[:header_file], tests, testfile_includes, used_mocks)
|
File.open(@options[:header_file], 'w') do |output|
|
||||||
end
|
create_h_file(output, @options[:header_file], tests, testfile_includes, used_mocks)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -123,7 +119,7 @@ class UnityTestRunnerGenerator
|
|||||||
source_index = 0
|
source_index = 0
|
||||||
tests_and_line_numbers.size.times do |i|
|
tests_and_line_numbers.size.times do |i|
|
||||||
source_lines[source_index..-1].each_with_index do |line, index|
|
source_lines[source_index..-1].each_with_index do |line, index|
|
||||||
next unless (line =~ /#{tests_and_line_numbers[i][:test]}/)
|
next unless line =~ /#{tests_and_line_numbers[i][:test]}/
|
||||||
source_index += index
|
source_index += index
|
||||||
tests_and_line_numbers[i][:line_number] = source_index + 1
|
tests_and_line_numbers[i][:line_number] = source_index + 1
|
||||||
break
|
break
|
||||||
@@ -182,12 +178,13 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts("#include \"#{mock.gsub('.h', '')}.h\"")
|
output.puts("#include \"#{mock.gsub('.h', '')}.h\"")
|
||||||
end
|
end
|
||||||
output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
|
output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
|
||||||
if @options[:enforce_strict_ordering]
|
|
||||||
output.puts('')
|
return unless @options[:enforce_strict_ordering]
|
||||||
output.puts('int GlobalExpectCount;')
|
|
||||||
output.puts('int GlobalVerifyOrder;')
|
output.puts('')
|
||||||
output.puts('char* GlobalOrderError;')
|
output.puts('int GlobalExpectCount;')
|
||||||
end
|
output.puts('int GlobalVerifyOrder;')
|
||||||
|
output.puts('char* GlobalOrderError;')
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_externs(output, tests, _mocks)
|
def create_externs(output, tests, _mocks)
|
||||||
@@ -201,55 +198,60 @@ class UnityTestRunnerGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_mock_management(output, mock_headers)
|
def create_mock_management(output, mock_headers)
|
||||||
unless mock_headers.empty?
|
return if mock_headers.empty?
|
||||||
output.puts("\n/*=======Mock Management=====*/")
|
|
||||||
output.puts('static void CMock_Init(void)')
|
|
||||||
output.puts('{')
|
|
||||||
if @options[:enforce_strict_ordering]
|
|
||||||
output.puts(' GlobalExpectCount = 0;')
|
|
||||||
output.puts(' GlobalVerifyOrder = 0;')
|
|
||||||
output.puts(' GlobalOrderError = NULL;')
|
|
||||||
end
|
|
||||||
mocks = mock_headers.map { |mock| File.basename(mock) }
|
|
||||||
mocks.each do |mock|
|
|
||||||
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
|
|
||||||
output.puts(" #{mock_clean}_Init();")
|
|
||||||
end
|
|
||||||
output.puts("}\n")
|
|
||||||
|
|
||||||
output.puts('static void CMock_Verify(void)')
|
output.puts("\n/*=======Mock Management=====*/")
|
||||||
output.puts('{')
|
output.puts('static void CMock_Init(void)')
|
||||||
mocks.each do |mock|
|
output.puts('{')
|
||||||
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
|
|
||||||
output.puts(" #{mock_clean}_Verify();")
|
|
||||||
end
|
|
||||||
output.puts("}\n")
|
|
||||||
|
|
||||||
output.puts('static void CMock_Destroy(void)')
|
if @options[:enforce_strict_ordering]
|
||||||
output.puts('{')
|
output.puts(' GlobalExpectCount = 0;')
|
||||||
mocks.each do |mock|
|
output.puts(' GlobalVerifyOrder = 0;')
|
||||||
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
|
output.puts(' GlobalOrderError = NULL;')
|
||||||
output.puts(" #{mock_clean}_Destroy();")
|
|
||||||
end
|
|
||||||
output.puts("}\n")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mocks = mock_headers.map { |mock| File.basename(mock) }
|
||||||
|
mocks.each do |mock|
|
||||||
|
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
|
||||||
|
output.puts(" #{mock_clean}_Init();")
|
||||||
|
end
|
||||||
|
output.puts("}\n")
|
||||||
|
|
||||||
|
output.puts('static void CMock_Verify(void)')
|
||||||
|
output.puts('{')
|
||||||
|
mocks.each do |mock|
|
||||||
|
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
|
||||||
|
output.puts(" #{mock_clean}_Verify();")
|
||||||
|
end
|
||||||
|
output.puts("}\n")
|
||||||
|
|
||||||
|
output.puts('static void CMock_Destroy(void)')
|
||||||
|
output.puts('{')
|
||||||
|
mocks.each do |mock|
|
||||||
|
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
|
||||||
|
output.puts(" #{mock_clean}_Destroy();")
|
||||||
|
end
|
||||||
|
output.puts("}\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_suite_setup_and_teardown(output)
|
def create_suite_setup(output)
|
||||||
unless @options[:suite_setup].nil?
|
return if @options[:suite_setup].nil?
|
||||||
output.puts("\n/*=======Suite Setup=====*/")
|
|
||||||
output.puts('static void suite_setup(void)')
|
output.puts("\n/*=======Suite Setup=====*/")
|
||||||
output.puts('{')
|
output.puts('static void suite_setup(void)')
|
||||||
output.puts(@options[:suite_setup])
|
output.puts('{')
|
||||||
output.puts('}')
|
output.puts(@options[:suite_setup])
|
||||||
end
|
output.puts('}')
|
||||||
unless @options[:suite_teardown].nil?
|
end
|
||||||
output.puts("\n/*=======Suite Teardown=====*/")
|
|
||||||
output.puts('static int suite_teardown(int num_failures)')
|
def create_suite_teardown(output)
|
||||||
output.puts('{')
|
return if @options[:suite_teardown].nil?
|
||||||
output.puts(@options[:suite_teardown])
|
|
||||||
output.puts('}')
|
output.puts("\n/*=======Suite Teardown=====*/")
|
||||||
end
|
output.puts('static int suite_teardown(int num_failures)')
|
||||||
|
output.puts('{')
|
||||||
|
output.puts(@options[:suite_teardown])
|
||||||
|
output.puts('}')
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_runtest(output, used_mocks)
|
def create_runtest(output, used_mocks)
|
||||||
@@ -384,22 +386,25 @@ class UnityTestRunnerGenerator
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if $PROGRAM_NAME == __FILE__
|
if $0 == __FILE__
|
||||||
options = { includes: [] }
|
options = { includes: [] }
|
||||||
yaml_file = nil
|
|
||||||
|
|
||||||
# parse out all the options first (these will all be removed as we go)
|
# parse out all the options first (these will all be removed as we go)
|
||||||
ARGV.reject! do |arg|
|
ARGV.reject! do |arg|
|
||||||
case (arg)
|
case arg
|
||||||
when '-cexception'
|
when '-cexception'
|
||||||
options[:plugins] = [:cexception]; true
|
options[:plugins] = [:cexception]
|
||||||
|
true
|
||||||
when /\.*\.ya?ml/
|
when /\.*\.ya?ml/
|
||||||
options = UnityTestRunnerGenerator.grab_config(arg); true
|
options = UnityTestRunnerGenerator.grab_config(arg)
|
||||||
|
true
|
||||||
when /--(\w+)=\"?(.*)\"?/
|
when /--(\w+)=\"?(.*)\"?/
|
||||||
options[Regexp.last_match(1).to_sym] = Regexp.last_match(2); true
|
options[Regexp.last_match(1).to_sym] = Regexp.last_match(2)
|
||||||
|
true
|
||||||
when /\.*\.h/
|
when /\.*\.h/
|
||||||
options[:includes] << arg; true
|
options[:includes] << arg
|
||||||
else false
|
true
|
||||||
|
else false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,218 +0,0 @@
|
|||||||
#============================================================
|
|
||||||
# Author: John Theofanopoulos
|
|
||||||
# A simple parser. Takes the output files generated during the build process and
|
|
||||||
# extracts information relating to the tests.
|
|
||||||
#
|
|
||||||
# Notes:
|
|
||||||
# To capture an output file under VS builds use the following:
|
|
||||||
# devenv [build instructions] > Output.txt & type Output.txt
|
|
||||||
#
|
|
||||||
# To capture an output file under GCC/Linux builds use the following:
|
|
||||||
# make | tee Output.txt
|
|
||||||
#
|
|
||||||
# To use this parser use the following command
|
|
||||||
# ruby parseOutput.rb [options] [file]
|
|
||||||
# options: -xml : produce a JUnit compatible XML file
|
|
||||||
# file : file to scan for results
|
|
||||||
#============================================================
|
|
||||||
|
|
||||||
class ParseOutput
|
|
||||||
# The following flag is set to true when a test is found or false otherwise.
|
|
||||||
@testFlag
|
|
||||||
@xmlOut
|
|
||||||
@arrayList
|
|
||||||
@totalTests
|
|
||||||
@classIndex
|
|
||||||
|
|
||||||
# Set the flag to indicate if there will be an XML output file or not
|
|
||||||
def setXmlOutput
|
|
||||||
@xmlOut = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# if write our output to XML
|
|
||||||
def writeXmlOuput
|
|
||||||
output = File.open('report.xml', 'w')
|
|
||||||
output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
||||||
@arrayList.each do |item|
|
|
||||||
output << item << "\n"
|
|
||||||
end
|
|
||||||
output << "</testsuite>\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
# This function will try and determine when the suite is changed. This is
|
|
||||||
# is the name that gets added to the classname parameter.
|
|
||||||
def testSuiteVerify(testSuiteName)
|
|
||||||
if @testFlag == false
|
|
||||||
@testFlag = true
|
|
||||||
# Split the path name
|
|
||||||
testName = testSuiteName.split('/')
|
|
||||||
# Remove the extension
|
|
||||||
baseName = testName[testName.size - 1].split('.')
|
|
||||||
@testSuite = 'test.' + baseName[0]
|
|
||||||
printf "New Test: %s\n", @testSuite
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test was flagged as having passed so format the output
|
|
||||||
def testPassed(array)
|
|
||||||
lastItem = array.length - 1
|
|
||||||
testName = array[lastItem - 1]
|
|
||||||
testSuiteVerify(array[@className])
|
|
||||||
printf "%-40s PASS\n", testName
|
|
||||||
if @xmlOut == true
|
|
||||||
@arrayList.push ' <testcase classname="' + @testSuite + '" name="' + testName + '"/>'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test was flagged as having passed so format the output.
|
|
||||||
# This is using the Unity fixture output and not the original Unity output.
|
|
||||||
def testPassedUnityFixture(array)
|
|
||||||
testSuite = array[0].sub('TEST(', '')
|
|
||||||
testSuite = testSuite.sub(',', '')
|
|
||||||
testName = array[1].sub(')', '')
|
|
||||||
if @xmlOut == true
|
|
||||||
@arrayList.push ' <testcase classname="' + testSuite + '" name="' + testName + '"/>'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test was flagged as being ingored so format the output
|
|
||||||
def testIgnored(array)
|
|
||||||
lastItem = array.length - 1
|
|
||||||
testName = array[lastItem - 2]
|
|
||||||
reason = array[lastItem].chomp
|
|
||||||
testSuiteVerify(array[@className])
|
|
||||||
printf "%-40s IGNORED\n", testName
|
|
||||||
|
|
||||||
if testName.start_with? 'TEST('
|
|
||||||
array2 = testName.split(' ')
|
|
||||||
@testSuite = array2[0].sub('TEST(', '')
|
|
||||||
@testSuite = @testSuite.sub(',', '')
|
|
||||||
testName = array2[1].sub(')', '')
|
|
||||||
end
|
|
||||||
|
|
||||||
if @xmlOut == true
|
|
||||||
@arrayList.push ' <testcase classname="' + @testSuite + '" name="' + testName + '">'
|
|
||||||
@arrayList.push ' <skipped type="TEST IGNORED"> ' + reason + ' </skipped>'
|
|
||||||
@arrayList.push ' </testcase>'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Test was flagged as having failed so format the line
|
|
||||||
def testFailed(array)
|
|
||||||
lastItem = array.length - 1
|
|
||||||
testName = array[lastItem - 2]
|
|
||||||
reason = array[lastItem].chomp + ' at line: ' + array[lastItem - 3]
|
|
||||||
testSuiteVerify(array[@className])
|
|
||||||
printf "%-40s FAILED\n", testName
|
|
||||||
|
|
||||||
if testName.start_with? 'TEST('
|
|
||||||
array2 = testName.split(' ')
|
|
||||||
@testSuite = array2[0].sub('TEST(', '')
|
|
||||||
@testSuite = @testSuite.sub(',', '')
|
|
||||||
testName = array2[1].sub(')', '')
|
|
||||||
end
|
|
||||||
|
|
||||||
if @xmlOut == true
|
|
||||||
@arrayList.push ' <testcase classname="' + @testSuite + '" name="' + testName + '">'
|
|
||||||
@arrayList.push ' <failure type="ASSERT FAILED"> ' + reason + ' </failure>'
|
|
||||||
@arrayList.push ' </testcase>'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Figure out what OS we are running on. For now we are assuming if it's not Windows it must
|
|
||||||
# be Unix based.
|
|
||||||
def detectOS
|
|
||||||
myOS = RUBY_PLATFORM.split('-')
|
|
||||||
@className = if myOS.size == 2
|
|
||||||
if myOS[1] == 'mingw32'
|
|
||||||
1
|
|
||||||
else
|
|
||||||
0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Main function used to parse the file that was captured.
|
|
||||||
def process(name)
|
|
||||||
@testFlag = false
|
|
||||||
@arrayList = []
|
|
||||||
|
|
||||||
detectOS
|
|
||||||
|
|
||||||
puts 'Parsing file: ' + name
|
|
||||||
|
|
||||||
testPass = 0
|
|
||||||
testFail = 0
|
|
||||||
testIgnore = 0
|
|
||||||
puts ''
|
|
||||||
puts '=================== RESULTS ====================='
|
|
||||||
puts ''
|
|
||||||
File.open(name).each do |line|
|
|
||||||
# Typical test lines look like this:
|
|
||||||
# <path>/<test_file>.c:36:test_tc1000_opsys:FAIL: Expected 1 Was 0
|
|
||||||
# <path>/<test_file>.c:112:test_tc5004_initCanChannel:IGNORE: Not Yet Implemented
|
|
||||||
# <path>/<test_file>.c:115:test_tc5100_initCanVoidPtrs:PASS
|
|
||||||
#
|
|
||||||
# where path is different on Unix vs Windows devices (Windows leads with a drive letter)
|
|
||||||
lineArray = line.split(':')
|
|
||||||
lineSize = lineArray.size
|
|
||||||
# If we were able to split the line then we can look to see if any of our target words
|
|
||||||
# were found. Case is important.
|
|
||||||
if (lineSize >= 4) || (line.start_with? 'TEST(')
|
|
||||||
# Determine if this test passed
|
|
||||||
if line.include? ':PASS'
|
|
||||||
testPassed(lineArray)
|
|
||||||
testPass += 1
|
|
||||||
elsif line.include? ':FAIL:'
|
|
||||||
testFailed(lineArray)
|
|
||||||
testFail += 1
|
|
||||||
elsif line.include? ':IGNORE:'
|
|
||||||
testIgnored(lineArray)
|
|
||||||
testIgnore += 1
|
|
||||||
elsif line.start_with? 'TEST('
|
|
||||||
if line.include? ' PASS'
|
|
||||||
lineArray = line.split(' ')
|
|
||||||
testPassedUnityFixture(lineArray)
|
|
||||||
testPass += 1
|
|
||||||
end
|
|
||||||
# If none of the keywords are found there are no more tests for this suite so clear
|
|
||||||
# the test flag
|
|
||||||
else
|
|
||||||
@testFlag = false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@testFlag = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
puts ''
|
|
||||||
puts '=================== SUMMARY ====================='
|
|
||||||
puts ''
|
|
||||||
puts 'Tests Passed : ' + testPass.to_s
|
|
||||||
puts 'Tests Failed : ' + testFail.to_s
|
|
||||||
puts 'Tests Ignored : ' + testIgnore.to_s
|
|
||||||
@totalTests = testPass + testFail + testIgnore
|
|
||||||
if @xmlOut == true
|
|
||||||
heading = '<testsuite tests="' + @totalTests.to_s + '" failures="' + testFail.to_s + '"' + ' skips="' + testIgnore.to_s + '">'
|
|
||||||
@arrayList.insert(0, heading)
|
|
||||||
writeXmlOuput
|
|
||||||
end
|
|
||||||
|
|
||||||
# return result
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# If the command line has no values in, used a default value of Output.txt
|
|
||||||
parseMyFile = ParseOutput.new
|
|
||||||
|
|
||||||
if ARGV.size >= 1
|
|
||||||
ARGV.each do |a|
|
|
||||||
if a == '-xml'
|
|
||||||
parseMyFile.setXmlOutput
|
|
||||||
else
|
|
||||||
parseMyFile.process(a)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
220
auto/parse_output.rb
Normal file
220
auto/parse_output.rb
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
#============================================================
|
||||||
|
# Author: John Theofanopoulos
|
||||||
|
# A simple parser. Takes the output files generated during the build process and
|
||||||
|
# extracts information relating to the tests.
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# To capture an output file under VS builds use the following:
|
||||||
|
# devenv [build instructions] > Output.txt & type Output.txt
|
||||||
|
#
|
||||||
|
# To capture an output file under GCC/Linux builds use the following:
|
||||||
|
# make | tee Output.txt
|
||||||
|
#
|
||||||
|
# To use this parser use the following command
|
||||||
|
# ruby parseOutput.rb [options] [file]
|
||||||
|
# options: -xml : produce a JUnit compatible XML file
|
||||||
|
# file : file to scan for results
|
||||||
|
#============================================================
|
||||||
|
|
||||||
|
class ParseOutput
|
||||||
|
def initialize
|
||||||
|
@test_flag = false
|
||||||
|
@xml_out = false
|
||||||
|
@array_list = false
|
||||||
|
@total_tests = false
|
||||||
|
@class_index = false
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set the flag to indicate if there will be an XML output file or not
|
||||||
|
def set_xml_output
|
||||||
|
@xml_out = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# if write our output to XML
|
||||||
|
def write_xml_output
|
||||||
|
output = File.open('report.xml', 'w')
|
||||||
|
output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
@array_list.each do |item|
|
||||||
|
output << item << "\n"
|
||||||
|
end
|
||||||
|
output << "</testsuite>\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
# This function will try and determine when the suite is changed. This is
|
||||||
|
# is the name that gets added to the classname parameter.
|
||||||
|
def test_suite_verify(test_suite_name)
|
||||||
|
return if @test_flag
|
||||||
|
|
||||||
|
@test_flag = true
|
||||||
|
# Split the path name
|
||||||
|
test_name = test_suite_name.split('/')
|
||||||
|
# Remove the extension
|
||||||
|
base_name = test_name[test_name.size - 1].split('.')
|
||||||
|
@test_suite = 'test.' + base_name[0]
|
||||||
|
printf "New Test: %s\n", @test_suite
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test was flagged as having passed so format the output
|
||||||
|
def test_passed(array)
|
||||||
|
last_item = array.length - 1
|
||||||
|
test_name = array[last_item - 1]
|
||||||
|
test_suite_verify(array[@class_name])
|
||||||
|
printf "%-40s PASS\n", test_name
|
||||||
|
|
||||||
|
return unless @xml_out
|
||||||
|
|
||||||
|
@array_list.push ' <testcase classname="' + @test_suite + '" name="' + test_name + '"/>'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test was flagged as having passed so format the output.
|
||||||
|
# This is using the Unity fixture output and not the original Unity output.
|
||||||
|
def test_passed_unity_fixture(array)
|
||||||
|
test_suite = array[0].sub('TEST(', '')
|
||||||
|
test_suite = test_suite.sub(',', '')
|
||||||
|
test_name = array[1].sub(')', '')
|
||||||
|
|
||||||
|
return unless @xml_out
|
||||||
|
|
||||||
|
@array_list.push ' <testcase classname="' + test_suite + '" name="' + test_name + '"/>'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test was flagged as being ingored so format the output
|
||||||
|
def test_ignored(array)
|
||||||
|
last_item = array.length - 1
|
||||||
|
test_name = array[last_item - 2]
|
||||||
|
reason = array[last_item].chomp
|
||||||
|
test_suite_verify(array[@class_name])
|
||||||
|
printf "%-40s IGNORED\n", test_name
|
||||||
|
|
||||||
|
if test_name.start_with? 'TEST('
|
||||||
|
array2 = test_name.split(' ')
|
||||||
|
@test_suite = array2[0].sub('TEST(', '')
|
||||||
|
@test_suite = @test_suite.sub(',', '')
|
||||||
|
test_name = array2[1].sub(')', '')
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless @xml_out
|
||||||
|
|
||||||
|
@array_list.push ' <testcase classname="' + @test_suite + '" name="' + test_name + '">'
|
||||||
|
@array_list.push ' <skipped type="TEST IGNORED"> ' + reason + ' </skipped>'
|
||||||
|
@array_list.push ' </testcase>'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Test was flagged as having failed so format the line
|
||||||
|
def test_failed(array)
|
||||||
|
last_item = array.length - 1
|
||||||
|
test_name = array[last_item - 2]
|
||||||
|
reason = array[last_item].chomp + ' at line: ' + array[last_item - 3]
|
||||||
|
test_suite_verify(array[@class_name])
|
||||||
|
printf "%-40s FAILED\n", test_name
|
||||||
|
|
||||||
|
if test_name.start_with? 'TEST('
|
||||||
|
array2 = test_name.split(' ')
|
||||||
|
@test_suite = array2[0].sub('TEST(', '')
|
||||||
|
@test_suite = @test_suite.sub(',', '')
|
||||||
|
test_name = array2[1].sub(')', '')
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless @xml_out
|
||||||
|
|
||||||
|
@array_list.push ' <testcase classname="' + @test_suite + '" name="' + test_name + '">'
|
||||||
|
@array_list.push ' <failure type="ASSERT FAILED"> ' + reason + ' </failure>'
|
||||||
|
@array_list.push ' </testcase>'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Figure out what OS we are running on. For now we are assuming if it's not Windows it must
|
||||||
|
# be Unix based.
|
||||||
|
def detect_os
|
||||||
|
os = RUBY_PLATFORM.split('-')
|
||||||
|
@class_name = if os.size == 2
|
||||||
|
if os[1] == 'mingw32'
|
||||||
|
1
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Main function used to parse the file that was captured.
|
||||||
|
def process(name)
|
||||||
|
@test_flag = false
|
||||||
|
@array_list = []
|
||||||
|
|
||||||
|
detect_os
|
||||||
|
|
||||||
|
puts 'Parsing file: ' + name
|
||||||
|
|
||||||
|
test_pass = 0
|
||||||
|
test_fail = 0
|
||||||
|
test_ignore = 0
|
||||||
|
puts ''
|
||||||
|
puts '=================== RESULTS ====================='
|
||||||
|
puts ''
|
||||||
|
File.open(name).each do |line|
|
||||||
|
# Typical test lines look like this:
|
||||||
|
# <path>/<test_file>.c:36:test_tc1000_opsys:FAIL: Expected 1 Was 0
|
||||||
|
# <path>/<test_file>.c:112:test_tc5004_initCanChannel:IGNORE: Not Yet Implemented
|
||||||
|
# <path>/<test_file>.c:115:test_tc5100_initCanVoidPtrs:PASS
|
||||||
|
#
|
||||||
|
# where path is different on Unix vs Windows devices (Windows leads with a drive letter)
|
||||||
|
line_array = line.split(':')
|
||||||
|
|
||||||
|
# If we were able to split the line then we can look to see if any of our target words
|
||||||
|
# were found. Case is important.
|
||||||
|
if (line_array.size >= 4) || (line.start_with? 'TEST(')
|
||||||
|
# Determine if this test passed
|
||||||
|
if line.include? ':PASS'
|
||||||
|
test_passed(line_array)
|
||||||
|
test_pass += 1
|
||||||
|
elsif line.include? ':FAIL:'
|
||||||
|
test_failed(line_array)
|
||||||
|
test_fail += 1
|
||||||
|
elsif line.include? ':IGNORE:'
|
||||||
|
test_ignored(line_array)
|
||||||
|
test_ignore += 1
|
||||||
|
elsif line.start_with? 'TEST('
|
||||||
|
if line.include? ' PASS'
|
||||||
|
line_array = line.split(' ')
|
||||||
|
test_passed_unity_fixture(line_array)
|
||||||
|
test_pass += 1
|
||||||
|
end
|
||||||
|
# If none of the keywords are found there are no more tests for this suite so clear
|
||||||
|
# the test flag
|
||||||
|
else
|
||||||
|
@test_flag = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@test_flag = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
puts ''
|
||||||
|
puts '=================== SUMMARY ====================='
|
||||||
|
puts ''
|
||||||
|
puts 'Tests Passed : ' + test_pass.to_s
|
||||||
|
puts 'Tests Failed : ' + test_fail.to_s
|
||||||
|
puts 'Tests Ignored : ' + test_ignore.to_s
|
||||||
|
@total_tests = test_pass + test_fail + test_ignore
|
||||||
|
|
||||||
|
return unless @xml_out
|
||||||
|
|
||||||
|
heading = '<testsuite tests="' + @total_tests.to_s + '" failures="' + test_fail.to_s + '"' + ' skips="' + test_ignore.to_s + '">'
|
||||||
|
@array_list.insert(0, heading)
|
||||||
|
write_xml_output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# If the command line has no values in, used a default value of Output.txt
|
||||||
|
parse_my_file = ParseOutput.new
|
||||||
|
|
||||||
|
if ARGV.size >= 1
|
||||||
|
ARGV.each do |a|
|
||||||
|
if a == '-xml'
|
||||||
|
parse_my_file.set_xml_output
|
||||||
|
else
|
||||||
|
parse_my_file.process(a)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -23,37 +23,37 @@ class ArgvParser
|
|||||||
options.root_path = '.'
|
options.root_path = '.'
|
||||||
options.out_file = 'results.xml'
|
options.out_file = 'results.xml'
|
||||||
|
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |o|
|
||||||
opts.banner = 'Usage: unity_to_junit.rb [options]'
|
o.banner = 'Usage: unity_to_junit.rb [options]'
|
||||||
|
|
||||||
opts.separator ''
|
o.separator ''
|
||||||
opts.separator 'Specific options:'
|
o.separator 'Specific options:'
|
||||||
|
|
||||||
opts.on('-r', '--results <dir>', 'Look for Unity Results files here.') do |results|
|
o.on('-r', '--results <dir>', 'Look for Unity Results files here.') do |results|
|
||||||
# puts "results #{results}"
|
# puts "results #{results}"
|
||||||
options.results_dir = results
|
options.results_dir = results
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('-p', '--root_path <path>', 'Prepend this path to files in results.') do |root_path|
|
o.on('-p', '--root_path <path>', 'Prepend this path to files in results.') do |root_path|
|
||||||
options.root_path = root_path
|
options.root_path = root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('-o', '--output <filename>', 'XML file to generate.') do |out_file|
|
o.on('-o', '--output <filename>', 'XML file to generate.') do |out_file|
|
||||||
# puts "out_file: #{out_file}"
|
# puts "out_file: #{out_file}"
|
||||||
options.out_file = out_file
|
options.out_file = out_file
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.separator ''
|
o.separator ''
|
||||||
opts.separator 'Common options:'
|
o.separator 'Common options:'
|
||||||
|
|
||||||
# No argument, shows at tail. This will print an options summary.
|
# No argument, shows at tail. This will print an options summary.
|
||||||
opts.on_tail('-h', '--help', 'Show this message') do
|
o.on_tail('-h', '--help', 'Show this message') do
|
||||||
puts opts
|
puts o
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
# Another typical switch to print the version.
|
# Another typical switch to print the version.
|
||||||
opts.on_tail('--version', 'Show version') do
|
o.on_tail('--version', 'Show version') do
|
||||||
puts "unity_to_junit.rb version #{VERSION}"
|
puts "unity_to_junit.rb version #{VERSION}"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
@@ -67,6 +67,7 @@ end # class OptparseExample
|
|||||||
class UnityToJUnit
|
class UnityToJUnit
|
||||||
include FileUtils::Verbose
|
include FileUtils::Verbose
|
||||||
attr_reader :report, :total_tests, :failures, :ignored
|
attr_reader :report, :total_tests, :failures, :ignored
|
||||||
|
attr_writer :targets, :root, :out_file
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@report = ''
|
@report = ''
|
||||||
@@ -82,16 +83,16 @@ class UnityToJUnit
|
|||||||
write_suites_header(f)
|
write_suites_header(f)
|
||||||
results.each do |result_file|
|
results.each do |result_file|
|
||||||
lines = File.readlines(result_file).map(&:chomp)
|
lines = File.readlines(result_file).map(&:chomp)
|
||||||
if lines.empty?
|
|
||||||
raise "Empty test result file: #{result_file}"
|
raise "Empty test result file: #{result_file}" if lines.empty?
|
||||||
else
|
|
||||||
result_output = get_details(result_file, lines)
|
result_output = get_details(result_file, lines)
|
||||||
tests, failures, ignored = parse_test_summary(lines)
|
tests, failures, ignored = parse_test_summary(lines)
|
||||||
result_output[:counts][:total] = tests
|
result_output[:counts][:total] = tests
|
||||||
result_output[:counts][:failed] = failures
|
result_output[:counts][:failed] = failures
|
||||||
result_output[:counts][:ignored] = ignored
|
result_output[:counts][:ignored] = ignored
|
||||||
result_output[:counts][:passed] = (result_output[:counts][:total] - result_output[:counts][:failed] - result_output[:counts][:ignored])
|
result_output[:counts][:passed] = (result_output[:counts][:total] - result_output[:counts][:failed] - result_output[:counts][:ignored])
|
||||||
end
|
|
||||||
# use line[0] from the test output to get the test_file path and name
|
# use line[0] from the test output to get the test_file path and name
|
||||||
test_file_str = lines[0].tr('\\', '/')
|
test_file_str = lines[0].tr('\\', '/')
|
||||||
test_file_str = test_file_str.split(':')
|
test_file_str = test_file_str.split(':')
|
||||||
@@ -99,7 +100,7 @@ class UnityToJUnit
|
|||||||
result_file
|
result_file
|
||||||
else
|
else
|
||||||
test_file_str[0] + ':' + test_file_str[1]
|
test_file_str[0] + ':' + test_file_str[1]
|
||||||
end
|
end
|
||||||
result_output[:source][:path] = File.dirname(test_file)
|
result_output[:source][:path] = File.dirname(test_file)
|
||||||
result_output[:source][:file] = File.basename(test_file)
|
result_output[:source][:file] = File.basename(test_file)
|
||||||
|
|
||||||
@@ -116,18 +117,6 @@ class UnityToJUnit
|
|||||||
f.close
|
f.close
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_targets(target_array)
|
|
||||||
@targets = target_array
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_root_path(path)
|
|
||||||
@root = path
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_out_file(filename)
|
|
||||||
@out_file = filename
|
|
||||||
end
|
|
||||||
|
|
||||||
def usage(err_msg = nil)
|
def usage(err_msg = nil)
|
||||||
puts "\nERROR: "
|
puts "\nERROR: "
|
||||||
puts err_msg if err_msg
|
puts err_msg if err_msg
|
||||||
@@ -148,11 +137,10 @@ class UnityToJUnit
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def get_details(_result_file, lines)
|
def get_details(_result_file, lines)
|
||||||
results = get_results_structure
|
results = results_structure
|
||||||
lines.each do |line|
|
lines.each do |line|
|
||||||
line = line.tr('\\', '/')
|
line = line.tr('\\', '/')
|
||||||
src_file, src_line, test_name, status, msg = line.split(/:/)
|
_src_file, src_line, test_name, status, msg = line.split(/:/)
|
||||||
line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\')
|
|
||||||
case status
|
case status
|
||||||
when 'IGNORE' then results[:ignores] << { test: test_name, line: src_line, message: msg }
|
when 'IGNORE' then results[:ignores] << { test: test_name, line: src_line, message: msg }
|
||||||
when 'FAIL' then results[:failures] << { test: test_name, line: src_line, message: msg }
|
when 'FAIL' then results[:failures] << { test: test_name, line: src_line, message: msg }
|
||||||
@@ -163,11 +151,8 @@ class UnityToJUnit
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_test_summary(summary)
|
def parse_test_summary(summary)
|
||||||
if summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
|
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]
|
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||||
else
|
|
||||||
raise "Couldn't parse test results: #{summary}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def here
|
def here
|
||||||
@@ -176,7 +161,7 @@ class UnityToJUnit
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_results_structure
|
def results_structure
|
||||||
{
|
{
|
||||||
source: { path: '', file: '' },
|
source: { path: '', file: '' },
|
||||||
successes: [],
|
successes: [],
|
||||||
@@ -213,7 +198,6 @@ class UnityToJUnit
|
|||||||
def write_tests(results, stream)
|
def write_tests(results, stream)
|
||||||
result = results[:successes]
|
result = results[:successes]
|
||||||
result.each do |item|
|
result.each do |item|
|
||||||
filename = File.join(results[:source][:path], File.basename(results[:source][:file], '.*'))
|
|
||||||
stream.puts "\t\t<testcase classname=\"#{@unit_name}\" name=\"#{item[:test]}\" time=\"0\" />"
|
stream.puts "\t\t<testcase classname=\"#{@unit_name}\" name=\"#{item[:test]}\" time=\"0\" />"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -239,7 +223,7 @@ class UnityToJUnit
|
|||||||
end
|
end
|
||||||
end # UnityToJUnit
|
end # UnityToJUnit
|
||||||
|
|
||||||
if __FILE__ == $PROGRAM_NAME
|
if __FILE__ == $0
|
||||||
# parse out the command options
|
# parse out the command options
|
||||||
options = ArgvParser.parse(ARGV)
|
options = ArgvParser.parse(ARGV)
|
||||||
|
|
||||||
@@ -251,18 +235,18 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
|
|
||||||
results = Dir[targets]
|
results = Dir[targets]
|
||||||
raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty?
|
raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty?
|
||||||
utj.set_targets(results)
|
utj.targets = results
|
||||||
|
|
||||||
# set the root path
|
# set the root path
|
||||||
utj.set_root_path(options.root_path)
|
utj.root = options.root_path
|
||||||
|
|
||||||
# set the output XML file name
|
# set the output XML file name
|
||||||
# puts "Output File from options: #{options.out_file}"
|
# puts "Output File from options: #{options.out_file}"
|
||||||
utj.set_out_file(options.out_file)
|
utj.out_file = options.out_file
|
||||||
|
|
||||||
# run the summarizer
|
# run the summarizer
|
||||||
puts utj.run
|
puts utj.run
|
||||||
rescue Exception => e
|
rescue StandardError => e
|
||||||
utj.usage e.message
|
utj.usage e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,15 +10,16 @@ module RakefileHelpers
|
|||||||
class TestFileFilter
|
class TestFileFilter
|
||||||
def initialize(all_files = false)
|
def initialize(all_files = false)
|
||||||
@all_files = all_files
|
@all_files = all_files
|
||||||
if @all_files != true
|
|
||||||
if File.exist?('test_file_filter.yml')
|
return false unless @all_files
|
||||||
filters = YAML.load_file('test_file_filter.yml')
|
return false unless File.exist?('test_file_filter.yml')
|
||||||
@all_files = filters[:all_files]
|
|
||||||
@only_files = filters[:only_files]
|
filters = YAML.load_file('test_file_filter.yml')
|
||||||
@exclude_files = filters[:exclude_files]
|
@all_files = filters[:all_files]
|
||||||
end
|
@only_files = filters[:only_files]
|
||||||
end
|
@exclude_files = filters[:exclude_files]
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :all_files, :only_files, :exclude_files
|
attr_accessor :all_files, :only_files, :exclude_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class UnityTestSummary
|
|||||||
include FileUtils::Verbose
|
include FileUtils::Verbose
|
||||||
|
|
||||||
attr_reader :report, :total_tests, :failures, :ignored
|
attr_reader :report, :total_tests, :failures, :ignored
|
||||||
|
attr_writer :targets, :root
|
||||||
|
|
||||||
def initialize(_opts = {})
|
def initialize(_opts = {})
|
||||||
@report = ''
|
@report = ''
|
||||||
@@ -33,17 +34,16 @@ class UnityTestSummary
|
|||||||
|
|
||||||
results.each do |result_file|
|
results.each do |result_file|
|
||||||
lines = File.readlines(result_file).map(&:chomp)
|
lines = File.readlines(result_file).map(&:chomp)
|
||||||
if lines.empty?
|
|
||||||
raise "Empty test result file: #{result_file}"
|
raise "Empty test result file: #{result_file}" if lines.empty?
|
||||||
else
|
|
||||||
output = get_details(result_file, lines)
|
output = get_details(result_file, lines)
|
||||||
failure_output << output[:failures] unless output[:failures].empty?
|
failure_output << output[:failures] unless output[:failures].empty?
|
||||||
ignore_output << output[:ignores] unless output[:ignores].empty?
|
ignore_output << output[:ignores] unless output[:ignores].empty?
|
||||||
tests, failures, ignored = parse_test_summary(lines)
|
tests, failures, ignored = parse_test_summary(lines)
|
||||||
@total_tests += tests
|
@total_tests += tests
|
||||||
@failures += failures
|
@failures += failures
|
||||||
@ignored += ignored
|
@ignored += ignored
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if @ignored > 0
|
if @ignored > 0
|
||||||
@@ -70,14 +70,6 @@ class UnityTestSummary
|
|||||||
@report += "\n"
|
@report += "\n"
|
||||||
end
|
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 "\nERROR: "
|
||||||
puts err_msg if err_msg
|
puts err_msg if err_msg
|
||||||
@@ -94,7 +86,7 @@ class UnityTestSummary
|
|||||||
def get_details(_result_file, lines)
|
def get_details(_result_file, lines)
|
||||||
results = { failures: [], ignores: [], successes: [] }
|
results = { failures: [], ignores: [], successes: [] }
|
||||||
lines.each do |line|
|
lines.each do |line|
|
||||||
src_file, src_line, test_name, status, msg = line.split(/:/)
|
_src_file, _src_line, _test_name, status, _msg = line.split(/:/)
|
||||||
line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\')
|
line_out = (@root && (@root != 0) ? "#{@root}#{line}" : line).gsub(/\//, '\\')
|
||||||
case status
|
case status
|
||||||
when 'IGNORE' then results[:ignores] << line_out
|
when 'IGNORE' then results[:ignores] << line_out
|
||||||
@@ -106,11 +98,8 @@ class UnityTestSummary
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_test_summary(summary)
|
def parse_test_summary(summary)
|
||||||
if summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
|
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]
|
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||||
else
|
|
||||||
raise "Couldn't parse test results: #{summary}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def here
|
def here
|
||||||
@@ -118,7 +107,7 @@ class UnityTestSummary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if $PROGRAM_NAME == __FILE__
|
if $0 == __FILE__
|
||||||
|
|
||||||
# parse out the command options
|
# parse out the command options
|
||||||
opts, args = ARGV.partition { |v| v =~ /^--\w+/ }
|
opts, args = ARGV.partition { |v| v =~ /^--\w+/ }
|
||||||
@@ -133,15 +122,15 @@ if $PROGRAM_NAME == __FILE__
|
|||||||
targets = "#{ARGV[0].tr('\\', '/')}**/*.test*"
|
targets = "#{ARGV[0].tr('\\', '/')}**/*.test*"
|
||||||
results = Dir[targets]
|
results = Dir[targets]
|
||||||
raise "No *.testpass, *.testfail, or *.testresults files found in '#{targets}'" if results.empty?
|
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 + '/'
|
args[1] ||= Dir.pwd + '/'
|
||||||
uts.set_root_path(ARGV[1])
|
uts.root = ARGV[1]
|
||||||
|
|
||||||
# run the summarizer
|
# run the summarizer
|
||||||
puts uts.run
|
puts uts.run
|
||||||
rescue Exception => e
|
rescue StandardError => e
|
||||||
uts.usage e.message
|
uts.usage e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ DEFAULT_CONFIG_FILE = 'target_gcc_32.yml'.freeze
|
|||||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||||
|
|
||||||
task unit: [:prepare_for_tests] do
|
task unit: [:prepare_for_tests] do
|
||||||
run_tests get_unit_test_files
|
run_tests unit_test_files
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Generate test summary'
|
desc 'Generate test summary'
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ module RakefileHelpers
|
|||||||
configure_clean
|
configure_clean
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_unit_test_files
|
def unit_test_files
|
||||||
path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION
|
path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION
|
||||||
path.tr!('\\', '/')
|
path.tr!('\\', '/')
|
||||||
FileList.new(path)
|
FileList.new(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_local_include_dirs
|
def local_include_dirs
|
||||||
include_dirs = $cfg['compiler']['includes']['items'].dup
|
include_dirs = $cfg['compiler']['includes']['items'].dup
|
||||||
include_dirs.delete_if { |dir| dir.is_a?(Array) }
|
include_dirs.delete_if { |dir| dir.is_a?(Array) }
|
||||||
include_dirs
|
include_dirs
|
||||||
@@ -69,14 +69,15 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def build_compiler_fields
|
def build_compiler_fields
|
||||||
command = tackit($cfg['compiler']['path'])
|
command = tackit($cfg['compiler']['path'])
|
||||||
if $cfg['compiler']['defines']['items'].nil?
|
defines = if $cfg['compiler']['defines']['items'].nil?
|
||||||
defines = ''
|
''
|
||||||
else
|
else
|
||||||
defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
||||||
end
|
end
|
||||||
options = squash('', $cfg['compiler']['options'])
|
options = squash('', $cfg['compiler']['options'])
|
||||||
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
|
|
||||||
{ command: command, defines: defines, options: options, includes: includes }
|
{ command: command, defines: defines, options: options, includes: includes }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -96,12 +97,12 @@ module RakefileHelpers
|
|||||||
else
|
else
|
||||||
squash('', $cfg['linker']['options'])
|
squash('', $cfg['linker']['options'])
|
||||||
end
|
end
|
||||||
if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
||||||
includes = ''
|
''
|
||||||
else
|
else
|
||||||
includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
||||||
end
|
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
|
||||||
{ command: command, options: options, includes: includes }
|
{ command: command, options: options, includes: includes }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -127,11 +128,12 @@ module RakefileHelpers
|
|||||||
else
|
else
|
||||||
squash('', $cfg['simulator']['pre_support'])
|
squash('', $cfg['simulator']['pre_support'])
|
||||||
end
|
end
|
||||||
if $cfg['simulator']['post_support'].nil?
|
post_support = if $cfg['simulator']['post_support'].nil?
|
||||||
post_support = ''
|
''
|
||||||
else
|
else
|
||||||
post_support = squash('', $cfg['simulator']['post_support'])
|
squash('', $cfg['simulator']['post_support'])
|
||||||
end
|
end
|
||||||
|
|
||||||
{ command: command, pre_support: pre_support, post_support: post_support }
|
{ command: command, pre_support: pre_support, post_support: post_support }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -139,7 +141,7 @@ module RakefileHelpers
|
|||||||
report command_string
|
report command_string
|
||||||
output = `#{command_string}`.chomp
|
output = `#{command_string}`.chomp
|
||||||
report(output) if verbose && !output.nil? && !output.empty?
|
report(output) if verbose && !output.nil? && !output.empty?
|
||||||
if ($?.exitstatus != 0) && raise_on_fail
|
if !$?.exitstatus.zero? && raise_on_fail
|
||||||
raise "Command failed. (Returned #{$?.exitstatus})"
|
raise "Command failed. (Returned #{$?.exitstatus})"
|
||||||
end
|
end
|
||||||
output
|
output
|
||||||
@@ -147,11 +149,11 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.set_root_path(HERE)
|
summary.root = HERE
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
summary.set_targets(results)
|
summary.targets = results
|
||||||
summary.run
|
summary.run
|
||||||
fail_out 'FAIL: There were failures' if summary.failures > 0
|
fail_out 'FAIL: There were failures' if summary.failures > 0
|
||||||
end
|
end
|
||||||
@@ -165,7 +167,7 @@ module RakefileHelpers
|
|||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
$cfg['compiler']['defines']['items'] << 'TEST'
|
$cfg['compiler']['defines']['items'] << 'TEST'
|
||||||
|
|
||||||
include_dirs = get_local_include_dirs
|
include_dirs = local_include_dirs
|
||||||
|
|
||||||
# Build and execute each unit test
|
# Build and execute each unit test
|
||||||
test_files.each do |test|
|
test_files.each do |test|
|
||||||
@@ -200,11 +202,11 @@ module RakefileHelpers
|
|||||||
# Execute unit test and generate results file
|
# Execute unit test and generate results file
|
||||||
simulator = build_simulator_fields
|
simulator = build_simulator_fields
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
if simulator.nil?
|
cmd_str = if simulator.nil?
|
||||||
cmd_str = executable
|
executable
|
||||||
else
|
else
|
||||||
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
end
|
end
|
||||||
output = execute(cmd_str, true, false)
|
output = execute(cmd_str, true, false)
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base
|
test_results = $cfg['compiler']['build_path'] + test_base
|
||||||
test_results += if output.match(/OK$/m).nil?
|
test_results += if output.match(/OK$/m).nil?
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ module RakefileHelpers
|
|||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
unless $configured
|
return if $configured
|
||||||
$cfg_file = HERE + "../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg_file = HERE + "../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
||||||
$colour_output = false unless $cfg['colour']
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
$configured = true if config_file != DEFAULT_CONFIG_FILE
|
$colour_output = false unless $cfg['colour']
|
||||||
end
|
$configured = true if config_file != DEFAULT_CONFIG_FILE
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_clean
|
def configure_clean
|
||||||
@@ -50,14 +50,15 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def build_compiler_fields
|
def build_compiler_fields
|
||||||
command = tackit($cfg['compiler']['path'])
|
command = tackit($cfg['compiler']['path'])
|
||||||
if $cfg['compiler']['defines']['items'].nil?
|
defines = if $cfg['compiler']['defines']['items'].nil?
|
||||||
defines = ''
|
''
|
||||||
else
|
else
|
||||||
defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'])
|
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'])
|
||||||
end
|
end
|
||||||
options = squash('', $cfg['compiler']['options'])
|
options = squash('', $cfg['compiler']['options'])
|
||||||
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
|
|
||||||
{ command: command, defines: defines, options: options, includes: includes }
|
{ command: command, defines: defines, options: options, includes: includes }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ module RakefileHelpers
|
|||||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \
|
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \
|
||||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \
|
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \
|
||||||
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||||
|
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -77,12 +79,12 @@ module RakefileHelpers
|
|||||||
else
|
else
|
||||||
squash('', $cfg['linker']['options'])
|
squash('', $cfg['linker']['options'])
|
||||||
end
|
end
|
||||||
if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
||||||
includes = ''
|
''
|
||||||
else
|
else
|
||||||
includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
||||||
end
|
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
|
||||||
{ command: command, options: options, includes: includes }
|
{ command: command, options: options, includes: includes }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -108,11 +110,11 @@ module RakefileHelpers
|
|||||||
else
|
else
|
||||||
squash('', $cfg['simulator']['pre_support'])
|
squash('', $cfg['simulator']['pre_support'])
|
||||||
end
|
end
|
||||||
if $cfg['simulator']['post_support'].nil?
|
post_support = if $cfg['simulator']['post_support'].nil?
|
||||||
post_support = ''
|
''
|
||||||
else
|
else
|
||||||
post_support = squash('', $cfg['simulator']['post_support'])
|
squash('', $cfg['simulator']['post_support'])
|
||||||
end
|
end
|
||||||
{ command: command, pre_support: pre_support, post_support: post_support }
|
{ command: command, pre_support: pre_support, post_support: post_support }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -126,11 +128,11 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.set_root_path(HERE)
|
summary.root = HERE
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
summary.set_targets(results)
|
summary.targets = results
|
||||||
summary.run
|
summary.run
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -159,11 +161,11 @@ module RakefileHelpers
|
|||||||
# Execute unit test and generate results file
|
# Execute unit test and generate results file
|
||||||
simulator = build_simulator_fields
|
simulator = build_simulator_fields
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
if simulator.nil?
|
cmd_str = if simulator.nil?
|
||||||
cmd_str = executable + ' -v -r'
|
executable + ' -v -r'
|
||||||
else
|
else
|
||||||
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
end
|
end
|
||||||
output = execute(cmd_str)
|
output = execute(cmd_str)
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base
|
test_results = $cfg['compiler']['build_path'] + test_base
|
||||||
test_results += if output.match(/OK$/m).nil?
|
test_results += if output.match(/OK$/m).nil?
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
# This is the configuration used to check the rubocop source code.
|
# This is the configuration used to check the rubocop source code.
|
||||||
|
|
||||||
inherit_from: .rubocop_todo.yml
|
#inherit_from: .rubocop_todo.yml
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 2.1
|
TargetRubyVersion: 2.1
|
||||||
|
|
||||||
# These are areas where ThrowTheSwitch's coding style diverges from the Ruby standard
|
# These are areas where ThrowTheSwitch's coding style diverges from the Ruby standard
|
||||||
# (Maybe we will make these conform over time)
|
|
||||||
Style/SpecialGlobalVars:
|
Style/SpecialGlobalVars:
|
||||||
SupportedStyles:
|
|
||||||
- use_perl_names
|
|
||||||
- use_english_names
|
|
||||||
EnforcedStyle: use_perl_names
|
EnforcedStyle: use_perl_names
|
||||||
Style/FormatString:
|
Style/FormatString:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Style/GlobalVars:
|
||||||
|
Enabled: false
|
||||||
|
Style/RegexpLiteral:
|
||||||
|
AllowInnerSlashes: true
|
||||||
|
Style/HashSyntax:
|
||||||
|
EnforcedStyle: no_mixed_keys
|
||||||
|
|
||||||
# This is disabled because it seems to get confused over nested hashes
|
# This is disabled because it seems to get confused over nested hashes
|
||||||
Style/AlignHash:
|
Style/AlignHash:
|
||||||
@@ -48,6 +50,8 @@ Metrics/LineLength:
|
|||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Metrics/ModuleLength:
|
||||||
|
Enabled: false
|
||||||
Metrics/ParameterLists:
|
Metrics/ParameterLists:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
|
|||||||
@@ -1,443 +0,0 @@
|
|||||||
# This configuration was generated by
|
|
||||||
# `rubocop --auto-gen-config`
|
|
||||||
# on 2017-03-28 15:45:51 -0400 using RuboCop version 0.48.0.
|
|
||||||
# The point is for the user to remove these configuration records
|
|
||||||
# one by one as the offenses are removed from the code base.
|
|
||||||
# Note that changes in the inspected code, or installation of new
|
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Lint/DeprecatedClassMethods:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 6
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
|
|
||||||
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
|
||||||
Lint/EndAlignment:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/colour_prompt.rb'
|
|
||||||
- '../auto/colour_reporter.rb'
|
|
||||||
- '../auto/parseOutput.rb'
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
Lint/RescueException:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
- '../auto/unity_test_summary.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
Lint/ShadowingOuterLocalVariable:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Lint/StringConversionInInterpolation:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 13
|
|
||||||
Lint/UselessAssignment:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
- '../auto/unity_test_summary.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 5
|
|
||||||
Lint/Void:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/parseOutput.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Configuration parameters: CountComments.
|
|
||||||
Metrics/ModuleLength:
|
|
||||||
Max: 204
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Performance/StringReplacement:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 10
|
|
||||||
Style/AccessorMethodName:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
- '../auto/unity_test_summary.rb'
|
|
||||||
- '../examples/example_3/rakefile_helper.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
|
||||||
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
|
||||||
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
||||||
# FunctionalMethods: let, let!, subject, watch
|
|
||||||
# IgnoredMethods: lambda, proc, it
|
|
||||||
Style/BlockDelimiters:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 17
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
|
||||||
# SupportedStyles: assign_to_condition, assign_inside_condition
|
|
||||||
Style/ConditionalAssignment:
|
|
||||||
Exclude:
|
|
||||||
- '../examples/example_3/rakefile_helper.rb'
|
|
||||||
- '../extras/fixture/rakefile_helper.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/ElseAlignment:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/EmptyLines:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 4
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: empty_lines, no_empty_lines
|
|
||||||
Style/EmptyLinesAroundBlockBody:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
|
||||||
Style/EmptyLinesAroundModuleBody:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 14
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
|
||||||
Style/ExtraSpacing:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
||||||
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
||||||
Style/FileName:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/parseOutput.rb'
|
|
||||||
|
|
||||||
# Offense count: 164
|
|
||||||
# Configuration parameters: AllowedVariables.
|
|
||||||
Style/GlobalVars:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/colour_reporter.rb'
|
|
||||||
- '../examples/example_3/rakefile_helper.rb'
|
|
||||||
- '../extras/fixture/rakefile.rb'
|
|
||||||
- '../extras/fixture/rakefile_helper.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 20
|
|
||||||
# Configuration parameters: MinBodyLength.
|
|
||||||
Style/GuardClause:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/colour_prompt.rb'
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- '../auto/parseOutput.rb'
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
- '../auto/test_file_filter.rb'
|
|
||||||
- '../auto/unity_test_summary.rb'
|
|
||||||
- '../extras/fixture/rakefile_helper.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 630
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
|
||||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
|
||||||
Style/HashSyntax:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: MaxLineLength.
|
|
||||||
Style/IfUnlessModifier:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: IndentationWidth.
|
|
||||||
Style/IndentAssignment:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 5
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: Width, IgnoredPatterns.
|
|
||||||
Style/IndentationWidth:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 17
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/LeadingCommentSpace:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/LineEndConcatenation:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 8
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: snake_case, camelCase
|
|
||||||
Style/MethodName:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/parseOutput.rb'
|
|
||||||
|
|
||||||
# Offense count: 40
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: symmetrical, new_line, same_line
|
|
||||||
Style/MultilineArrayBraceLayout:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 63
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: symmetrical, new_line, same_line
|
|
||||||
Style/MultilineHashBraceLayout:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 4
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
|
||||||
# SupportedStyles: aligned, indented
|
|
||||||
Style/MultilineOperationIndentation:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/MutableConstant:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 4
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: both, prefix, postfix
|
|
||||||
Style/NegatedIf:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/Not:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: predicate, comparison
|
|
||||||
Style/NumericPredicate:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/**/*'
|
|
||||||
- '../auto/colour_reporter.rb'
|
|
||||||
|
|
||||||
# Offense count: 17
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AllowSafeAssignment.
|
|
||||||
Style/ParenthesesAroundCondition:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 7
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/RedundantParentheses:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 13
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AllowMultipleReturnValues.
|
|
||||||
Style/RedundantReturn:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 13
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
|
||||||
# SupportedStyles: slashes, percent_r, mixed
|
|
||||||
Style/RegexpLiteral:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
- '../auto/type_sanitizer.rb'
|
|
||||||
- '../auto/unity_test_summary.rb'
|
|
||||||
- '../extras/fixture/rakefile_helper.rb'
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 4
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AllowAsExpressionSeparator.
|
|
||||||
Style/Semicolon:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 5
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/SpaceAfterComma:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyleInsidePipes, SupportedStylesInsidePipes.
|
|
||||||
# SupportedStylesInsidePipes: space, no_space
|
|
||||||
Style/SpaceAroundBlockParameters:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: space, no_space
|
|
||||||
Style/SpaceAroundEqualsInParameterDefault:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: AllowForAlignment.
|
|
||||||
Style/SpaceAroundOperators:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: space, no_space
|
|
||||||
Style/SpaceBeforeBlockBraces:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 13
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
|
|
||||||
# SupportedStyles: space, no_space
|
|
||||||
# SupportedStylesForEmptyBraces: space, no_space
|
|
||||||
Style/SpaceInsideBlockBraces:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 295
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/SpaceInsideBrackets:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 6
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
|
|
||||||
# SupportedStyles: space, no_space, compact
|
|
||||||
# SupportedStylesForEmptyBraces: space, no_space
|
|
||||||
Style/SpaceInsideHashLiteralBraces:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 5
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/SpaceInsideParens:
|
|
||||||
Exclude:
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: use_perl_names, use_english_names
|
|
||||||
Style/SpecialGlobalVars:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/generate_test_runner.rb'
|
|
||||||
- '../auto/stylize_as_junit.rb'
|
|
||||||
- '../auto/unity_test_summary.rb'
|
|
||||||
|
|
||||||
# Offense count: 167
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
|
|
||||||
# SupportedStyles: single_quotes, double_quotes
|
|
||||||
Style/StringLiterals:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
|
|
||||||
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
|
||||||
Style/TernaryParentheses:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 152
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
|
|
||||||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
|
||||||
Style/TrailingCommaInLiteral:
|
|
||||||
Exclude:
|
|
||||||
- 'spec/generate_module_existing_file_spec.rb'
|
|
||||||
- 'tests/test_generate_test_runner.rb'
|
|
||||||
|
|
||||||
# Offense count: 39
|
|
||||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
||||||
# SupportedStyles: snake_case, camelCase
|
|
||||||
Style/VariableName:
|
|
||||||
Exclude:
|
|
||||||
- '../auto/parseOutput.rb'
|
|
||||||
|
|
||||||
# Offense count: 69
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: SupportedStyles, WordRegex.
|
|
||||||
# SupportedStyles: percent, brackets
|
|
||||||
Style/WordArray:
|
|
||||||
EnforcedStyle: percent
|
|
||||||
MinSize: 12
|
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
Style/ZeroLengthPredicate:
|
|
||||||
Exclude:
|
|
||||||
- 'rakefile_helper.rb'
|
|
||||||
@@ -32,7 +32,7 @@ configure_toolchain(DEFAULT_CONFIG_FILE)
|
|||||||
|
|
||||||
desc "Test unity with its own unit tests"
|
desc "Test unity with its own unit tests"
|
||||||
task :unit => [:prepare_for_tests] do
|
task :unit => [:prepare_for_tests] do
|
||||||
run_tests get_unit_test_files
|
run_tests unit_test_files
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Test unity's helper scripts"
|
desc "Test unity's helper scripts"
|
||||||
@@ -74,32 +74,35 @@ end
|
|||||||
namespace :style do
|
namespace :style do
|
||||||
desc "Check style"
|
desc "Check style"
|
||||||
task :check do
|
task :check do
|
||||||
report execute("rubocop ../ --config .rubocop.yml", true)
|
report "\nVERIFYING RUBY STYLE"
|
||||||
report "Style Checked."
|
report execute("rubocop ../auto ../examples ../extras --config .rubocop.yml", true)
|
||||||
|
report "Style PASSED."
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :check do
|
namespace :check do
|
||||||
Dir['../**/*.rb'].each do |f|
|
Dir['../**/*.rb'].each do |f|
|
||||||
task File.basename(f, '.rb').to_sym do
|
task File.basename(f, '.rb').to_sym => ['style:clean'] do
|
||||||
report execute("rubocop #{f} --color --config .rubocop.yml", true)
|
report execute("rubocop #{f} --color --config .rubocop.yml", true)
|
||||||
report "Style Checked."
|
report "Style Checked for #{f}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Attempt to Autocorrect style"
|
desc "Attempt to Autocorrect style"
|
||||||
task :auto do
|
task :auto => ['style:clean'] do
|
||||||
File.delete(".rubocop_todo.yml")
|
execute("rubocop ../auto ../examples ../extras --auto-correct --config .rubocop.yml")
|
||||||
execute("rubocop ../ --auto-correct --config .rubocop.yml")
|
|
||||||
report "Autocorrected What We Could."
|
report "Autocorrected What We Could."
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Update style todo list"
|
desc "Update style todo list"
|
||||||
task :todo do
|
task :todo => ['style:clean'] do
|
||||||
File.delete(".rubocop_todo.yml")
|
execute("rubocop ../auto ../examples ../extras --auto-gen-config --config .rubocop.yml")
|
||||||
execute("rubocop ../ --auto-gen-config --config .rubocop.yml")
|
|
||||||
report "Updated Style TODO List."
|
report "Updated Style TODO List."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :clean do
|
||||||
|
File.delete(".rubocop_todo.yml") if File.exists?(".rubocop_todo.yml")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :style => ['style:check']
|
task :style => ['style:check']
|
||||||
|
|||||||
@@ -11,39 +11,37 @@ require UNITY_ROOT + '../auto/generate_test_runner'
|
|||||||
require UNITY_ROOT + '../auto/colour_reporter'
|
require UNITY_ROOT + '../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
|
C_EXTENSION = '.c'.freeze
|
||||||
C_EXTENSION = '.c'
|
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
unless ($configured)
|
return if $configured
|
||||||
$cfg_file = "targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
|
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg_file = "targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
||||||
$colour_output = false unless $cfg['colour']
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
$configured = true if (config_file != DEFAULT_CONFIG_FILE)
|
$colour_output = false unless $cfg['colour']
|
||||||
end
|
$configured = true if config_file != DEFAULT_CONFIG_FILE
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_clean
|
def configure_clean
|
||||||
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
|
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
|
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
|
||||||
config_file += '.yml' unless config_file =~ /\.yml$/
|
config_file += '.yml' unless config_file =~ /\.yml$/
|
||||||
config_file = config_file unless config_file =~ /[\\|\/]/
|
config_file = config_file unless config_file =~ /[\\|\/]/
|
||||||
load_configuration(config_file)
|
load_configuration(config_file)
|
||||||
configure_clean
|
configure_clean
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_unit_test_files
|
def unit_test_files
|
||||||
path = $cfg['compiler']['unit_tests_path'] + 'test*' + C_EXTENSION
|
path = $cfg['compiler']['unit_tests_path'] + 'test*' + C_EXTENSION
|
||||||
path.gsub!(/\\/, '/')
|
path.tr!('\\', '/')
|
||||||
FileList.new(path)
|
FileList.new(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_local_include_dirs
|
def local_include_dirs
|
||||||
include_dirs = $cfg['compiler']['includes']['items'].dup
|
include_dirs = $cfg['compiler']['includes']['items'].dup
|
||||||
include_dirs.delete_if {|dir| dir.is_a?(Array)}
|
include_dirs.delete_if { |dir| dir.is_a?(Array) }
|
||||||
return include_dirs
|
include_dirs
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_headers(filename)
|
def extract_headers(filename)
|
||||||
@@ -51,41 +49,37 @@ module RakefileHelpers
|
|||||||
lines = File.readlines(filename)
|
lines = File.readlines(filename)
|
||||||
lines.each do |line|
|
lines.each do |line|
|
||||||
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
|
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
|
||||||
if not m.nil?
|
includes << m[1] unless m.nil?
|
||||||
includes << m[1]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return includes
|
includes
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_source_file(header, paths)
|
def find_source_file(header, paths)
|
||||||
paths.each do |dir|
|
paths.each do |dir|
|
||||||
src_file = dir + header.ext(C_EXTENSION)
|
src_file = dir + header.ext(C_EXTENSION)
|
||||||
if (File.exists?(src_file))
|
return src_file if File.exist?(src_file)
|
||||||
return src_file
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def tackit(strings)
|
def tackit(strings)
|
||||||
if strings.is_a?(Array)
|
result = if strings.is_a?(Array)
|
||||||
result = "\"#{strings.join}\""
|
"\"#{strings.join}\""
|
||||||
else
|
else
|
||||||
result = strings
|
strings
|
||||||
end
|
end
|
||||||
return result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def squash(prefix, items)
|
def squash(prefix, items)
|
||||||
result = ''
|
result = ''
|
||||||
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
||||||
return result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def should(behave, &block)
|
def should(behave, &block)
|
||||||
if block
|
if block
|
||||||
puts "Should " + behave
|
puts 'Should ' + behave
|
||||||
yield block
|
yield block
|
||||||
else
|
else
|
||||||
puts "UNIMPLEMENTED CASE: Should #{behave}"
|
puts "UNIMPLEMENTED CASE: Should #{behave}"
|
||||||
@@ -93,91 +87,91 @@ module RakefileHelpers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_compiler_fields(inject_defines)
|
def build_compiler_fields(inject_defines)
|
||||||
command = tackit($cfg['compiler']['path'])
|
command = tackit($cfg['compiler']['path'])
|
||||||
if $cfg['compiler']['defines']['items'].nil?
|
defines = if $cfg['compiler']['defines']['items'].nil?
|
||||||
defines = ''
|
''
|
||||||
else
|
else
|
||||||
defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + inject_defines)
|
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + inject_defines)
|
||||||
end
|
end
|
||||||
options = squash('', $cfg['compiler']['options'])
|
options = squash('', $cfg['compiler']['options'])
|
||||||
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
return {:command => command, :defines => defines, :options => options, :includes => includes}
|
|
||||||
|
{ :command => command, :defines => defines, :options => options, :includes => includes }
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile(file, defines=[])
|
def compile(file, defines = [])
|
||||||
compiler = build_compiler_fields(defines)
|
compiler = build_compiler_fields(defines)
|
||||||
defines =
|
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \
|
||||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
|
||||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
||||||
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||||
execute(cmd_str + obj_file)
|
execute(cmd_str + obj_file)
|
||||||
return obj_file
|
|
||||||
|
obj_file
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_linker_fields
|
def build_linker_fields
|
||||||
command = tackit($cfg['linker']['path'])
|
command = tackit($cfg['linker']['path'])
|
||||||
if $cfg['linker']['options'].nil?
|
options = if $cfg['linker']['options'].nil?
|
||||||
options = ''
|
''
|
||||||
else
|
else
|
||||||
options = squash('', $cfg['linker']['options'])
|
squash('', $cfg['linker']['options'])
|
||||||
end
|
end
|
||||||
if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?)
|
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
||||||
includes = ''
|
''
|
||||||
else
|
else
|
||||||
includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
||||||
end
|
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
|
||||||
return {:command => command, :options => options, :includes => includes}
|
{ :command => command, :options => options, :includes => includes }
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_it(exe_name, obj_list)
|
def link_it(exe_name, obj_list)
|
||||||
linker = build_linker_fields
|
linker = build_linker_fields
|
||||||
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
||||||
(obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).join +
|
(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join +
|
||||||
$cfg['linker']['bin_files']['prefix'] + ' ' +
|
$cfg['linker']['bin_files']['prefix'] + ' ' +
|
||||||
$cfg['linker']['bin_files']['destination'] +
|
$cfg['linker']['bin_files']['destination'] +
|
||||||
exe_name + $cfg['linker']['bin_files']['extension']
|
exe_name + $cfg['linker']['bin_files']['extension']
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_simulator_fields
|
def build_simulator_fields
|
||||||
return nil if $cfg['simulator'].nil?
|
return nil if $cfg['simulator'].nil?
|
||||||
if $cfg['simulator']['path'].nil?
|
command = if $cfg['simulator']['path'].nil?
|
||||||
command = ''
|
''
|
||||||
else
|
else
|
||||||
command = (tackit($cfg['simulator']['path']) + ' ')
|
(tackit($cfg['simulator']['path']) + ' ')
|
||||||
end
|
end
|
||||||
if $cfg['simulator']['pre_support'].nil?
|
pre_support = if $cfg['simulator']['pre_support'].nil?
|
||||||
pre_support = ''
|
''
|
||||||
else
|
else
|
||||||
pre_support = squash('', $cfg['simulator']['pre_support'])
|
squash('', $cfg['simulator']['pre_support'])
|
||||||
end
|
end
|
||||||
if $cfg['simulator']['post_support'].nil?
|
post_support = if $cfg['simulator']['post_support'].nil?
|
||||||
post_support = ''
|
''
|
||||||
else
|
else
|
||||||
post_support = squash('', $cfg['simulator']['post_support'])
|
squash('', $cfg['simulator']['post_support'])
|
||||||
end
|
end
|
||||||
return {:command => command, :pre_support => pre_support, :post_support => post_support}
|
|
||||||
|
{ :command => command, :pre_support => pre_support, :post_support => post_support }
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(command_string, ok_to_fail=false)
|
def execute(command_string, ok_to_fail = false)
|
||||||
report command_string if $verbose
|
report command_string if $verbose
|
||||||
output = `#{command_string}`.chomp
|
output = `#{command_string}`.chomp
|
||||||
report(output) if ($verbose && !output.nil? && (output.length > 0))
|
report(output) if $verbose && !output.nil? && !output.empty?
|
||||||
if (($?.exitstatus != 0) && !ok_to_fail)
|
raise "Command failed. (Returned #{$?.exitstatus})" if !$?.exitstatus.zero? && !ok_to_fail
|
||||||
raise "Command failed. (Returned #{$?.exitstatus})"
|
output
|
||||||
end
|
|
||||||
return output
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.set_root_path(UNITY_ROOT)
|
summary.root = UNITY_ROOT
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.gsub!(/\\/, '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
summary.set_targets(results)
|
summary.targets = results
|
||||||
report summary.run
|
report summary.run
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -187,16 +181,16 @@ module RakefileHelpers
|
|||||||
# Tack on TEST define for compiling unit tests
|
# Tack on TEST define for compiling unit tests
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
test_defines = ['TEST']
|
test_defines = ['TEST']
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] ||= []
|
||||||
$cfg['compiler']['defines']['items'] << 'TEST'
|
$cfg['compiler']['defines']['items'] << 'TEST'
|
||||||
|
|
||||||
include_dirs = get_local_include_dirs
|
include_dirs = local_include_dirs
|
||||||
|
|
||||||
# Build and execute each unit test
|
# Build and execute each unit test
|
||||||
test_files.each do |test|
|
test_files.each do |test|
|
||||||
obj_list = []
|
obj_list = []
|
||||||
|
|
||||||
if !$cfg['compiler']['aux_sources'].nil?
|
unless $cfg['compiler']['aux_sources'].nil?
|
||||||
$cfg['compiler']['aux_sources'].each do |aux|
|
$cfg['compiler']['aux_sources'].each do |aux|
|
||||||
obj_list << compile(aux, test_defines)
|
obj_list << compile(aux, test_defines)
|
||||||
end
|
end
|
||||||
@@ -206,25 +200,23 @@ module RakefileHelpers
|
|||||||
extract_headers(test).each do |header|
|
extract_headers(test).each do |header|
|
||||||
# Compile corresponding source file if it exists
|
# Compile corresponding source file if it exists
|
||||||
src_file = find_source_file(header, include_dirs)
|
src_file = find_source_file(header, include_dirs)
|
||||||
if !src_file.nil?
|
|
||||||
obj_list << compile(src_file, test_defines)
|
obj_list << compile(src_file, test_defines) unless src_file.nil?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Build the test runner (generate if configured to do so)
|
# Build the test runner (generate if configured to do so)
|
||||||
test_base = File.basename(test, C_EXTENSION)
|
test_base = File.basename(test, C_EXTENSION)
|
||||||
|
|
||||||
runner_name = test_base + '_Runner.c'
|
runner_name = test_base + '_Runner.c'
|
||||||
runner_path = ''
|
|
||||||
|
|
||||||
if $cfg['compiler']['runner_path'].nil?
|
runner_path = if $cfg['compiler']['runner_path'].nil?
|
||||||
runner_path = $cfg['compiler']['build_path'] + runner_name
|
$cfg['compiler']['build_path'] + runner_name
|
||||||
else
|
else
|
||||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
$cfg['compiler']['runner_path'] + runner_name
|
||||||
end
|
end
|
||||||
|
|
||||||
options = $cfg[:unity]
|
options = $cfg[:unity]
|
||||||
options[:use_param_tests] = (test =~ /parameterized/) ? true : false
|
options[:use_param_tests] = test =~ /parameterized/ ? true : false
|
||||||
UnityTestRunnerGenerator.new(options).run(test, runner_path)
|
UnityTestRunnerGenerator.new(options).run(test, runner_path)
|
||||||
obj_list << compile(runner_path, test_defines)
|
obj_list << compile(runner_path, test_defines)
|
||||||
|
|
||||||
@@ -237,21 +229,20 @@ module RakefileHelpers
|
|||||||
# Execute unit test and generate results file
|
# Execute unit test and generate results file
|
||||||
simulator = build_simulator_fields
|
simulator = build_simulator_fields
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
if simulator.nil?
|
cmd_str = if simulator.nil?
|
||||||
cmd_str = executable
|
executable
|
||||||
else
|
else
|
||||||
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
end
|
end
|
||||||
output = execute(cmd_str)
|
output = execute(cmd_str)
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base
|
test_results = $cfg['compiler']['build_path'] + test_base
|
||||||
if output.match(/OK$/m).nil?
|
if output.match(/OK$/m).nil?
|
||||||
test_results += '.testfail'
|
test_results += '.testfail'
|
||||||
else
|
else
|
||||||
report output if (!$verbose) #verbose already prints this line, as does a failure
|
report output unless $verbose # Verbose already prints this line, as does a failure
|
||||||
test_results += '.testpass'
|
test_results += '.testpass'
|
||||||
end
|
end
|
||||||
File.open(test_results, 'w') { |f| f.print output }
|
File.open(test_results, 'w') { |f| f.print output }
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user