mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
- Works with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2 (and possibly others)
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@192 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
|
||||
# Setup our load path:
|
||||
[
|
||||
'lib',
|
||||
'lib',
|
||||
].each do |dir|
|
||||
$LOAD_PATH.unshift( File.join( File.expand_path(File.dirname(__FILE__) + "/../"), dir) )
|
||||
$LOAD_PATH.unshift( File.join( File.expand_path(File.dirname(__FILE__)) + '/../', dir) )
|
||||
end
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.0 Kickstart\'
|
||||
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
|
||||
compiler:
|
||||
path: [*tools_root, 'arm\bin\iccarm.exe']
|
||||
source_path: 'src\'
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
||||
|
||||
#require HERE + 'config/environment'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
require 'rake/testtask'
|
||||
require 'rakefile_helper'
|
||||
require './rakefile_helper'
|
||||
|
||||
include RakefileHelpers
|
||||
|
||||
|
||||
@@ -59,12 +59,16 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def tackit(strings)
|
||||
if strings.is_a?(Array)
|
||||
result = "\"#{strings.join}\""
|
||||
else
|
||||
result = strings
|
||||
case(strings)
|
||||
when Array
|
||||
"\"#{strings.join}\""
|
||||
when /^-/
|
||||
strings
|
||||
when /\s/
|
||||
"\"#{strings}\""
|
||||
else
|
||||
strings
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
def squash(prefix, items)
|
||||
|
||||
+8
-9
@@ -4,15 +4,14 @@
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__)) + "/../config/production_environment"
|
||||
|
||||
require "cmock_header_parser"
|
||||
require "cmock_generator"
|
||||
require "cmock_file_writer"
|
||||
require "cmock_config"
|
||||
require "cmock_plugin_manager"
|
||||
require "cmock_generator_utils"
|
||||
require "cmock_unityhelper_parser"
|
||||
[ "../config/production_environment",
|
||||
"cmock_header_parser",
|
||||
"cmock_generator",
|
||||
"cmock_file_writer",
|
||||
"cmock_config",
|
||||
"cmock_plugin_manager",
|
||||
"cmock_generator_utils",
|
||||
"cmock_unityhelper_parser"].each {|req| require "#{File.expand_path(File.dirname(__FILE__))}/#{req}"}
|
||||
|
||||
class CMock
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class CMockHeaderParser
|
||||
#automatically name unnamed arguments (those that only had a type)
|
||||
arg_list.split(/\s*,\s*/).map { |arg|
|
||||
parts = (arg.split - ['struct', 'union', 'enum', 'const', 'const*'])
|
||||
if ((parts.size < 2) or (parts[-1][-1] == 42) or (@standards.include?(parts[-1])))
|
||||
if ((parts.size < 2) or (parts[-1][-1].chr == '*') or (@standards.include?(parts[-1])))
|
||||
"#{arg} cmock_arg#{c+=1}"
|
||||
else
|
||||
arg
|
||||
|
||||
@@ -16,7 +16,7 @@ class CMockPluginManager
|
||||
object_name = "CMockGeneratorPlugin" + camelize(plugin_name)
|
||||
begin
|
||||
unless (Object.const_defined? object_name)
|
||||
require "cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
||||
require "#{File.expand_path(File.dirname(__FILE__))}/cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
||||
end
|
||||
@plugins << eval("#{object_name}.new(config, utils)")
|
||||
rescue
|
||||
|
||||
+2
-4
@@ -4,13 +4,11 @@
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
||||
|
||||
require HERE + 'config/test_environment'
|
||||
require './config/test_environment'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
require 'rake/testtask'
|
||||
require 'rakefile_helper'
|
||||
require './rakefile_helper'
|
||||
|
||||
include RakefileHelpers
|
||||
|
||||
|
||||
+24
-25
@@ -6,10 +6,10 @@
|
||||
|
||||
require 'yaml'
|
||||
require 'fileutils'
|
||||
require 'generate_test_runner'
|
||||
require 'unity_test_summary'
|
||||
require 'systest_generator'
|
||||
require 'vendor/unity/auto/colour_reporter.rb'
|
||||
require './vendor/unity/auto/generate_test_runner'
|
||||
require './vendor/unity/auto/unity_test_summary'
|
||||
require './test/system/systest_generator'
|
||||
require './vendor/unity/auto/colour_reporter.rb'
|
||||
|
||||
module RakefileHelpers
|
||||
|
||||
@@ -21,7 +21,7 @@ module RakefileHelpers
|
||||
|
||||
def load_configuration(config_file)
|
||||
$cfg_file = config_file
|
||||
$cfg = YAML.load(File.read('targets/' + $cfg_file))
|
||||
$cfg = YAML.load(File.read('./targets/' + $cfg_file))
|
||||
$colour_output = false unless $cfg['colour']
|
||||
end
|
||||
|
||||
@@ -62,15 +62,6 @@ module RakefileHelpers
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def tackit(strings)
|
||||
if strings.is_a?(Array)
|
||||
result = "\"#{strings.join}\""
|
||||
else
|
||||
result = strings
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
def squash(prefix, items)
|
||||
result = ''
|
||||
@@ -156,27 +147,31 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def tackit(strings)
|
||||
if strings.is_a?(Array)
|
||||
result = "\"#{strings.join}\""
|
||||
else
|
||||
result = strings
|
||||
case(strings)
|
||||
when Array
|
||||
"\"#{strings.join}\""
|
||||
when /^-/
|
||||
strings
|
||||
when /\s/
|
||||
"\"#{strings}\""
|
||||
else
|
||||
strings
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
def report_summary
|
||||
summary = UnityTestSummary.new
|
||||
summary.set_root_path(HERE)
|
||||
summary.set_root_path(File.expand_path(File.dirname(__FILE__)) + '/')
|
||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||
results_glob.gsub!(/\\/, '/')
|
||||
results = Dir[results_glob]
|
||||
summary.set_targets(results)
|
||||
summary.run
|
||||
raise "There were failures" if (summary.failures > 0)
|
||||
fail_out "FAIL: There were failures" if (summary.failures > 0)
|
||||
end
|
||||
|
||||
def run_system_test_interactions(test_case_files)
|
||||
load 'cmock.rb'
|
||||
load './lib/cmock.rb'
|
||||
|
||||
SystemTestGenerator.new.generate_files(test_case_files)
|
||||
test_files = FileList.new(SYSTEST_GENERATED_FILES_PATH + 'test*.c')
|
||||
@@ -252,7 +247,6 @@ module RakefileHelpers
|
||||
test_file = 'test_' + File.basename(test_case).ext(C_EXTENSION)
|
||||
result_file = test_file.ext(RESULT_EXTENSION)
|
||||
test_results = File.readlines(SYSTEST_BUILD_FILES_PATH + result_file)
|
||||
|
||||
tests.each_with_index do |test, index|
|
||||
# compare test's intended pass/fail state with pass/fail state in actual results;
|
||||
# if they don't match, the system test has failed
|
||||
@@ -316,7 +310,7 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def run_system_test_compilations(mockables)
|
||||
load 'cmock.rb'
|
||||
load './lib/cmock.rb'
|
||||
|
||||
load_configuration($cfg_file)
|
||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||
@@ -334,7 +328,7 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def run_system_test_profiles(mockables)
|
||||
load 'cmock.rb'
|
||||
load './lib/cmock.rb'
|
||||
|
||||
load_configuration($cfg_file)
|
||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||
@@ -380,5 +374,10 @@ module RakefileHelpers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def fail_out(msg)
|
||||
puts msg
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
SYS_TEST_GEN_ROOT = File.expand_path( File.dirname( __FILE__ ) ) + '/'
|
||||
|
||||
require 'yaml'
|
||||
|
||||
GENERATED_PATH = SYS_TEST_GEN_ROOT + 'generated/'
|
||||
BUILD_PATH = SYS_TEST_GEN_ROOT + 'build/'
|
||||
CASES_PATH = SYS_TEST_GEN_ROOT + 'cases/'
|
||||
SYS_TEST_GEN_ROOT = File.expand_path( File.dirname( __FILE__ ) ) + '/'
|
||||
GENERATED_PATH = SYS_TEST_GEN_ROOT + 'generated/'
|
||||
BUILD_PATH = SYS_TEST_GEN_ROOT + 'build/'
|
||||
CASES_PATH = SYS_TEST_GEN_ROOT + 'cases/'
|
||||
|
||||
TYPES_H = 'types.h'
|
||||
UNITY_H = 'unity.h'
|
||||
|
||||
+6
-5
@@ -3,18 +3,19 @@
|
||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__)) + "/../config/test_environment"
|
||||
[ "/../config/test_environment",
|
||||
"/../vendor/behaviors/lib/behaviors"
|
||||
].each do |req|
|
||||
require File.expand_path(File.dirname(__FILE__)) + req
|
||||
end
|
||||
|
||||
#gem install test-unit -v 1.2.3
|
||||
ruby_version = RUBY_VERSION.split('.')
|
||||
if (ruby_version[1].to_i == 9) and (ruby_version[2].to_i > 1)
|
||||
require 'gems'
|
||||
require 'rubygems'
|
||||
gem 'test-unit'
|
||||
end
|
||||
require 'test/unit'
|
||||
|
||||
require 'behaviors'
|
||||
require 'hardmock'
|
||||
|
||||
class Test::Unit::TestCase
|
||||
|
||||
@@ -53,10 +53,6 @@ class CMockGeneratorPluginIgnoreTest < Test::Unit::TestCase
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "not add code to implementation (when :args_and_calls)" do
|
||||
assert(! @cmock_generator_plugin_ignore.methods.include?(:mock_implementation))
|
||||
end
|
||||
|
||||
should "add required code to implementation precheck with void function (when :args_and_calls)" do
|
||||
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
||||
expected = [" if (Mock.Mold_IgnoreBool)\n",
|
||||
|
||||
@@ -544,7 +544,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
end
|
||||
|
||||
should "should fully parse multiple prototypes" do
|
||||
should "fully parse multiple prototypes" do
|
||||
|
||||
source = "const int TheMatrix(int Trinity, unsigned int * Neo);\n" +
|
||||
"int Morpheus(int, unsigned int*);\n"
|
||||
|
||||
Reference in New Issue
Block a user