mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-08-03 17:57:52 +00:00
Make sure that examples get run with ci, and using appropriate settings.
This commit is contained in:
@@ -16,9 +16,9 @@ TARGETS_PATH = File.join(__dir__, '..', '..', 'test', 'targets').freeze
|
|||||||
PROJECT_FILE = File.join(__dir__, 'project.yml').freeze
|
PROJECT_FILE = File.join(__dir__, 'project.yml').freeze
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
$cfg_file = config_file =~ /[\\\/]/ ? config_file : File.join(TARGETS_PATH, config_file)
|
$unity_example_config_file = config_file =~ /[\\\/]/ ? config_file : File.join(TARGETS_PATH, config_file)
|
||||||
project = YamlHelper.load_file(PROJECT_FILE)
|
project = YamlHelper.load_file(PROJECT_FILE)
|
||||||
target = YamlHelper.load_file($cfg_file)
|
target = YamlHelper.load_file($unity_example_config_file)
|
||||||
|
|
||||||
# Toolchain settings (tools, extensions) come from the target YML.
|
# Toolchain settings (tools, extensions) come from the target YML.
|
||||||
# Path and project settings come from project.yml and take precedence.
|
# Path and project settings come from project.yml and take precedence.
|
||||||
@@ -130,7 +130,7 @@ end
|
|||||||
|
|
||||||
def compile(file, defines = [])
|
def compile(file, defines = [])
|
||||||
build_path = $cfg[:project][:build_root]
|
build_path = $cfg[:project][:build_root]
|
||||||
out_file = File.join(build_path, File.basename(file, C_EXTENSION)) + $cfg[:extension][:object]
|
out_file = File.join(build_path, File.basename(file, C_EXTENSION)) + ($cfg[:extension][:object] || '.o')
|
||||||
cmd_str = build_command_string($cfg[:tools][:test_compiler], [file, out_file], defines)
|
cmd_str = build_command_string($cfg[:tools][:test_compiler], [file, out_file], defines)
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
out_file
|
out_file
|
||||||
@@ -138,7 +138,7 @@ end
|
|||||||
|
|
||||||
def link_it(exe_name, obj_list)
|
def link_it(exe_name, obj_list)
|
||||||
build_path = $cfg[:project][:build_root]
|
build_path = $cfg[:project][:build_root]
|
||||||
exe_file = File.join(build_path, File.basename(exe_name, '.*')) + $cfg[:extension][:executable]
|
exe_file = File.join(build_path, File.basename(exe_name, '.*')) + ($cfg[:extension][:executable] || '')
|
||||||
cmd_str = build_command_string($cfg[:tools][:test_linker], [obj_list, exe_file])
|
cmd_str = build_command_string($cfg[:tools][:test_linker], [obj_list, exe_file])
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
exe_file
|
exe_file
|
||||||
|
|||||||
+15
-11
@@ -28,30 +28,30 @@ include RakefileHelpers
|
|||||||
|
|
||||||
# Load proper GCC as defult configuration
|
# Load proper GCC as defult configuration
|
||||||
DEFAULT_CONFIG_FILE = 'gcc_64_auto_stdint.yml'
|
DEFAULT_CONFIG_FILE = 'gcc_64_auto_stdint.yml'
|
||||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
$unity_test_config_file = DEFAULT_CONFIG_FILE
|
||||||
|
|
||||||
############# ALL THE SELF-TESTS WE CAN PERFORM
|
############# ALL THE SELF-TESTS WE CAN PERFORM
|
||||||
namespace :test do
|
namespace :test do
|
||||||
desc "Build and test Unity"
|
desc "Build and test Unity"
|
||||||
task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary']
|
task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary']
|
||||||
task :ci => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary']
|
task :ci => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:examples', 'test:summary']
|
||||||
|
|
||||||
desc "Test unity with its own unit tests"
|
desc "Test unity with its own unit tests"
|
||||||
task :unit => [:prepare_for_tests] do
|
task :unit => [:config_toolchain, :prepare_for_tests] do
|
||||||
run_tests unit_test_files
|
run_tests unit_test_files
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :unit do
|
namespace :unit do
|
||||||
unit_test_files.each do |f|
|
unit_test_files.each do |f|
|
||||||
desc "test this unit only"
|
desc "test this unit only"
|
||||||
task File.basename(f,'.c').sub('test_unity_','') => [:prepare_for_tests] do
|
task File.basename(f,'.c').sub('test_unity_','') => [:config_toolchain, :prepare_for_tests] do
|
||||||
run_tests [f]
|
run_tests [f]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Test unity's helper scripts"
|
desc "Test unity's helper scripts"
|
||||||
task :scripts => [:prepare_for_tests] do
|
task :scripts => [:config_toolchain, :prepare_for_tests] do
|
||||||
begin
|
begin
|
||||||
Dir['tests/test_*.rb'].each do |scriptfile|
|
Dir['tests/test_*.rb'].each do |scriptfile|
|
||||||
require "./"+scriptfile
|
require "./"+scriptfile
|
||||||
@@ -66,27 +66,27 @@ namespace :test do
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc "Test unity triggered from make"
|
desc "Test unity triggered from make"
|
||||||
task :make => [:prepare_for_tests] do
|
task :make => [:config_toolchain, :prepare_for_tests] do
|
||||||
run_make_tests()
|
run_make_tests()
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Test unity fixture addon"
|
desc "Test unity fixture addon"
|
||||||
task :fixture => [:prepare_for_tests] do
|
task :fixture => [:config_toolchain, :prepare_for_tests] do
|
||||||
test_fixtures()
|
test_fixtures()
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Test unity memory addon"
|
desc "Test unity memory addon"
|
||||||
task :memory => [:prepare_for_tests] do
|
task :memory => [:config_toolchain, :prepare_for_tests] do
|
||||||
test_memory()
|
test_memory()
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Test unity examples"
|
desc "Test unity examples"
|
||||||
task :examples => [:prepare_for_tests] do
|
task :examples => [:config_toolchain, :prepare_for_tests] do
|
||||||
run_examples
|
run_examples
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run all rspecs"
|
desc "Run all rspecs"
|
||||||
task :spec => [:prepare_for_tests] do
|
task :spec => [:config_toolchain, :prepare_for_tests] do
|
||||||
output = execute("rspec spec/**/*_spec.rb", true)
|
output = execute("rspec spec/**/*_spec.rb", true)
|
||||||
rspec_ok = $?.exitstatus.zero?
|
rspec_ok = $?.exitstatus.zero?
|
||||||
report output
|
report output
|
||||||
@@ -115,7 +115,11 @@ task :default => [:clobber, :all]
|
|||||||
|
|
||||||
desc "Load configuration"
|
desc "Load configuration"
|
||||||
task :config, :config_file do |t, args|
|
task :config, :config_file do |t, args|
|
||||||
configure_toolchain(args[:config_file])
|
$unity_test_config_file = args[:config_file]
|
||||||
|
end
|
||||||
|
|
||||||
|
task :config_toolchain do
|
||||||
|
configure_toolchain($unity_test_config_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
task :no_color do
|
task :no_color do
|
||||||
|
|||||||
+24
-10
@@ -13,16 +13,19 @@ require_relative '../auto/yaml_helper'
|
|||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
return if $configured
|
return if $configured
|
||||||
|
|
||||||
if config_file =~ /[\\|\/]/
|
$cfg_file_base = config_file
|
||||||
$cfg_file = config_file
|
cfg_file = if config_file =~ /[\\|\/]/
|
||||||
|
$unity_test_config_file_in_targets = false
|
||||||
|
config_file
|
||||||
else
|
else
|
||||||
$cfg_file_base = config_file
|
$unity_test_config_file_in_targets = true
|
||||||
$cfg_file = "targets/#{config_file}"
|
"targets/#{config_file}"
|
||||||
end
|
end
|
||||||
$cfg = YamlHelper.load_file($cfg_file)
|
$cfg = YamlHelper.load_file(cfg_file)
|
||||||
$cfg[:paths] ||= {}
|
$cfg[:paths] ||= {}
|
||||||
$cfg[:paths][:test] = (Array($cfg[:paths][:test]) + ['src/', '../src/', 'testdata/', 'tests/']).uniq
|
$cfg[:paths][:test] = (Array($cfg[:paths][:test]) + ['src/', '../src/', 'testdata/', 'tests/']).uniq
|
||||||
$colour_output = false unless $cfg['colour']
|
$colour_output = false unless $cfg['colour']
|
||||||
@@ -418,11 +421,22 @@ module RakefileHelpers
|
|||||||
def run_examples()
|
def run_examples()
|
||||||
report "\nRunning Unity Examples"
|
report "\nRunning Unity Examples"
|
||||||
total_tests = total_ignored = 0
|
total_tests = total_ignored = 0
|
||||||
[
|
|
||||||
"cd ../examples/example_1 && make -s ci",
|
# If we're set up to use gcc, the makefiles should work too. otherwise, just run example 3
|
||||||
"cd ../examples/example_2 && make -s ci",
|
examples = if $cfg_file_base.nil? || ($cfg_file_base =~ /gcc/)
|
||||||
"cd ../examples/example_3 && rake config[#{$cfg_file_base || 'gcc_64'}] default"
|
[
|
||||||
].each do |cmd|
|
"cd ../examples/example_1 && make -s ci",
|
||||||
|
"cd ../examples/example_2 && make -s ci"
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end + if $unity_test_config_file_in_targets
|
||||||
|
["cd ../examples/example_3 && rake config[#{$cfg_file_base}] default"]
|
||||||
|
else
|
||||||
|
["cd ../examples/example_3 && rake config[\"../#{$unity_test_config_file}\"] default"]
|
||||||
|
end
|
||||||
|
|
||||||
|
examples.each do |cmd|
|
||||||
execute(cmd, false).each_line do |line|
|
execute(cmd, false).each_line do |line|
|
||||||
if line =~ /(\d+) Tests \d+ Failures (\d+) Ignored/
|
if line =~ /(\d+) Tests \d+ Failures (\d+) Ignored/
|
||||||
total_tests += Regexp.last_match(1).to_i
|
total_tests += Regexp.last_match(1).to_i
|
||||||
|
|||||||
@@ -1241,9 +1241,6 @@ RUNNER_TESTS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
def runner_test(test, runner, expected, test_defines, cmdline_args, features)
|
def runner_test(test, runner, expected, test_defines, cmdline_args, features)
|
||||||
# Tack on TEST define for compiling unit tests
|
|
||||||
load_configuration($cfg_file)
|
|
||||||
|
|
||||||
# Drop Out if we're skipping this type of test
|
# Drop Out if we're skipping this type of test
|
||||||
if $cfg[:skip_tests] && features
|
if $cfg[:skip_tests] && features
|
||||||
if $cfg[:skip_tests].include?(:parameterized) && features.include?(:parameterized)
|
if $cfg[:skip_tests].include?(:parameterized) && features.include?(:parameterized)
|
||||||
|
|||||||
Reference in New Issue
Block a user