- 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:
mvandervoord
2010-09-22 00:19:04 +00:00
parent b7564ce8a0
commit 1f643e8661
9 changed files with 28 additions and 16 deletions

View File

@ -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>')

View File

@ -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

View File

@ -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'])

View File

@ -36,3 +36,5 @@ linker:
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@ -37,3 +37,5 @@ linker:
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []

View File

@ -31,7 +31,7 @@ compiler:
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '../src/'
- '..\src\'
- *unit_tests_path
- 'vendor\unity\src\'
defines:
@ -84,3 +84,5 @@ simulator:
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@ -30,7 +30,7 @@ compiler:
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '../src/'
- '..\src\'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
@ -74,3 +74,5 @@ simulator:
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@ -32,7 +32,7 @@ compiler:
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '../src/'
- '..\src\'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
@ -78,3 +78,5 @@ simulator:
- -d
- sim
colour: true
:unity:
:plugins: []

View File

@ -89,3 +89,5 @@ simulator:
- [*core_config, 'MSP430F5438.ddf']
- -d sim
colour: true
:unity:
:plugins: []