mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-26 18:01:35 +01:00
- moved unity helper into the example directory, because it's not really core.
- made generate_test_runner more flexible in how data comes in. git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@28 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
|
||||
class UnityTestRunnerGenerator
|
||||
|
||||
def grab_config(config_file)
|
||||
includes = []
|
||||
options = {}
|
||||
unless (config_file.nil? or config_file.empty?)
|
||||
require 'yaml'
|
||||
yaml_goodness = YAML.load_file(config_file)[:cmock]
|
||||
options[:cexception] = 1 if (yaml_goodness[:plugins].include? 'cexception')
|
||||
options[:coverage ] = 1 if (yaml_goodness[:coverage])
|
||||
options[:order] = 1 if (yaml_goodness[:enforce_strict_ordering])
|
||||
includes << yaml_goodness[:includes]
|
||||
end
|
||||
return([includes, options])
|
||||
end
|
||||
|
||||
def run(input_file, output_file, additional_includes=[], tab=' ', options={})
|
||||
@tab = tab
|
||||
@options = options
|
||||
@@ -67,11 +81,11 @@ class UnityTestRunnerGenerator
|
||||
def create_header(output, mocks, additional_includes=[])
|
||||
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
|
||||
output.puts('#include "unity.h"')
|
||||
additional_includes.each do |includes|
|
||||
output.puts("#include \"#{includes}.h\"")
|
||||
additional_includes.flatten.each do |includes|
|
||||
output.puts("#include \"#{includes.gsub('.h','')}.h\"")
|
||||
end
|
||||
mocks.each do |mock|
|
||||
output.puts("#include \"#{mock}.h\"")
|
||||
output.puts("#include \"#{mock.gsub('.h','')}.h\"")
|
||||
end
|
||||
output.puts('#include <setjmp.h>')
|
||||
output.puts('#include <stdio.h>')
|
||||
@@ -170,16 +184,15 @@ class UnityTestRunnerGenerator
|
||||
output.puts("#{@tab}return 0;")
|
||||
output.puts("}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
if ($0 == __FILE__)
|
||||
usage = ["usage: ruby #{__FILE__} ( options ) input_test_file output_test_runner (includes)",
|
||||
usage = ["usage: ruby #{__FILE__} (yaml) (options) input_test_file output_test_runner (includes)",
|
||||
" blah.yml - will use config options in the yml file (see CMock docs)",
|
||||
" -cexception - include cexception support",
|
||||
" -coverage - include bullseye coverage support",
|
||||
" -order - include cmock order-enforcement support",
|
||||
" blah.yml - will use config options in the yml file (see CMock docs)" ]
|
||||
" -order - include cmock order-enforcement support" ]
|
||||
|
||||
includes = []
|
||||
options = {}
|
||||
@@ -190,12 +203,7 @@ if ($0 == __FILE__)
|
||||
options[$1.to_sym] = 1
|
||||
true
|
||||
elsif (arg =~ /(\w+\.yml)/)
|
||||
require 'yaml'
|
||||
yaml_goodness = YAML.load_file($1)[:cmock]
|
||||
options[:cexception] = 1 if (yaml_goodness[:plugins].include? 'cexception')
|
||||
options[:coverage ] = 1 if (yaml_goodness[:coverage])
|
||||
options[:order] = 1 if (yaml_goodness[:enforce_strict_ordering])
|
||||
includes << yaml_goodness[:includes]
|
||||
includes, options = grab_config($1)
|
||||
true
|
||||
else
|
||||
false
|
||||
@@ -214,5 +222,5 @@ if ($0 == __FILE__)
|
||||
#everything else is an include file
|
||||
includes << ARGV.slice(2..-1) if (ARGV.size > 2)
|
||||
|
||||
UnityTestRunnerGenerator.new.run(ARGV[0], ARGV[1], includes.flatten.compact)
|
||||
UnityTestRunnerGenerator.new.run(ARGV[0], ARGV[1], includes.flatten.compact, ' ', options)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user