提交 1f643e86 编写于 作者: M mvandervoord

- 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
上级 b7564ce8
......@@ -24,6 +24,7 @@ class UnityTestRunnerGenerator
require 'yaml'
yaml_guts = YAML.load_file(config_file)
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[:order] = 1 if (yaml_goodness[:enforce_strict_ordering])
options[:framework] = (yaml_goodness[:framework] || :unity)
......@@ -120,7 +121,7 @@ class UnityTestRunnerGenerator
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
output.puts("#include \"#{@options[:framework].to_s}.h\"")
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\"")
end
output.puts('#include <setjmp.h>')
......
......@@ -9,7 +9,7 @@ module RakefileHelpers
C_EXTENSION = '.c'
def load_configuration(config_file)
$cfg_file = config_file
$cfg_file = "../targets/#{config_file}"
$cfg = YAML.load(File.read($cfg_file))
end
......@@ -191,7 +191,7 @@ module RakefileHelpers
runner_name = test_base + '_Runner.c'
if $cfg['compiler']['runner_path'].nil?
runner_path = $cfg['compiler']['build_path'] + runner_name
test_gen = UnityTestRunnerGenerator.new
test_gen = UnityTestRunnerGenerator.new($cfg_file)
test_gen.run(test, runner_path)
else
runner_path = $cfg['compiler']['runner_path'] + runner_name
......
......@@ -16,7 +16,7 @@ module RakefileHelpers
C_EXTENSION = '.c'
def load_configuration(config_file)
$cfg_file = config_file
$cfg_file = "targets/#{config_file}" unless $cfg_file =~ /[\\|\/]/
$cfg = YAML.load(File.read($cfg_file))
$colour_output = false unless $cfg['colour']
end
......@@ -27,7 +27,7 @@ module RakefileHelpers
def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
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)
configure_clean
end
......@@ -205,8 +205,7 @@ module RakefileHelpers
runner_path = $cfg['compiler']['runner_path'] + runner_name
end
#UnityTestRunnerGenerator.new(:suite_setup => 'puts("\nStarting Test Suite!\n");', :suite_teardown => 'return num_failures;').run(test, runner_path)
UnityTestRunnerGenerator.new.run(test, runner_path)
UnityTestRunnerGenerator.new($cfg_file).run(test, runner_path)
compile(runner_path, test_defines)
obj_list << runner_name.ext($cfg['compiler']['object_files']['extension'])
......
......@@ -35,4 +35,6 @@ linker:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
\ No newline at end of file
colour: true
:unity:
:plugins: []
\ No newline at end of file
......@@ -36,4 +36,6 @@ linker:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
\ No newline at end of file
colour: true
:unity:
:plugins: []
\ No newline at end of file
......@@ -31,7 +31,7 @@ compiler:
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '../src/'
- '..\src\'
- *unit_tests_path
- 'vendor\unity\src\'
defines:
......@@ -83,4 +83,6 @@ simulator:
- [*tools_root, 'arm\config\ioat91sam7X256.ddf']
- -d
- sim
colour: true
\ No newline at end of file
colour: true
:unity:
:plugins: []
\ No newline at end of file
......@@ -30,7 +30,7 @@ compiler:
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '../src/'
- '..\src\'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
......@@ -73,4 +73,6 @@ simulator:
- [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
- -d
- sim
colour: true
\ No newline at end of file
colour: true
:unity:
:plugins: []
\ No newline at end of file
......@@ -32,7 +32,7 @@ compiler:
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '../src/'
- '..\src\'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
......@@ -77,4 +77,6 @@ simulator:
- --cpu=Cortex-M3
- -d
- sim
colour: true
\ No newline at end of file
colour: true
:unity:
:plugins: []
\ No newline at end of file
......@@ -88,4 +88,6 @@ simulator:
- -p
- [*core_config, 'MSP430F5438.ddf']
- -d sim
colour: true
\ No newline at end of file
colour: true
:unity:
:plugins: []
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册