Make sure that examples get run with ci, and using appropriate settings.

This commit is contained in:
Mark VanderVoord
2026-05-29 10:29:30 -04:00
parent 444fbda72a
commit dd70d40adf
4 changed files with 43 additions and 28 deletions
+15 -11
View File
@@ -28,30 +28,30 @@ include RakefileHelpers
# Load proper GCC as defult configuration
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
namespace :test do
desc "Build and test Unity"
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"
task :unit => [:prepare_for_tests] do
task :unit => [:config_toolchain, :prepare_for_tests] do
run_tests unit_test_files
end
namespace :unit do
unit_test_files.each do |f|
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]
end
end
end
desc "Test unity's helper scripts"
task :scripts => [:prepare_for_tests] do
task :scripts => [:config_toolchain, :prepare_for_tests] do
begin
Dir['tests/test_*.rb'].each do |scriptfile|
require "./"+scriptfile
@@ -66,27 +66,27 @@ namespace :test do
end
desc "Test unity triggered from make"
task :make => [:prepare_for_tests] do
task :make => [:config_toolchain, :prepare_for_tests] do
run_make_tests()
end
desc "Test unity fixture addon"
task :fixture => [:prepare_for_tests] do
task :fixture => [:config_toolchain, :prepare_for_tests] do
test_fixtures()
end
desc "Test unity memory addon"
task :memory => [:prepare_for_tests] do
task :memory => [:config_toolchain, :prepare_for_tests] do
test_memory()
end
desc "Test unity examples"
task :examples => [:prepare_for_tests] do
task :examples => [:config_toolchain, :prepare_for_tests] do
run_examples
end
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)
rspec_ok = $?.exitstatus.zero?
report output
@@ -115,7 +115,11 @@ task :default => [:clobber, :all]
desc "Load configuration"
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
task :no_color do
+24 -10
View File
@@ -13,16 +13,19 @@ require_relative '../auto/yaml_helper'
module RakefileHelpers
C_EXTENSION = '.c'.freeze
def load_configuration(config_file)
return if $configured
if config_file =~ /[\\|\/]/
$cfg_file = config_file
$cfg_file_base = config_file
cfg_file = if config_file =~ /[\\|\/]/
$unity_test_config_file_in_targets = false
config_file
else
$cfg_file_base = config_file
$cfg_file = "targets/#{config_file}"
$unity_test_config_file_in_targets = true
"targets/#{config_file}"
end
$cfg = YamlHelper.load_file($cfg_file)
$cfg = YamlHelper.load_file(cfg_file)
$cfg[:paths] ||= {}
$cfg[:paths][:test] = (Array($cfg[:paths][:test]) + ['src/', '../src/', 'testdata/', 'tests/']).uniq
$colour_output = false unless $cfg['colour']
@@ -418,11 +421,22 @@ module RakefileHelpers
def run_examples()
report "\nRunning Unity Examples"
total_tests = total_ignored = 0
[
"cd ../examples/example_1 && make -s ci",
"cd ../examples/example_2 && make -s ci",
"cd ../examples/example_3 && rake config[#{$cfg_file_base || 'gcc_64'}] default"
].each do |cmd|
# If we're set up to use gcc, the makefiles should work too. otherwise, just run example 3
examples = if $cfg_file_base.nil? || ($cfg_file_base =~ /gcc/)
[
"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|
if line =~ /(\d+) Tests \d+ Failures (\d+) Ignored/
total_tests += Regexp.last_match(1).to_i
-3
View File
@@ -1241,9 +1241,6 @@ RUNNER_TESTS = [
]
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
if $cfg[:skip_tests] && features
if $cfg[:skip_tests].include?(:parameterized) && features.include?(:parameterized)