mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-08-06 13:50:49 +08:00
Updated to newer coding standard
This commit is contained in:
@ -22,6 +22,7 @@ end
|
|||||||
class ColourCommandLine
|
class ColourCommandLine
|
||||||
def initialize
|
def initialize
|
||||||
return unless 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')
|
||||||
|
@ -264,6 +264,7 @@ if $0 == __FILE__
|
|||||||
when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config(Regexp.last_match(1))
|
when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config(Regexp.last_match(1))
|
||||||
when /^(\w+)/
|
when /^(\w+)/
|
||||||
raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
|
raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
|
||||||
|
|
||||||
module_name = arg
|
module_name = arg
|
||||||
when /^-(h|-help)/
|
when /^-(h|-help)/
|
||||||
ARGV = [].freeze
|
ARGV = [].freeze
|
||||||
@ -298,6 +299,7 @@ if $0 == __FILE__
|
|||||||
end
|
end
|
||||||
|
|
||||||
raise 'ERROR: You must have a Module name specified! (use option -h for help)' if module_name.nil?
|
raise 'ERROR: You must have a Module name specified! (use option -h for help)' if module_name.nil?
|
||||||
|
|
||||||
if destroy
|
if destroy
|
||||||
UnityModuleGenerator.new(options).destroy(module_name)
|
UnityModuleGenerator.new(options).destroy(module_name)
|
||||||
else
|
else
|
||||||
|
@ -61,11 +61,11 @@ class UnityTestRunnerGenerator
|
|||||||
# pull required data from source file
|
# pull required data from source file
|
||||||
source = File.read(input_file)
|
source = File.read(input_file)
|
||||||
source = source.force_encoding('ISO-8859-1').encode('utf-8', replace: nil)
|
source = source.force_encoding('ISO-8859-1').encode('utf-8', replace: nil)
|
||||||
tests = find_tests(source)
|
tests = find_tests(source)
|
||||||
headers = find_includes(source)
|
headers = find_includes(source)
|
||||||
testfile_includes = (headers[:local] + headers[:system])
|
testfile_includes = (headers[:local] + headers[:system])
|
||||||
used_mocks = find_mocks(testfile_includes)
|
used_mocks = find_mocks(testfile_includes)
|
||||||
testfile_includes = (testfile_includes - used_mocks)
|
testfile_includes = (testfile_includes - used_mocks)
|
||||||
testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ }
|
testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ }
|
||||||
find_setup_and_teardown(source)
|
find_setup_and_teardown(source)
|
||||||
|
|
||||||
@ -127,17 +127,21 @@ class UnityTestRunnerGenerator
|
|||||||
lines.each_with_index do |line, _index|
|
lines.each_with_index do |line, _index|
|
||||||
# find tests
|
# find tests
|
||||||
next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m
|
next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m
|
||||||
|
|
||||||
arguments = Regexp.last_match(1)
|
arguments = Regexp.last_match(1)
|
||||||
name = Regexp.last_match(2)
|
name = Regexp.last_match(2)
|
||||||
call = Regexp.last_match(3)
|
call = Regexp.last_match(3)
|
||||||
params = Regexp.last_match(4)
|
params = Regexp.last_match(4)
|
||||||
args = nil
|
args = nil
|
||||||
|
|
||||||
if @options[:use_param_tests] && !arguments.empty?
|
if @options[:use_param_tests] && !arguments.empty?
|
||||||
args = []
|
args = []
|
||||||
arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] }
|
arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] }
|
||||||
end
|
end
|
||||||
|
|
||||||
tests_and_line_numbers << { test: name, args: args, call: call, params: params, line_number: 0 }
|
tests_and_line_numbers << { test: name, args: args, call: call, params: params, line_number: 0 }
|
||||||
end
|
end
|
||||||
|
|
||||||
tests_and_line_numbers.uniq! { |v| v[:test] }
|
tests_and_line_numbers.uniq! { |v| v[:test] }
|
||||||
|
|
||||||
# determine line numbers and create tests to run
|
# determine line numbers and create tests to run
|
||||||
@ -146,6 +150,7 @@ class UnityTestRunnerGenerator
|
|||||||
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 =~ /\s+#{tests_and_line_numbers[i][:test]}(?:\s|\()/
|
next unless line =~ /\s+#{tests_and_line_numbers[i][:test]}(?:\s|\()/
|
||||||
|
|
||||||
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
|
||||||
@ -266,18 +271,21 @@ class UnityTestRunnerGenerator
|
|||||||
|
|
||||||
def create_setup(output)
|
def create_setup(output)
|
||||||
return if @options[:has_setup]
|
return if @options[:has_setup]
|
||||||
|
|
||||||
output.puts("\n/*=======Setup (stub)=====*/")
|
output.puts("\n/*=======Setup (stub)=====*/")
|
||||||
output.puts("void #{@options[:setup_name]}(void) {}")
|
output.puts("void #{@options[:setup_name]}(void) {}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_teardown(output)
|
def create_teardown(output)
|
||||||
return if @options[:has_teardown]
|
return if @options[:has_teardown]
|
||||||
|
|
||||||
output.puts("\n/*=======Teardown (stub)=====*/")
|
output.puts("\n/*=======Teardown (stub)=====*/")
|
||||||
output.puts("void #{@options[:teardown_name]}(void) {}")
|
output.puts("void #{@options[:teardown_name]}(void) {}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_suite_setup(output)
|
def create_suite_setup(output)
|
||||||
return if @options[:suite_setup].nil?
|
return if @options[:suite_setup].nil?
|
||||||
|
|
||||||
output.puts("\n/*=======Suite Setup=====*/")
|
output.puts("\n/*=======Suite Setup=====*/")
|
||||||
output.puts('void suiteSetUp(void)')
|
output.puts('void suiteSetUp(void)')
|
||||||
output.puts('{')
|
output.puts('{')
|
||||||
@ -287,6 +295,7 @@ class UnityTestRunnerGenerator
|
|||||||
|
|
||||||
def create_suite_teardown(output)
|
def create_suite_teardown(output)
|
||||||
return if @options[:suite_teardown].nil?
|
return if @options[:suite_teardown].nil?
|
||||||
|
|
||||||
output.puts("\n/*=======Suite Teardown=====*/")
|
output.puts("\n/*=======Suite Teardown=====*/")
|
||||||
output.puts('int suiteTearDown(int num_failures)')
|
output.puts('int suiteTearDown(int num_failures)')
|
||||||
output.puts('{')
|
output.puts('{')
|
||||||
@ -315,9 +324,11 @@ class UnityTestRunnerGenerator
|
|||||||
|
|
||||||
def create_args_wrappers(output, tests)
|
def create_args_wrappers(output, tests)
|
||||||
return unless @options[:use_param_tests]
|
return unless @options[:use_param_tests]
|
||||||
|
|
||||||
output.puts("\n/*=======Parameterized Test Wrappers=====*/")
|
output.puts("\n/*=======Parameterized Test Wrappers=====*/")
|
||||||
tests.each do |test|
|
tests.each do |test|
|
||||||
next if test[:args].nil? || test[:args].empty?
|
next if test[:args].nil? || test[:args].empty?
|
||||||
|
|
||||||
test[:args].each.with_index(1) do |args, idx|
|
test[:args].each.with_index(1) do |args, idx|
|
||||||
output.puts("static void runner_args#{idx}_#{test[:test]}(void)")
|
output.puts("static void runner_args#{idx}_#{test[:test]}(void)")
|
||||||
output.puts('{')
|
output.puts('{')
|
||||||
|
@ -34,9 +34,9 @@ class ParseOutput
|
|||||||
|
|
||||||
# current suite name and statistics
|
# current suite name and statistics
|
||||||
@test_suite = nil
|
@test_suite = nil
|
||||||
@total_tests = 0
|
@total_tests = 0
|
||||||
@test_passed = 0
|
@test_passed = 0
|
||||||
@test_failed = 0
|
@test_failed = 0
|
||||||
@test_ignored = 0
|
@test_ignored = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -152,6 +152,7 @@ class UnityToJUnit
|
|||||||
|
|
||||||
def parse_test_summary(summary)
|
def parse_test_summary(summary)
|
||||||
raise "Couldn't parse test results: #{summary}" unless 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]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -230,7 +231,9 @@ if $0 == __FILE__
|
|||||||
targets = "#{options.results_dir.tr('\\', '/')}**/*.test*"
|
targets = "#{options.results_dir.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?
|
||||||
|
|
||||||
utj.targets = results
|
utj.targets = results
|
||||||
|
|
||||||
# set the root path
|
# set the root path
|
||||||
|
@ -99,6 +99,7 @@ class UnityTestSummary
|
|||||||
|
|
||||||
def parse_test_summary(summary)
|
def parse_test_summary(summary)
|
||||||
raise "Couldn't parse test results: #{summary}" unless 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]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -117,7 +118,9 @@ if $0 == __FILE__
|
|||||||
args[0] ||= './'
|
args[0] ||= './'
|
||||||
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.targets = results
|
uts.targets = results
|
||||||
|
|
||||||
# set the root path
|
# set the root path
|
||||||
|
@ -13,8 +13,6 @@ end
|
|||||||
|
|
||||||
task prepare_for_tests: TEMP_DIRS
|
task prepare_for_tests: TEMP_DIRS
|
||||||
|
|
||||||
include RakefileHelpers
|
|
||||||
|
|
||||||
# Load default configuration, for now
|
# Load default configuration, for now
|
||||||
DEFAULT_CONFIG_FILE = 'target_gcc_32.yml'.freeze
|
DEFAULT_CONFIG_FILE = 'target_gcc_32.yml'.freeze
|
||||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||||
|
@ -4,246 +4,247 @@ require_relative '../../auto/unity_test_summary'
|
|||||||
require_relative '../../auto/generate_test_runner'
|
require_relative '../../auto/generate_test_runner'
|
||||||
require_relative '../../auto/colour_reporter'
|
require_relative '../../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
C_EXTENSION = '.c'.freeze
|
||||||
C_EXTENSION = '.c'.freeze
|
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
$cfg_file = config_file
|
$cfg_file = config_file
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
|
end
|
||||||
|
|
||||||
|
def configure_clean
|
||||||
|
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
|
||||||
|
config_file += '.yml' unless config_file =~ /\.yml$/
|
||||||
|
load_configuration(config_file)
|
||||||
|
configure_clean
|
||||||
|
end
|
||||||
|
|
||||||
|
def unit_test_files
|
||||||
|
path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION
|
||||||
|
path.tr!('\\', '/')
|
||||||
|
FileList.new(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def local_include_dirs
|
||||||
|
include_dirs = $cfg['compiler']['includes']['items'].dup
|
||||||
|
include_dirs.delete_if { |dir| dir.is_a?(Array) }
|
||||||
|
include_dirs
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_headers(filename)
|
||||||
|
includes = []
|
||||||
|
lines = File.readlines(filename)
|
||||||
|
lines.each do |line|
|
||||||
|
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
|
||||||
|
includes << m[1] unless m.nil?
|
||||||
end
|
end
|
||||||
|
includes
|
||||||
|
end
|
||||||
|
|
||||||
def configure_clean
|
def find_source_file(header, paths)
|
||||||
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
|
paths.each do |dir|
|
||||||
|
src_file = dir + header.ext(C_EXTENSION)
|
||||||
|
return src_file if File.exist?(src_file)
|
||||||
end
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
|
def tackit(strings)
|
||||||
config_file += '.yml' unless config_file =~ /\.yml$/
|
result = if strings.is_a?(Array)
|
||||||
load_configuration(config_file)
|
"\"#{strings.join}\""
|
||||||
configure_clean
|
else
|
||||||
end
|
strings
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
def unit_test_files
|
def squash(prefix, items)
|
||||||
path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION
|
result = ''
|
||||||
path.tr!('\\', '/')
|
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
||||||
FileList.new(path)
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_include_dirs
|
def build_compiler_fields
|
||||||
include_dirs = $cfg['compiler']['includes']['items'].dup
|
command = tackit($cfg['compiler']['path'])
|
||||||
include_dirs.delete_if { |dir| dir.is_a?(Array) }
|
defines = if $cfg['compiler']['defines']['items'].nil?
|
||||||
include_dirs
|
''
|
||||||
end
|
else
|
||||||
|
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
||||||
|
end
|
||||||
|
options = squash('', $cfg['compiler']['options'])
|
||||||
|
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
||||||
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
|
|
||||||
def extract_headers(filename)
|
{ command: command, defines: defines, options: options, includes: includes }
|
||||||
includes = []
|
end
|
||||||
lines = File.readlines(filename)
|
|
||||||
lines.each do |line|
|
|
||||||
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
|
|
||||||
includes << m[1] unless m.nil?
|
|
||||||
end
|
|
||||||
includes
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_source_file(header, paths)
|
def compile(file, _defines = [])
|
||||||
paths.each do |dir|
|
compiler = build_compiler_fields
|
||||||
src_file = dir + header.ext(C_EXTENSION)
|
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \
|
||||||
return src_file if File.exist?(src_file)
|
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
||||||
end
|
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||||
nil
|
execute(cmd_str + obj_file)
|
||||||
end
|
obj_file
|
||||||
|
end
|
||||||
|
|
||||||
def tackit(strings)
|
def build_linker_fields
|
||||||
result = if strings.is_a?(Array)
|
command = tackit($cfg['linker']['path'])
|
||||||
"\"#{strings.join}\""
|
options = if $cfg['linker']['options'].nil?
|
||||||
|
''
|
||||||
|
else
|
||||||
|
squash('', $cfg['linker']['options'])
|
||||||
|
end
|
||||||
|
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
||||||
|
''
|
||||||
else
|
else
|
||||||
strings
|
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
||||||
end
|
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
result
|
|
||||||
end
|
|
||||||
|
|
||||||
def squash(prefix, items)
|
{ command: command, options: options, includes: includes }
|
||||||
result = ''
|
end
|
||||||
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
|
||||||
result
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_compiler_fields
|
def link_it(exe_name, obj_list)
|
||||||
command = tackit($cfg['compiler']['path'])
|
linker = build_linker_fields
|
||||||
defines = if $cfg['compiler']['defines']['items'].nil?
|
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
||||||
''
|
(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join +
|
||||||
else
|
$cfg['linker']['bin_files']['prefix'] + ' ' +
|
||||||
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
$cfg['linker']['bin_files']['destination'] +
|
||||||
end
|
exe_name + $cfg['linker']['bin_files']['extension']
|
||||||
options = squash('', $cfg['compiler']['options'])
|
execute(cmd_str)
|
||||||
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
end
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
|
||||||
|
|
||||||
{ command: command, defines: defines, options: options, includes: includes }
|
def build_simulator_fields
|
||||||
end
|
return nil if $cfg['simulator'].nil?
|
||||||
|
|
||||||
def compile(file, _defines = [])
|
command = if $cfg['simulator']['path'].nil?
|
||||||
compiler = build_compiler_fields
|
''
|
||||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \
|
else
|
||||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
(tackit($cfg['simulator']['path']) + ' ')
|
||||||
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
end
|
||||||
execute(cmd_str + obj_file)
|
pre_support = if $cfg['simulator']['pre_support'].nil?
|
||||||
obj_file
|
''
|
||||||
end
|
|
||||||
|
|
||||||
def build_linker_fields
|
|
||||||
command = tackit($cfg['linker']['path'])
|
|
||||||
options = if $cfg['linker']['options'].nil?
|
|
||||||
''
|
|
||||||
else
|
|
||||||
squash('', $cfg['linker']['options'])
|
|
||||||
end
|
|
||||||
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
|
||||||
''
|
|
||||||
else
|
|
||||||
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
|
||||||
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
|
||||||
|
|
||||||
{ command: command, options: options, includes: includes }
|
|
||||||
end
|
|
||||||
|
|
||||||
def link_it(exe_name, obj_list)
|
|
||||||
linker = build_linker_fields
|
|
||||||
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
|
||||||
(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join +
|
|
||||||
$cfg['linker']['bin_files']['prefix'] + ' ' +
|
|
||||||
$cfg['linker']['bin_files']['destination'] +
|
|
||||||
exe_name + $cfg['linker']['bin_files']['extension']
|
|
||||||
execute(cmd_str)
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_simulator_fields
|
|
||||||
return nil if $cfg['simulator'].nil?
|
|
||||||
command = if $cfg['simulator']['path'].nil?
|
|
||||||
''
|
|
||||||
else
|
|
||||||
(tackit($cfg['simulator']['path']) + ' ')
|
|
||||||
end
|
|
||||||
pre_support = if $cfg['simulator']['pre_support'].nil?
|
|
||||||
''
|
|
||||||
else
|
|
||||||
squash('', $cfg['simulator']['pre_support'])
|
|
||||||
end
|
|
||||||
post_support = if $cfg['simulator']['post_support'].nil?
|
|
||||||
''
|
|
||||||
else
|
|
||||||
squash('', $cfg['simulator']['post_support'])
|
|
||||||
end
|
|
||||||
|
|
||||||
{ command: command, pre_support: pre_support, post_support: post_support }
|
|
||||||
end
|
|
||||||
|
|
||||||
def execute(command_string, verbose = true, raise_on_fail = true)
|
|
||||||
report command_string
|
|
||||||
output = `#{command_string}`.chomp
|
|
||||||
report(output) if verbose && !output.nil? && !output.empty?
|
|
||||||
if !$?.nil? && !$?.exitstatus.zero? && raise_on_fail
|
|
||||||
raise "Command failed. (Returned #{$?.exitstatus})"
|
|
||||||
end
|
|
||||||
output
|
|
||||||
end
|
|
||||||
|
|
||||||
def report_summary
|
|
||||||
summary = UnityTestSummary.new
|
|
||||||
summary.root = __dir__
|
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
|
||||||
results_glob.tr!('\\', '/')
|
|
||||||
results = Dir[results_glob]
|
|
||||||
summary.targets = results
|
|
||||||
summary.run
|
|
||||||
fail_out 'FAIL: There were failures' if summary.failures > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_tests(test_files)
|
|
||||||
report 'Running system tests...'
|
|
||||||
|
|
||||||
# Tack on TEST define for compiling unit tests
|
|
||||||
load_configuration($cfg_file)
|
|
||||||
test_defines = ['TEST']
|
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
|
||||||
$cfg['compiler']['defines']['items'] << 'TEST'
|
|
||||||
|
|
||||||
include_dirs = local_include_dirs
|
|
||||||
|
|
||||||
# Build and execute each unit test
|
|
||||||
test_files.each do |test|
|
|
||||||
obj_list = []
|
|
||||||
|
|
||||||
# Detect dependencies and build required required modules
|
|
||||||
extract_headers(test).each do |header|
|
|
||||||
# Compile corresponding source file if it exists
|
|
||||||
src_file = find_source_file(header, include_dirs)
|
|
||||||
obj_list << compile(src_file, test_defines) unless src_file.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
# Build the test runner (generate if configured to do so)
|
|
||||||
test_base = File.basename(test, C_EXTENSION)
|
|
||||||
runner_name = test_base + '_Runner.c'
|
|
||||||
if $cfg['compiler']['runner_path'].nil?
|
|
||||||
runner_path = $cfg['compiler']['build_path'] + runner_name
|
|
||||||
test_gen = UnityTestRunnerGenerator.new($cfg_file)
|
|
||||||
test_gen.run(test, runner_path)
|
|
||||||
else
|
|
||||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
|
||||||
end
|
|
||||||
|
|
||||||
obj_list << compile(runner_path, test_defines)
|
|
||||||
|
|
||||||
# Build the test module
|
|
||||||
obj_list << compile(test, test_defines)
|
|
||||||
|
|
||||||
# Link the test executable
|
|
||||||
link_it(test_base, obj_list)
|
|
||||||
|
|
||||||
# Execute unit test and generate results file
|
|
||||||
simulator = build_simulator_fields
|
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
|
||||||
cmd_str = if simulator.nil?
|
|
||||||
executable
|
|
||||||
else
|
else
|
||||||
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
squash('', $cfg['simulator']['pre_support'])
|
||||||
end
|
end
|
||||||
output = execute(cmd_str, true, false)
|
post_support = if $cfg['simulator']['post_support'].nil?
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base
|
''
|
||||||
test_results += if output.match(/OK$/m).nil?
|
else
|
||||||
'.testfail'
|
squash('', $cfg['simulator']['post_support'])
|
||||||
else
|
end
|
||||||
'.testpass'
|
|
||||||
end
|
{ command: command, pre_support: pre_support, post_support: post_support }
|
||||||
File.open(test_results, 'w') { |f| f.print output }
|
end
|
||||||
end
|
|
||||||
|
def execute(command_string, verbose = true, raise_on_fail = true)
|
||||||
|
report command_string
|
||||||
|
output = `#{command_string}`.chomp
|
||||||
|
report(output) if verbose && !output.nil? && !output.empty?
|
||||||
|
|
||||||
|
if !$?.nil? && !$?.exitstatus.zero? && raise_on_fail
|
||||||
|
raise "Command failed. (Returned #{$?.exitstatus})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_application(main)
|
output
|
||||||
report 'Building application...'
|
end
|
||||||
|
|
||||||
|
def report_summary
|
||||||
|
summary = UnityTestSummary.new
|
||||||
|
summary.root = __dir__
|
||||||
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
|
results_glob.tr!('\\', '/')
|
||||||
|
results = Dir[results_glob]
|
||||||
|
summary.targets = results
|
||||||
|
summary.run
|
||||||
|
fail_out 'FAIL: There were failures' if summary.failures > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_tests(test_files)
|
||||||
|
report 'Running system tests...'
|
||||||
|
|
||||||
|
# Tack on TEST define for compiling unit tests
|
||||||
|
load_configuration($cfg_file)
|
||||||
|
test_defines = ['TEST']
|
||||||
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
|
$cfg['compiler']['defines']['items'] << 'TEST'
|
||||||
|
|
||||||
|
include_dirs = local_include_dirs
|
||||||
|
|
||||||
|
# Build and execute each unit test
|
||||||
|
test_files.each do |test|
|
||||||
obj_list = []
|
obj_list = []
|
||||||
load_configuration($cfg_file)
|
|
||||||
main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION
|
|
||||||
|
|
||||||
# Detect dependencies and build required required modules
|
# Detect dependencies and build required required modules
|
||||||
include_dirs = get_local_include_dirs
|
extract_headers(test).each do |header|
|
||||||
extract_headers(main_path).each do |header|
|
# Compile corresponding source file if it exists
|
||||||
src_file = find_source_file(header, include_dirs)
|
src_file = find_source_file(header, include_dirs)
|
||||||
obj_list << compile(src_file) unless src_file.nil?
|
obj_list << compile(src_file, test_defines) unless src_file.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Build the main source file
|
# Build the test runner (generate if configured to do so)
|
||||||
main_base = File.basename(main_path, C_EXTENSION)
|
test_base = File.basename(test, C_EXTENSION)
|
||||||
obj_list << compile(main_path)
|
runner_name = test_base + '_Runner.c'
|
||||||
|
if $cfg['compiler']['runner_path'].nil?
|
||||||
|
runner_path = $cfg['compiler']['build_path'] + runner_name
|
||||||
|
test_gen = UnityTestRunnerGenerator.new($cfg_file)
|
||||||
|
test_gen.run(test, runner_path)
|
||||||
|
else
|
||||||
|
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
||||||
|
end
|
||||||
|
|
||||||
# Create the executable
|
obj_list << compile(runner_path, test_defines)
|
||||||
link_it(main_base, obj_list)
|
|
||||||
end
|
|
||||||
|
|
||||||
def fail_out(msg)
|
# Build the test module
|
||||||
puts msg
|
obj_list << compile(test, test_defines)
|
||||||
puts 'Not returning exit code so continuous integration can pass'
|
|
||||||
# exit(-1) # Only removed to pass example_3, which has failing tests on purpose.
|
# Link the test executable
|
||||||
# Still fail if the build fails for any other reason.
|
link_it(test_base, obj_list)
|
||||||
|
|
||||||
|
# Execute unit test and generate results file
|
||||||
|
simulator = build_simulator_fields
|
||||||
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
|
cmd_str = if simulator.nil?
|
||||||
|
executable
|
||||||
|
else
|
||||||
|
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
|
end
|
||||||
|
output = execute(cmd_str, true, false)
|
||||||
|
test_results = $cfg['compiler']['build_path'] + test_base
|
||||||
|
test_results += if output.match(/OK$/m).nil?
|
||||||
|
'.testfail'
|
||||||
|
else
|
||||||
|
'.testpass'
|
||||||
|
end
|
||||||
|
File.open(test_results, 'w') { |f| f.print output }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_application(main)
|
||||||
|
report 'Building application...'
|
||||||
|
|
||||||
|
obj_list = []
|
||||||
|
load_configuration($cfg_file)
|
||||||
|
main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION
|
||||||
|
|
||||||
|
# Detect dependencies and build required required modules
|
||||||
|
include_dirs = get_local_include_dirs
|
||||||
|
extract_headers(main_path).each do |header|
|
||||||
|
src_file = find_source_file(header, include_dirs)
|
||||||
|
obj_list << compile(src_file) unless src_file.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
# Build the main source file
|
||||||
|
main_base = File.basename(main_path, C_EXTENSION)
|
||||||
|
obj_list << compile(main_path)
|
||||||
|
|
||||||
|
# Create the executable
|
||||||
|
link_it(main_base, obj_list)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fail_out(msg)
|
||||||
|
puts msg
|
||||||
|
puts 'Not returning exit code so continuous integration can pass'
|
||||||
|
# exit(-1) # Only removed to pass example_3, which has failing tests on purpose.
|
||||||
|
# Still fail if the build fails for any other reason.
|
||||||
|
end
|
||||||
|
@ -20,8 +20,6 @@ end
|
|||||||
|
|
||||||
task prepare_for_tests: TEMP_DIRS
|
task prepare_for_tests: TEMP_DIRS
|
||||||
|
|
||||||
include RakefileHelpers
|
|
||||||
|
|
||||||
# Load default configuration, for now
|
# Load default configuration, for now
|
||||||
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze
|
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze
|
||||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||||
|
@ -10,169 +10,170 @@ require_relative '../../auto/unity_test_summary'
|
|||||||
require_relative '../../auto/generate_test_runner'
|
require_relative '../../auto/generate_test_runner'
|
||||||
require_relative '../../auto/colour_reporter'
|
require_relative '../../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
C_EXTENSION = '.c'.freeze
|
||||||
C_EXTENSION = '.c'.freeze
|
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
return if $configured
|
return if $configured
|
||||||
|
|
||||||
$cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
$cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
$colour_output = false unless $cfg['colour']
|
$colour_output = false unless $cfg['colour']
|
||||||
$configured = true if config_file != DEFAULT_CONFIG_FILE
|
$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 tackit(strings)
|
def tackit(strings)
|
||||||
result = if strings.is_a?(Array)
|
result = if strings.is_a?(Array)
|
||||||
"\"#{strings.join}\""
|
"\"#{strings.join}\""
|
||||||
else
|
else
|
||||||
strings
|
strings
|
||||||
end
|
end
|
||||||
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)}" }
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_compiler_fields
|
def build_compiler_fields
|
||||||
command = tackit($cfg['compiler']['path'])
|
command = tackit($cfg['compiler']['path'])
|
||||||
defines = if $cfg['compiler']['defines']['items'].nil?
|
defines = if $cfg['compiler']['defines']['items'].nil?
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)'])
|
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)'])
|
||||||
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
|
||||||
|
|
||||||
def compile(file, _defines = [])
|
def compile(file, _defines = [])
|
||||||
compiler = build_compiler_fields
|
compiler = build_compiler_fields
|
||||||
unity_include = $cfg['compiler']['includes']['prefix'] + '../../src'
|
unity_include = $cfg['compiler']['includes']['prefix'] + '../../src'
|
||||||
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
|
||||||
|
|
||||||
def build_linker_fields
|
def build_linker_fields
|
||||||
command = tackit($cfg['linker']['path'])
|
command = tackit($cfg['linker']['path'])
|
||||||
options = if $cfg['linker']['options'].nil?
|
options = if $cfg['linker']['options'].nil?
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
squash('', $cfg['linker']['options'])
|
squash('', $cfg['linker']['options'])
|
||||||
end
|
end
|
||||||
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
||||||
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
|
|
||||||
{ 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?
|
||||||
command = if $cfg['simulator']['path'].nil?
|
|
||||||
''
|
command = if $cfg['simulator']['path'].nil?
|
||||||
else
|
''
|
||||||
(tackit($cfg['simulator']['path']) + ' ')
|
else
|
||||||
end
|
(tackit($cfg['simulator']['path']) + ' ')
|
||||||
pre_support = if $cfg['simulator']['pre_support'].nil?
|
end
|
||||||
''
|
pre_support = if $cfg['simulator']['pre_support'].nil?
|
||||||
else
|
''
|
||||||
squash('', $cfg['simulator']['pre_support'])
|
else
|
||||||
end
|
squash('', $cfg['simulator']['pre_support'])
|
||||||
post_support = if $cfg['simulator']['post_support'].nil?
|
end
|
||||||
''
|
post_support = if $cfg['simulator']['post_support'].nil?
|
||||||
else
|
''
|
||||||
squash('', $cfg['simulator']['post_support'])
|
else
|
||||||
end
|
squash('', $cfg['simulator']['post_support'])
|
||||||
{ command: command, pre_support: pre_support, post_support: post_support }
|
end
|
||||||
end
|
{ command: command, pre_support: pre_support, post_support: post_support }
|
||||||
|
end
|
||||||
def execute(command_string, verbose = true)
|
|
||||||
report command_string
|
def execute(command_string, verbose = true)
|
||||||
output = `#{command_string}`.chomp
|
report command_string
|
||||||
report(output) if verbose && !output.nil? && !output.empty?
|
output = `#{command_string}`.chomp
|
||||||
raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0
|
report(output) if verbose && !output.nil? && !output.empty?
|
||||||
output
|
|
||||||
end
|
raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0
|
||||||
|
|
||||||
def report_summary
|
output
|
||||||
summary = UnityTestSummary.new
|
end
|
||||||
summary.root = __dir__
|
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
def report_summary
|
||||||
results_glob.tr!('\\', '/')
|
summary = UnityTestSummary.new
|
||||||
results = Dir[results_glob]
|
summary.root = __dir__
|
||||||
summary.targets = results
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
summary.run
|
results_glob.tr!('\\', '/')
|
||||||
end
|
results = Dir[results_glob]
|
||||||
|
summary.targets = results
|
||||||
def run_tests
|
summary.run
|
||||||
report 'Running Unity system tests...'
|
end
|
||||||
|
|
||||||
# Tack on TEST define for compiling unit tests
|
def run_tests
|
||||||
load_configuration($cfg_file)
|
report 'Running Unity system tests...'
|
||||||
test_defines = ['TEST']
|
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
# Tack on TEST define for compiling unit tests
|
||||||
|
load_configuration($cfg_file)
|
||||||
# Get a list of all source files needed
|
test_defines = ['TEST']
|
||||||
src_files = Dir["#{__dir__}/src/*.c"]
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
src_files += Dir["#{__dir__}/test/*.c"]
|
|
||||||
src_files += Dir["#{__dir__}/test/main/*.c"]
|
# Get a list of all source files needed
|
||||||
src_files << '../../src/unity.c'
|
src_files = Dir["#{__dir__}/src/*.c"]
|
||||||
|
src_files += Dir["#{__dir__}/test/*.c"]
|
||||||
# Build object files
|
src_files += Dir["#{__dir__}/test/main/*.c"]
|
||||||
src_files.each { |f| compile(f, test_defines) }
|
src_files << '../../src/unity.c'
|
||||||
obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
|
|
||||||
|
# Build object files
|
||||||
# Link the test executable
|
src_files.each { |f| compile(f, test_defines) }
|
||||||
test_base = 'framework_test'
|
obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
|
||||||
link_it(test_base, obj_list)
|
|
||||||
|
# Link the test executable
|
||||||
# Execute unit test and generate results file
|
test_base = 'framework_test'
|
||||||
simulator = build_simulator_fields
|
link_it(test_base, obj_list)
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
|
||||||
cmd_str = if simulator.nil?
|
# Execute unit test and generate results file
|
||||||
executable + ' -v -r'
|
simulator = build_simulator_fields
|
||||||
else
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
cmd_str = if simulator.nil?
|
||||||
end
|
executable + ' -v -r'
|
||||||
output = execute(cmd_str)
|
else
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base
|
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
test_results += if output.match(/OK$/m).nil?
|
end
|
||||||
'.testfail'
|
output = execute(cmd_str)
|
||||||
else
|
test_results = $cfg['compiler']['build_path'] + test_base
|
||||||
'.testpass'
|
test_results += if output.match(/OK$/m).nil?
|
||||||
end
|
'.testfail'
|
||||||
File.open(test_results, 'w') { |f| f.print output }
|
else
|
||||||
end
|
'.testpass'
|
||||||
|
end
|
||||||
|
File.open(test_results, 'w') { |f| f.print output }
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#inherit_from: .rubocop_todo.yml
|
#inherit_from: .rubocop_todo.yml
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 2.1
|
TargetRubyVersion: 2.3
|
||||||
|
|
||||||
# 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
|
||||||
Style/SpecialGlobalVars:
|
Style/SpecialGlobalVars:
|
||||||
@ -12,10 +12,20 @@ Style/FormatString:
|
|||||||
Enabled: false
|
Enabled: false
|
||||||
Style/GlobalVars:
|
Style/GlobalVars:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
Style/FrozenStringLiteralComment:
|
||||||
|
Enabled: false
|
||||||
Style/RegexpLiteral:
|
Style/RegexpLiteral:
|
||||||
AllowInnerSlashes: true
|
AllowInnerSlashes: true
|
||||||
Style/HashSyntax:
|
Style/HashSyntax:
|
||||||
EnforcedStyle: no_mixed_keys
|
EnforcedStyle: no_mixed_keys
|
||||||
|
Style/NumericPredicate:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
# These are also places we diverge... but we will likely comply down the road
|
||||||
|
Style/IfUnlessModifier:
|
||||||
|
Enabled: false
|
||||||
|
Style/FormatStringToken:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
# This is disabled because it seems to get confused over nested hashes
|
# This is disabled because it seems to get confused over nested hashes
|
||||||
Layout/AlignHash:
|
Layout/AlignHash:
|
||||||
|
Reference in New Issue
Block a user