mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-28 21:42:17 +08:00
- updated example and main tests to show how to use generate_test_runner with yaml target file
- improved error reporting for generate_test_runner git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@96 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@ -24,6 +24,7 @@ class UnityTestRunnerGenerator
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
yaml_guts = YAML.load_file(config_file)
|
yaml_guts = YAML.load_file(config_file)
|
||||||
yaml_goodness = yaml_guts[:unity] ? yaml_guts[:unity] : yaml_guts[:cmock]
|
yaml_goodness = yaml_guts[:unity] ? yaml_guts[:unity] : yaml_guts[:cmock]
|
||||||
|
raise "No :unity or :cmock section found in #{config_file}" unless yaml_goodness
|
||||||
options[:cexception] = 1 unless (yaml_goodness[:plugins] & ['cexception', :cexception]).empty?
|
options[:cexception] = 1 unless (yaml_goodness[:plugins] & ['cexception', :cexception]).empty?
|
||||||
options[:order] = 1 if (yaml_goodness[:enforce_strict_ordering])
|
options[:order] = 1 if (yaml_goodness[:enforce_strict_ordering])
|
||||||
options[:framework] = (yaml_goodness[:framework] || :unity)
|
options[:framework] = (yaml_goodness[:framework] || :unity)
|
||||||
@ -120,7 +121,7 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
|
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
|
||||||
output.puts("#include \"#{@options[:framework].to_s}.h\"")
|
output.puts("#include \"#{@options[:framework].to_s}.h\"")
|
||||||
output.puts('#include "cmock.h"') unless (mocks.empty?)
|
output.puts('#include "cmock.h"') unless (mocks.empty?)
|
||||||
@options[:includes].flatten.each do |includes|
|
@options[:includes].flatten.uniq.compact.each do |includes|
|
||||||
output.puts("#include \"#{includes.gsub('.h','')}.h\"")
|
output.puts("#include \"#{includes.gsub('.h','')}.h\"")
|
||||||
end
|
end
|
||||||
output.puts('#include <setjmp.h>')
|
output.puts('#include <setjmp.h>')
|
||||||
|
@ -9,7 +9,7 @@ module RakefileHelpers
|
|||||||
C_EXTENSION = '.c'
|
C_EXTENSION = '.c'
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
$cfg_file = config_file
|
$cfg_file = "../targets/#{config_file}"
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ module RakefileHelpers
|
|||||||
runner_name = test_base + '_Runner.c'
|
runner_name = test_base + '_Runner.c'
|
||||||
if $cfg['compiler']['runner_path'].nil?
|
if $cfg['compiler']['runner_path'].nil?
|
||||||
runner_path = $cfg['compiler']['build_path'] + runner_name
|
runner_path = $cfg['compiler']['build_path'] + runner_name
|
||||||
test_gen = UnityTestRunnerGenerator.new
|
test_gen = UnityTestRunnerGenerator.new($cfg_file)
|
||||||
test_gen.run(test, runner_path)
|
test_gen.run(test, runner_path)
|
||||||
else
|
else
|
||||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
||||||
|
@ -16,7 +16,7 @@ module RakefileHelpers
|
|||||||
C_EXTENSION = '.c'
|
C_EXTENSION = '.c'
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
$cfg_file = config_file
|
$cfg_file = "targets/#{config_file}" unless $cfg_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']
|
||||||
end
|
end
|
||||||
@ -27,7 +27,7 @@ module RakefileHelpers
|
|||||||
|
|
||||||
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 = "targets/#{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
|
||||||
@ -205,8 +205,7 @@ module RakefileHelpers
|
|||||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
||||||
end
|
end
|
||||||
|
|
||||||
#UnityTestRunnerGenerator.new(:suite_setup => 'puts("\nStarting Test Suite!\n");', :suite_teardown => 'return num_failures;').run(test, runner_path)
|
UnityTestRunnerGenerator.new($cfg_file).run(test, runner_path)
|
||||||
UnityTestRunnerGenerator.new.run(test, runner_path)
|
|
||||||
|
|
||||||
compile(runner_path, test_defines)
|
compile(runner_path, test_defines)
|
||||||
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
|
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
|
||||||
|
@ -36,3 +36,5 @@ linker:
|
|||||||
extension: '.exe'
|
extension: '.exe'
|
||||||
destination: *build_path
|
destination: *build_path
|
||||||
colour: true
|
colour: true
|
||||||
|
:unity:
|
||||||
|
:plugins: []
|
@ -37,3 +37,5 @@ linker:
|
|||||||
extension: '.exe'
|
extension: '.exe'
|
||||||
destination: *build_path
|
destination: *build_path
|
||||||
colour: true
|
colour: true
|
||||||
|
:unity:
|
||||||
|
:plugins: []
|
@ -31,7 +31,7 @@ compiler:
|
|||||||
items:
|
items:
|
||||||
- [*tools_root, 'arm\inc\']
|
- [*tools_root, 'arm\inc\']
|
||||||
- 'src\'
|
- 'src\'
|
||||||
- '../src/'
|
- '..\src\'
|
||||||
- *unit_tests_path
|
- *unit_tests_path
|
||||||
- 'vendor\unity\src\'
|
- 'vendor\unity\src\'
|
||||||
defines:
|
defines:
|
||||||
@ -84,3 +84,5 @@ simulator:
|
|||||||
- -d
|
- -d
|
||||||
- sim
|
- sim
|
||||||
colour: true
|
colour: true
|
||||||
|
:unity:
|
||||||
|
:plugins: []
|
@ -30,7 +30,7 @@ compiler:
|
|||||||
items:
|
items:
|
||||||
- [*tools_root, 'arm\inc\']
|
- [*tools_root, 'arm\inc\']
|
||||||
- 'src\'
|
- 'src\'
|
||||||
- '../src/'
|
- '..\src\'
|
||||||
- *unit_tests_path
|
- *unit_tests_path
|
||||||
- 'vendor\unity\src\'
|
- 'vendor\unity\src\'
|
||||||
- 'iar\iar_v5\incIAR\'
|
- 'iar\iar_v5\incIAR\'
|
||||||
@ -74,3 +74,5 @@ simulator:
|
|||||||
- -d
|
- -d
|
||||||
- sim
|
- sim
|
||||||
colour: true
|
colour: true
|
||||||
|
:unity:
|
||||||
|
:plugins: []
|
@ -32,7 +32,7 @@ compiler:
|
|||||||
items:
|
items:
|
||||||
- [*tools_root, 'arm\inc\']
|
- [*tools_root, 'arm\inc\']
|
||||||
- 'src\'
|
- 'src\'
|
||||||
- '../src/'
|
- '..\src\'
|
||||||
- *unit_tests_path
|
- *unit_tests_path
|
||||||
- 'vendor\unity\src\'
|
- 'vendor\unity\src\'
|
||||||
- 'iar\iar_v5\incIAR\'
|
- 'iar\iar_v5\incIAR\'
|
||||||
@ -78,3 +78,5 @@ simulator:
|
|||||||
- -d
|
- -d
|
||||||
- sim
|
- sim
|
||||||
colour: true
|
colour: true
|
||||||
|
:unity:
|
||||||
|
:plugins: []
|
@ -89,3 +89,5 @@ simulator:
|
|||||||
- [*core_config, 'MSP430F5438.ddf']
|
- [*core_config, 'MSP430F5438.ddf']
|
||||||
- -d sim
|
- -d sim
|
||||||
colour: true
|
colour: true
|
||||||
|
:unity:
|
||||||
|
:plugins: []
|
Reference in New Issue
Block a user