mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-29 05:27:25 +00:00
Updated to latest version of Unity.
Removed -Wno-duplicate-decl-specifier flag from all YAML files, since unsupported in some versions of gcc. Reimplemented ignore in specific files and generated code using a pragmas instead, which are setup to ignore undefined pragma values. Added initial .travis.yml file for TravisCI builds.
This commit is contained in:
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
test/system/build
|
test/system/build
|
||||||
test/system/generated
|
test/system/generated
|
||||||
*.sublime-project
|
*.sublime-project
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
|
.rake_t_cache
|
||||||
|
.DS_Store
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,8 @@
|
|||||||
[submodule "vendor/unity"]
|
[submodule "vendor/unity"]
|
||||||
path = vendor/unity
|
path = vendor/unity
|
||||||
url = git://github.com/ThrowTheSwitch/Unity.git
|
url = https://github.com/throwtheswitch/unity.git
|
||||||
|
branch = master
|
||||||
[submodule "vendor/c_exception"]
|
[submodule "vendor/c_exception"]
|
||||||
path = vendor/c_exception
|
path = vendor/c_exception
|
||||||
url = git://github.com/ThrowTheSwitch/CException.git
|
url = https://github.com/throwtheswitch/cexception.git
|
||||||
|
branch = master
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
language: ruby
|
||||||
|
rvm:
|
||||||
|
- "1.9.3"
|
||||||
|
- "2.0.0"
|
||||||
|
install:
|
||||||
|
- bundle install
|
||||||
|
script:
|
||||||
|
- bundle exec ci
|
||||||
@@ -1,10 +1,25 @@
|
|||||||
Welcome to CMock.
|
Welcome to CMock!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[CMock build status](http://travis-ci.org/throwtheswitch/kinetic-c) is provided via [Travis CI](http://travis-ci.org)
|
||||||
|
|
||||||
|
Getting Started
|
||||||
|
================
|
||||||
|
|
||||||
|
> git clone --recursive https://github.com/throwtheswitch/cmock.git
|
||||||
|
> cd cmock
|
||||||
|
> bundle install # Ensures you have all RubyGems needed
|
||||||
|
> bundle execute rake # Run all CMock library tests
|
||||||
|
|
||||||
|
API Documentation
|
||||||
|
=================
|
||||||
|
|
||||||
* Not sure what you're doing?
|
* Not sure what you're doing?
|
||||||
** The docs are in /docs
|
** [View docs/CMock_Summary.md](docs/CMock_Summary.md)
|
||||||
* Interested in our MIT-style license?
|
* Interested in our MIT-style license?
|
||||||
** That's in /docs too
|
** [View docs/license.txt](docs/license.txt)
|
||||||
* Are there examples?
|
* Are there examples?
|
||||||
** Try /examples
|
** They are all in [/examples](examples/)
|
||||||
* Any other resources to check out?
|
* Any other resources to check out?
|
||||||
** Sure. How about ThrowTheSwitch.org
|
** Definitely! Check out our developer portal on [ThrowTheSwitch.org](http://throwtheswitch.org)
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# CMock Project - Automatic Mock Generation for C
|
||||||
|
# Copyright (c) 2007-2014 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
require './config/test_environment'
|
||||||
|
require 'rake'
|
||||||
|
require 'rake/clean'
|
||||||
|
require 'rake/testtask'
|
||||||
|
require './rakefile_helper'
|
||||||
|
|
||||||
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
|
include RakefileHelpers
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_FILE = 'gcc.yml'
|
||||||
|
CMOCK_ROOT = File.expand_path(File.dirname(__FILE__))
|
||||||
|
|
||||||
|
SYSTEM_TEST_SUPPORT_DIRS = [
|
||||||
|
File.join(CMOCK_ROOT, 'test/system/generated'),
|
||||||
|
File.join(CMOCK_ROOT, 'test/system/build')
|
||||||
|
]
|
||||||
|
|
||||||
|
SYSTEM_TEST_SUPPORT_DIRS.each do |dir|
|
||||||
|
p dir
|
||||||
|
directory(dir)
|
||||||
|
CLOBBER.include(dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task :prep_system_tests => SYSTEM_TEST_SUPPORT_DIRS
|
||||||
|
|
||||||
|
configure_clean
|
||||||
|
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||||
|
|
||||||
|
task :default => ['test:all']
|
||||||
|
task :ci => [:no_color, :default]
|
||||||
|
task :cruise => :ci
|
||||||
|
|
||||||
|
desc "Load configuration"
|
||||||
|
task :config, :config_file do |t, args|
|
||||||
|
args = {:config_file => DEFAULT_CONFIG_FILE} if args[:config_file].nil?
|
||||||
|
args = {:config_file => args[:config_file] + '.yml'} unless args[:config_file] =~ /\.yml$/i
|
||||||
|
configure_toolchain(args[:config_file])
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :test do
|
||||||
|
desc "Run all unit and system tests"
|
||||||
|
task :all => [:clobber, :prep_system_tests, 'test:units', 'test:c', 'test:system']
|
||||||
|
|
||||||
|
desc "Run Unit Tests"
|
||||||
|
Rake::TestTask.new('units') do |t|
|
||||||
|
t.pattern = 'test/unit/*_test.rb'
|
||||||
|
t.verbose = true
|
||||||
|
end
|
||||||
|
|
||||||
|
#individual unit tests
|
||||||
|
FileList['test/unit/*_test.rb'].each do |test|
|
||||||
|
Rake::TestTask.new(File.basename(test,'.*')) do |t|
|
||||||
|
t.pattern = test
|
||||||
|
t.verbose = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Run C Unit Tests"
|
||||||
|
task :c => [:prep_system_tests] do
|
||||||
|
build_and_test_c_files
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Run System Tests"
|
||||||
|
task :system => [:clobber, :prep_system_tests] do
|
||||||
|
#get a list of all system tests, removing unsupported tests for this compiler
|
||||||
|
sys_unsupported = $cfg['unsupported'].map {|a| 'test/system/test_interactions/'+a+'.yml'}
|
||||||
|
sys_tests_to_run = FileList['test/system/test_interactions/*.yml'] - sys_unsupported
|
||||||
|
compile_unsupported = $cfg['unsupported'].map {|a| SYSTEST_COMPILE_MOCKABLES_PATH+a+'.h'}
|
||||||
|
compile_tests_to_run = FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'] - compile_unsupported
|
||||||
|
unless (sys_unsupported.empty? and compile_unsupported.empty?)
|
||||||
|
report "\nIgnoring these system tests..."
|
||||||
|
sys_unsupported.each {|a| report a}
|
||||||
|
compile_unsupported.each {|a| report a}
|
||||||
|
end
|
||||||
|
report "\nRunning system tests..."
|
||||||
|
tests_failed = run_system_test_interactions(sys_tests_to_run)
|
||||||
|
raise "System tests failed." if (tests_failed > 0)
|
||||||
|
|
||||||
|
run_system_test_compilations(compile_tests_to_run)
|
||||||
|
end
|
||||||
|
|
||||||
|
#individual system tests
|
||||||
|
FileList['test/system/test_interactions/*.yml'].each do |test|
|
||||||
|
desc "Run system test #{File.basename(test,'.*')}"
|
||||||
|
task "test:#{File.basename(test,'.*')}" do
|
||||||
|
run_system_test_interactions([test])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Profile Mock Generation"
|
||||||
|
task :profile => [:clobber, :prep_system_tests] do
|
||||||
|
run_system_test_profiles(FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :no_color do
|
||||||
|
$colour_output = false
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
||||||
|
spec_path = File.join(CMOCK_ROOT, 'test/spec')
|
||||||
|
t.pattern = spec_path + '/*_spec.rb'
|
||||||
|
end
|
||||||
|
|
||||||
@@ -74,6 +74,10 @@ class CMockGenerator
|
|||||||
plugin_includes = @plugins.run(:include_files)
|
plugin_includes = @plugins.run(:include_files)
|
||||||
file << plugin_includes if (!plugin_includes.empty?)
|
file << plugin_includes if (!plugin_includes.empty?)
|
||||||
file << "\n"
|
file << "\n"
|
||||||
|
file << "/* Ignore the following warnings, since we are copying code */\n"
|
||||||
|
file << "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n"
|
||||||
|
file << "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n"
|
||||||
|
file << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_typedefs(file, typedefs)
|
def create_typedefs(file, typedefs)
|
||||||
|
|||||||
+10
-11
@@ -1,8 +1,8 @@
|
|||||||
# ==========================================
|
# ==============================================================================
|
||||||
# CMock Project - Automatic Mock Generation for C
|
# CMock Project - Automatic Mock Generation for C
|
||||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
# Copyright (c) 2007-2014 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==============================================================================
|
||||||
|
|
||||||
require './config/test_environment'
|
require './config/test_environment'
|
||||||
require 'rake'
|
require 'rake'
|
||||||
@@ -23,7 +23,6 @@ SYSTEM_TEST_SUPPORT_DIRS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
SYSTEM_TEST_SUPPORT_DIRS.each do |dir|
|
SYSTEM_TEST_SUPPORT_DIRS.each do |dir|
|
||||||
p dir
|
|
||||||
directory(dir)
|
directory(dir)
|
||||||
CLOBBER.include(dir)
|
CLOBBER.include(dir)
|
||||||
end
|
end
|
||||||
@@ -53,7 +52,7 @@ namespace :test do
|
|||||||
t.pattern = 'test/unit/*_test.rb'
|
t.pattern = 'test/unit/*_test.rb'
|
||||||
t.verbose = true
|
t.verbose = true
|
||||||
end
|
end
|
||||||
|
|
||||||
#individual unit tests
|
#individual unit tests
|
||||||
FileList['test/unit/*_test.rb'].each do |test|
|
FileList['test/unit/*_test.rb'].each do |test|
|
||||||
Rake::TestTask.new(File.basename(test,'.*')) do |t|
|
Rake::TestTask.new(File.basename(test,'.*')) do |t|
|
||||||
@@ -61,12 +60,12 @@ namespace :test do
|
|||||||
t.verbose = true
|
t.verbose = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run C Unit Tests"
|
desc "Run C Unit Tests"
|
||||||
task :c => [:prep_system_tests] do
|
task :c => [:prep_system_tests] do
|
||||||
build_and_test_c_files
|
build_and_test_c_files
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run System Tests"
|
desc "Run System Tests"
|
||||||
task :system => [:clobber, :prep_system_tests] do
|
task :system => [:clobber, :prep_system_tests] do
|
||||||
#get a list of all system tests, removing unsupported tests for this compiler
|
#get a list of all system tests, removing unsupported tests for this compiler
|
||||||
@@ -82,10 +81,10 @@ namespace :test do
|
|||||||
report "\nRunning system tests..."
|
report "\nRunning system tests..."
|
||||||
tests_failed = run_system_test_interactions(sys_tests_to_run)
|
tests_failed = run_system_test_interactions(sys_tests_to_run)
|
||||||
raise "System tests failed." if (tests_failed > 0)
|
raise "System tests failed." if (tests_failed > 0)
|
||||||
|
|
||||||
run_system_test_compilations(compile_tests_to_run)
|
run_system_test_compilations(compile_tests_to_run)
|
||||||
end
|
end
|
||||||
|
|
||||||
#individual system tests
|
#individual system tests
|
||||||
FileList['test/system/test_interactions/*.yml'].each do |test|
|
FileList['test/system/test_interactions/*.yml'].each do |test|
|
||||||
desc "Run system test #{File.basename(test,'.*')}"
|
desc "Run system test #{File.basename(test,'.*')}"
|
||||||
@@ -93,7 +92,7 @@ namespace :test do
|
|||||||
run_system_test_interactions([test])
|
run_system_test_interactions([test])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Profile Mock Generation"
|
desc "Profile Mock Generation"
|
||||||
task :profile => [:clobber, :prep_system_tests] do
|
task :profile => [:clobber, :prep_system_tests] do
|
||||||
run_system_test_profiles(FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'])
|
run_system_test_profiles(FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'])
|
||||||
@@ -108,4 +107,4 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|||||||
spec_path = File.join(CMOCK_ROOT, 'test/spec')
|
spec_path = File.join(CMOCK_ROOT, 'test/spec')
|
||||||
t.pattern = spec_path + '/*_spec.rb'
|
t.pattern = spec_path + '/*_spec.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ compiler:
|
|||||||
- '-Wwrite-strings'
|
- '-Wwrite-strings'
|
||||||
- '-Wbad-function-cast'
|
- '-Wbad-function-cast'
|
||||||
- '-Wno-missing-prototypes' #we've been lazy about things like setUp and tearDown
|
- '-Wno-missing-prototypes' #we've been lazy about things like setUp and tearDown
|
||||||
- '-Wno-duplicate-decl-specifier' #allows us to test things like "const char const *""
|
|
||||||
- '-fms-extensions'
|
- '-fms-extensions'
|
||||||
- '-fno-omit-frame-pointer'
|
- '-fno-omit-frame-pointer'
|
||||||
- '-ffloat-store'
|
- '-ffloat-store'
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ compiler:
|
|||||||
- '-Wall'
|
- '-Wall'
|
||||||
- '-Wextra'
|
- '-Wextra'
|
||||||
- '-Wunused-parameter'
|
- '-Wunused-parameter'
|
||||||
- '-Wno-duplicate-decl-specifier'
|
|
||||||
- '-Wno-address'
|
- '-Wno-address'
|
||||||
- '-std=c99'
|
- '-std=c99'
|
||||||
- '-pedantic'
|
- '-pedantic'
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ compiler:
|
|||||||
- '-m64'
|
- '-m64'
|
||||||
- '-Wall'
|
- '-Wall'
|
||||||
- '-Wunused-parameter'
|
- '-Wunused-parameter'
|
||||||
- '-Wno-duplicate-decl-specifier'
|
|
||||||
- '-Wno-address'
|
- '-Wno-address'
|
||||||
- '-std=c99'
|
- '-std=c99'
|
||||||
- '-pedantic'
|
- '-pedantic'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# CMock Project - Automatic Mock Generation for C
|
# CMock Project - Automatic Mock Generation for C
|
||||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
@@ -26,31 +26,31 @@ C_EXTENSION = '.c'
|
|||||||
|
|
||||||
|
|
||||||
class SystemTestGenerator
|
class SystemTestGenerator
|
||||||
|
|
||||||
def generate_files(test_cases)
|
def generate_files(test_cases)
|
||||||
test_cases.each do |filename|
|
test_cases.each do |filename|
|
||||||
yaml_hash = YAML.load_file(filename)
|
yaml_hash = YAML.load_file(filename)
|
||||||
|
|
||||||
name = File.basename(filename, YAML_EXTENSION)
|
name = File.basename(filename, YAML_EXTENSION)
|
||||||
namix = "#{name}_"
|
namix = "#{name}_"
|
||||||
|
|
||||||
generate_cmock_config(yaml_hash, namix)
|
generate_cmock_config(yaml_hash, namix)
|
||||||
generate_code(yaml_hash, namix, name)
|
generate_code(yaml_hash, namix, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_cmock_config(yaml_hash, namix)
|
def generate_cmock_config(yaml_hash, namix)
|
||||||
cmock_yaml = yaml_hash.clone
|
cmock_yaml = yaml_hash.clone
|
||||||
cmock_yaml.delete(:systest)
|
cmock_yaml.delete(:systest)
|
||||||
cmock = cmock_yaml[:cmock]
|
cmock = cmock_yaml[:cmock]
|
||||||
|
|
||||||
cmock[:mock_path] = GENERATED_PATH
|
cmock[:mock_path] = GENERATED_PATH
|
||||||
cmock[:includes] = (cmock[:includes] || []) + [namix + TYPES_H]
|
cmock[:includes] = (cmock[:includes] || []) + [namix + TYPES_H]
|
||||||
cmock[:mock_prefix] = MOCK_PREFIX
|
cmock[:mock_prefix] = MOCK_PREFIX
|
||||||
if not yaml_hash[:systest][:unity_helper].nil?
|
if not yaml_hash[:systest][:unity_helper].nil?
|
||||||
cmock[:includes] << namix + UNITY_HELPER_H
|
cmock[:includes] << namix + UNITY_HELPER_H
|
||||||
cmock[:unity_helper_path] = GENERATED_PATH + namix + UNITY_HELPER_H
|
cmock[:unity_helper_path] = GENERATED_PATH + namix + UNITY_HELPER_H
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,29 +58,29 @@ class SystemTestGenerator
|
|||||||
YAML.dump(cmock_yaml, out)
|
YAML.dump(cmock_yaml, out)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_code(yaml_hash, namix, name)
|
def generate_code(yaml_hash, namix, name)
|
||||||
generate_types_file(yaml_hash, namix)
|
generate_types_file(yaml_hash, namix)
|
||||||
generate_mockable_file(yaml_hash, namix)
|
generate_mockable_file(yaml_hash, namix)
|
||||||
generate_unity_helper_files(yaml_hash, namix)
|
generate_unity_helper_files(yaml_hash, namix)
|
||||||
|
|
||||||
generate_test_file(yaml_hash, namix, name)
|
generate_test_file(yaml_hash, namix, name)
|
||||||
generate_source_file(yaml_hash, namix, name)
|
generate_source_file(yaml_hash, namix, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_types_file(yaml_hash, namix)
|
def generate_types_file(yaml_hash, namix)
|
||||||
types = yaml_hash[:systest][:types]
|
types = yaml_hash[:systest][:types]
|
||||||
return if types.nil?
|
return if types.nil?
|
||||||
|
|
||||||
write_header_file(GENERATED_PATH + namix + TYPES_H, namix.upcase + 'TYPES_H') do |out|
|
write_header_file(GENERATED_PATH + namix + TYPES_H, namix.upcase + 'TYPES_H') do |out|
|
||||||
out.puts(types)
|
out.puts(types)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_mockable_file(yaml_hash, namix)
|
def generate_mockable_file(yaml_hash, namix)
|
||||||
mockable = yaml_hash[:systest][:mockable]
|
mockable = yaml_hash[:systest][:mockable]
|
||||||
return if mockable.nil?
|
return if mockable.nil?
|
||||||
|
|
||||||
write_header_file(GENERATED_PATH + namix + MOCKABLE_H, namix.upcase + 'MOCKABLE_H', [namix + TYPES_H]) do |out|
|
write_header_file(GENERATED_PATH + namix + MOCKABLE_H, namix.upcase + 'MOCKABLE_H', [namix + TYPES_H]) do |out|
|
||||||
out.puts(mockable)
|
out.puts(mockable)
|
||||||
end
|
end
|
||||||
@@ -89,7 +89,7 @@ class SystemTestGenerator
|
|||||||
def generate_unity_helper_files(yaml_hash, namix)
|
def generate_unity_helper_files(yaml_hash, namix)
|
||||||
unity_helper = yaml_hash[:systest][:unity_helper]
|
unity_helper = yaml_hash[:systest][:unity_helper]
|
||||||
return if unity_helper.nil?
|
return if unity_helper.nil?
|
||||||
|
|
||||||
write_header_file(GENERATED_PATH + namix + UNITY_HELPER_H, namix.upcase + 'UNITY_HELPER_H', [namix + TYPES_H]) do |out|
|
write_header_file(GENERATED_PATH + namix + UNITY_HELPER_H, namix.upcase + 'UNITY_HELPER_H', [namix + TYPES_H]) do |out|
|
||||||
out.puts(unity_helper[:header])
|
out.puts(unity_helper[:header])
|
||||||
end
|
end
|
||||||
@@ -102,12 +102,12 @@ class SystemTestGenerator
|
|||||||
def generate_test_file(yaml_hash, namix, name)
|
def generate_test_file(yaml_hash, namix, name)
|
||||||
tests = yaml_hash[:systest][:tests]
|
tests = yaml_hash[:systest][:tests]
|
||||||
return if tests.nil?
|
return if tests.nil?
|
||||||
|
|
||||||
includes = [UNITY_H, CMOCK_H]
|
includes = [UNITY_H, CMOCK_H]
|
||||||
includes << (namix + UNITY_HELPER_H) if not yaml_hash[:systest][:unity_helper].nil?
|
includes << (namix + UNITY_HELPER_H) if not yaml_hash[:systest][:unity_helper].nil?
|
||||||
includes << [MOCK_PREFIX + namix + MOCKABLE_H]
|
includes << [MOCK_PREFIX + namix + MOCKABLE_H]
|
||||||
includes << [name + H_EXTENSION]
|
includes << [name + H_EXTENSION]
|
||||||
|
|
||||||
write_source_file(GENERATED_PATH + TEST_PREFIX + name + C_EXTENSION, includes.flatten) do |out|
|
write_source_file(GENERATED_PATH + TEST_PREFIX + name + C_EXTENSION, includes.flatten) do |out|
|
||||||
out.puts(tests[:common])
|
out.puts(tests[:common])
|
||||||
out.puts('')
|
out.puts('')
|
||||||
@@ -117,29 +117,29 @@ class SystemTestGenerator
|
|||||||
out.puts(test[:code].gsub!(/test\(\)/, "void test#{index+1}(void)"))
|
out.puts(test[:code].gsub!(/test\(\)/, "void test#{index+1}(void)"))
|
||||||
out.puts('')
|
out.puts('')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_source_file(yaml_hash, namix, name)
|
def generate_source_file(yaml_hash, namix, name)
|
||||||
source = yaml_hash[:systest][:source]
|
source = yaml_hash[:systest][:source]
|
||||||
return if source.nil?
|
return if source.nil?
|
||||||
|
|
||||||
header_file = name + H_EXTENSION
|
header_file = name + H_EXTENSION
|
||||||
|
|
||||||
includes = yaml_hash[:systest][:types].nil? ? [] : [(namix + TYPES_H)]
|
includes = yaml_hash[:systest][:types].nil? ? [] : [(namix + TYPES_H)]
|
||||||
|
|
||||||
write_header_file(GENERATED_PATH + header_file, name.upcase, includes) do |out|
|
write_header_file(GENERATED_PATH + header_file, name.upcase, includes) do |out|
|
||||||
out.puts(source[:header])
|
out.puts(source[:header])
|
||||||
end
|
end
|
||||||
|
|
||||||
includes = []
|
includes = []
|
||||||
includes << (namix + TYPES_H) if not yaml_hash[:systest][:types].nil?
|
includes << (namix + TYPES_H) if not yaml_hash[:systest][:types].nil?
|
||||||
includes << (namix + MOCKABLE_H) if not yaml_hash[:systest][:mockable].nil?
|
includes << (namix + MOCKABLE_H) if not yaml_hash[:systest][:mockable].nil?
|
||||||
includes << header_file
|
includes << header_file
|
||||||
|
|
||||||
write_source_file(GENERATED_PATH + name + C_EXTENSION, includes.flatten) do |out|
|
write_source_file(GENERATED_PATH + name + C_EXTENSION, includes.flatten) do |out|
|
||||||
out.puts(source[:code])
|
out.puts(source[:code])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_header_file(filename, upcase_name, include_list=[])
|
def write_header_file(filename, upcase_name, include_list=[])
|
||||||
@@ -151,11 +151,14 @@ class SystemTestGenerator
|
|||||||
out.puts("#include \"#{include}\"")
|
out.puts("#include \"#{include}\"")
|
||||||
end
|
end
|
||||||
out.puts('')
|
out.puts('')
|
||||||
|
out.puts('#pragma GCC diagnostic ignored "-Wunknown-pragmas"')
|
||||||
|
out.puts('#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"')
|
||||||
|
out.puts('')
|
||||||
yield(out)
|
yield(out)
|
||||||
out.puts('')
|
out.puts('')
|
||||||
out.puts("#endif // _#{upcase_name}")
|
out.puts("#endif // _#{upcase_name}")
|
||||||
out.puts('')
|
out.puts('')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_source_file(filename, include_list=[])
|
def write_source_file(filename, include_list=[])
|
||||||
@@ -164,11 +167,14 @@ class SystemTestGenerator
|
|||||||
out.puts("#include \"#{include}\"")
|
out.puts("#include \"#{include}\"")
|
||||||
end
|
end
|
||||||
out.puts('')
|
out.puts('')
|
||||||
|
out.puts('#pragma GCC diagnostic ignored "-Wunknown-pragmas"')
|
||||||
|
out.puts('#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"')
|
||||||
|
out.puts('')
|
||||||
yield(out)
|
yield(out)
|
||||||
out.puts('')
|
out.puts('')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
[Released under MIT License. Please refer to license.txt for details]
|
[Released under MIT License. Please refer to license.txt for details]
|
||||||
========================================== */
|
========================================== */
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||||
|
#pragma GCC diagnostic ignored "-Wduplicate-decl-specifier"
|
||||||
|
|
||||||
struct _DUMMY_T { unsigned int a; float b; };
|
struct _DUMMY_T { unsigned int a; float b; };
|
||||||
|
|
||||||
void const_variants1( const char* a, int const, unsigned short const * c );
|
void const_variants1( const char* a, int const, unsigned short const * c );
|
||||||
|
|
||||||
void const_variants2(
|
void const_variants2(
|
||||||
struct _DUMMY_T const * const param1,
|
struct _DUMMY_T const * const param1,
|
||||||
const unsigned long int const * const param2,
|
const unsigned long int const * const param2,
|
||||||
const struct _DUMMY_T const * param3 );
|
const struct _DUMMY_T const * param3 );
|
||||||
|
|
||||||
|
|||||||
@@ -6,26 +6,26 @@
|
|||||||
|
|
||||||
:systest:
|
:systest:
|
||||||
:types: |
|
:types: |
|
||||||
|
|
||||||
|
|
||||||
:mockable: |
|
:mockable: |
|
||||||
void foo(unsigned char** a);
|
void foo(unsigned char** a);
|
||||||
unsigned char** bar(void);
|
unsigned char** bar(void);
|
||||||
|
|
||||||
:source:
|
:source:
|
||||||
:header: |
|
:header: |
|
||||||
void function_a(void);
|
void function_a(void);
|
||||||
|
|
||||||
:code: |
|
:code: |
|
||||||
void function_a(void) {
|
void function_a(void) {
|
||||||
foo(bar());
|
foo(bar());
|
||||||
}
|
}
|
||||||
|
|
||||||
:tests:
|
:tests:
|
||||||
:common: |
|
:common: |
|
||||||
void setUp(void) {}
|
void setUp(void) {}
|
||||||
void tearDown(void) {}
|
void tearDown(void) {}
|
||||||
|
|
||||||
:units:
|
:units:
|
||||||
- :pass: TRUE
|
- :pass: TRUE
|
||||||
:should: 'handle two dimensional array of unsigned characters just like we would handle a single dimensional array in expect (where we really only care about first element)'
|
:should: 'handle two dimensional array of unsigned characters just like we would handle a single dimensional array in expect (where we really only care about first element)'
|
||||||
@@ -34,13 +34,13 @@
|
|||||||
{
|
{
|
||||||
unsigned char a[] = { 1, 2, 3, 4, 5, 6 };
|
unsigned char a[] = { 1, 2, 3, 4, 5, 6 };
|
||||||
unsigned char** pa = (unsigned char**)(&a);
|
unsigned char** pa = (unsigned char**)(&a);
|
||||||
|
|
||||||
bar_ExpectAndReturn(pa);
|
bar_ExpectAndReturn(pa);
|
||||||
foo_Expect(pa);
|
foo_Expect(pa);
|
||||||
|
|
||||||
function_a();
|
function_a();
|
||||||
}
|
}
|
||||||
|
|
||||||
- :pass: FALSE
|
- :pass: FALSE
|
||||||
:should: 'handle two dimensional array of unsigned characters just like we would handle a single dimensional array in expect as failures (where we really only care about first element)'
|
:should: 'handle two dimensional array of unsigned characters just like we would handle a single dimensional array in expect as failures (where we really only care about first element)'
|
||||||
:code: |
|
:code: |
|
||||||
@@ -50,10 +50,10 @@
|
|||||||
unsigned char b[] = { 5, 6, 7, 8, 9, 0 };
|
unsigned char b[] = { 5, 6, 7, 8, 9, 0 };
|
||||||
unsigned char** pa = (unsigned char**)(&a);
|
unsigned char** pa = (unsigned char**)(&a);
|
||||||
unsigned char** pb = (unsigned char**)(&b);
|
unsigned char** pb = (unsigned char**)(&b);
|
||||||
|
|
||||||
bar_ExpectAndReturn(pa);
|
bar_ExpectAndReturn(pa);
|
||||||
foo_Expect(pb);
|
foo_Expect(pb);
|
||||||
|
|
||||||
function_a();
|
function_a();
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -85,15 +85,20 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|||||||
define_name = "MOCKPOUTPOUTFISH_H"
|
define_name = "MOCKPOUTPOUTFISH_H"
|
||||||
mock_name = "MockPoutPoutFish"
|
mock_name = "MockPoutPoutFish"
|
||||||
output = []
|
output = []
|
||||||
expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
expected = [
|
||||||
"#ifndef _#{define_name}\n",
|
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
||||||
"#define _#{define_name}\n\n",
|
"#ifndef _#{define_name}\n",
|
||||||
"#include \"ConfigRequiredHeader1.h\"\n",
|
"#define _#{define_name}\n\n",
|
||||||
"#include \"ConfigRequiredHeader2.h\"\n",
|
"#include \"ConfigRequiredHeader1.h\"\n",
|
||||||
"#include \"#{orig_filename}\"\n",
|
"#include \"ConfigRequiredHeader2.h\"\n",
|
||||||
"#include \"PluginRequiredHeader.h\"\n",
|
"#include \"#{orig_filename}\"\n",
|
||||||
"\n"
|
"#include \"PluginRequiredHeader.h\"\n",
|
||||||
]
|
"\n",
|
||||||
|
"/* Ignore the following warnings, since we are copying code */\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
|
||||||
|
"\n",
|
||||||
|
]
|
||||||
|
|
||||||
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
||||||
|
|
||||||
@@ -121,15 +126,20 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|||||||
define_name = "MOCKPOUT_POUT_FISH_H"
|
define_name = "MOCKPOUT_POUT_FISH_H"
|
||||||
mock_name = "MockPout_Pout_Fish"
|
mock_name = "MockPout_Pout_Fish"
|
||||||
output = []
|
output = []
|
||||||
expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
expected = [
|
||||||
"#ifndef _#{define_name}\n",
|
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
||||||
"#define _#{define_name}\n\n",
|
"#ifndef _#{define_name}\n",
|
||||||
"#include \"ConfigRequiredHeader1.h\"\n",
|
"#define _#{define_name}\n\n",
|
||||||
"#include \"ConfigRequiredHeader2.h\"\n",
|
"#include \"ConfigRequiredHeader1.h\"\n",
|
||||||
"#include \"#{orig_filename}\"\n",
|
"#include \"ConfigRequiredHeader2.h\"\n",
|
||||||
"#include \"PluginRequiredHeader.h\"\n",
|
"#include \"#{orig_filename}\"\n",
|
||||||
"\n"
|
"#include \"PluginRequiredHeader.h\"\n",
|
||||||
]
|
"\n",
|
||||||
|
"/* Ignore the following warnings, since we are copying code */\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
|
||||||
|
"\n",
|
||||||
|
]
|
||||||
|
|
||||||
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
||||||
|
|
||||||
@@ -144,14 +154,19 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|||||||
define_name = "MOCKPOUTPOUTFISH_H"
|
define_name = "MOCKPOUTPOUTFISH_H"
|
||||||
mock_name = "MockPoutPoutFish"
|
mock_name = "MockPoutPoutFish"
|
||||||
output = []
|
output = []
|
||||||
expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
expected = [
|
||||||
"#ifndef _#{define_name}\n",
|
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
||||||
"#define _#{define_name}\n\n",
|
"#ifndef _#{define_name}\n",
|
||||||
"#include \"ConfigRequiredHeader1.h\"\n",
|
"#define _#{define_name}\n\n",
|
||||||
"#include \"ConfigRequiredHeader2.h\"\n",
|
"#include \"ConfigRequiredHeader1.h\"\n",
|
||||||
"#include \"#{orig_filename}\"\n",
|
"#include \"ConfigRequiredHeader2.h\"\n",
|
||||||
"\n"
|
"#include \"#{orig_filename}\"\n",
|
||||||
]
|
"\n",
|
||||||
|
"/* Ignore the following warnings, since we are copying code */\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
|
||||||
|
"\n",
|
||||||
|
]
|
||||||
|
|
||||||
@plugins.expect.run(:include_files).returns('')
|
@plugins.expect.run(:include_files).returns('')
|
||||||
|
|
||||||
@@ -166,15 +181,20 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|||||||
define_name = "MOCKPOUTPOUTFISH_H"
|
define_name = "MOCKPOUTPOUTFISH_H"
|
||||||
mock_name = "MockPoutPoutFish"
|
mock_name = "MockPoutPoutFish"
|
||||||
output = []
|
output = []
|
||||||
expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
expected = [
|
||||||
"#ifndef _#{define_name}\n",
|
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
||||||
"#define _#{define_name}\n\n",
|
"#ifndef _#{define_name}\n",
|
||||||
"#include \"ConfigRequiredHeader1.h\"\n",
|
"#define _#{define_name}\n\n",
|
||||||
"#include \"ConfigRequiredHeader2.h\"\n",
|
"#include \"ConfigRequiredHeader1.h\"\n",
|
||||||
"#include \"#{orig_filename}\"\n",
|
"#include \"ConfigRequiredHeader2.h\"\n",
|
||||||
"#include \"PluginRequiredHeader.h\"\n",
|
"#include \"#{orig_filename}\"\n",
|
||||||
"\n"
|
"#include \"PluginRequiredHeader.h\"\n",
|
||||||
]
|
"\n",
|
||||||
|
"/* Ignore the following warnings, since we are copying code */\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n",
|
||||||
|
"#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n",
|
||||||
|
"\n",
|
||||||
|
]
|
||||||
|
|
||||||
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
Submodule vendor/c_exception updated: 0571b990b6...f64bdb2ea1
Vendored
+1
-1
Submodule vendor/unity updated: fe2c691e9d...47a778d606
Reference in New Issue
Block a user