mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
run examples fully and pass optional yaml file to them.
begin to automatically reject tests based on criteria.
This commit is contained in:
+23
-9
@@ -27,8 +27,8 @@ SYSTEM_TEST_SUPPORT_DIRS.each do |dir|
|
||||
CLOBBER.include(dir)
|
||||
end
|
||||
|
||||
$config_file = DEFAULT_CONFIG_FILE
|
||||
$overlay_file = nil
|
||||
$cmock_test_config_file = DEFAULT_CONFIG_FILE
|
||||
$cmock_test_overlay_file = nil
|
||||
|
||||
task :prep_system_tests => SYSTEM_TEST_SUPPORT_DIRS
|
||||
task :default => [:test]
|
||||
@@ -37,12 +37,12 @@ task :cruise => :ci
|
||||
|
||||
desc "Load configuration"
|
||||
task :config, [:config_file, :cmock_overlay] do |t, args|
|
||||
$config_file = args[:config_file]
|
||||
$overlay_file = args[:cmock_overlay]
|
||||
$cmock_test_config_file = args[:config_file]
|
||||
$cmock_test_overlay_file = args[:cmock_overlay]
|
||||
end
|
||||
|
||||
task :config_toolchains do
|
||||
configure_toolchain($config_file, $overlay_file)
|
||||
configure_toolchain($cmock_test_config_file, $cmock_test_overlay_file)
|
||||
end
|
||||
|
||||
# Still support testing everything with just 'test' but switch default to ceedling-like test:all
|
||||
@@ -74,10 +74,24 @@ namespace :test do
|
||||
|
||||
desc "Run System Tests"
|
||||
task :system => [:config_toolchains, :clobber, :prep_system_tests] do
|
||||
#get a list of all system tests, removing unsupported tests for this compiler
|
||||
sys_unsupported = unsupported_tests.map {|a| 'system/test_interactions/'+a+'.yml'}
|
||||
# Get a list of all system tests, removing unsupported tests for this toolchain
|
||||
# including those explicitly not included, plus those implicitly based on needs
|
||||
unsupported = unsupported_tests()
|
||||
criteria = {
|
||||
'out_of_memory' => { :defines => ['CMOCK_MEM_STATIC', 'CMOCK_MEM_SIZE=1024']}
|
||||
}
|
||||
criteria.each_pair do |k,v|
|
||||
crit_defs = v[:defines] || []
|
||||
conf_defs = $unity_cfg.dig(:defines,:test,'*') || $unity_cfg.dig(:defines,:test) || []
|
||||
if (crit_defs & conf_defs).empty?
|
||||
unsupported |= [k]
|
||||
end
|
||||
end
|
||||
sys_unsupported = unsupported.map {|a| 'system/test_interactions/'+a+'.yml'}
|
||||
|
||||
# Determine which system tests remain after those are removed
|
||||
sys_tests_to_run = FileList['system/test_interactions/*.yml'] - sys_unsupported
|
||||
compile_unsupported = unsupported_tests.map {|a| SYSTEST_COMPILE_MOCKABLES_PATH+a+'.h'}
|
||||
compile_unsupported = 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..."
|
||||
@@ -93,7 +107,7 @@ namespace :test do
|
||||
|
||||
desc "Test cmock examples"
|
||||
task :examples => [:config_toolchains, :prep_system_tests] do
|
||||
run_examples(true)
|
||||
run_examples()
|
||||
end
|
||||
|
||||
#individual system tests
|
||||
|
||||
+20
-8
@@ -147,7 +147,7 @@ module RakefileHelpers
|
||||
# Returns the unsupported test list, regardless of whether it came from
|
||||
# a CMock overlay or a CMock-only target file.
|
||||
def unsupported_tests
|
||||
$cmock_cfg[:unsupported] || $unity_cfg[:unsupported] || []
|
||||
($cmock_cfg[:unsupported] || []) | ($unity_cfg[:unsupported] || [])
|
||||
end
|
||||
|
||||
# Resolve argument template tokens and produce a flat argument string.
|
||||
@@ -229,6 +229,7 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def execute(command_string, verbose=true, raise_on_failure=true)
|
||||
report(command_string) if verbose
|
||||
output = `#{command_string}`.chomp
|
||||
report(output) if (verbose && !output.nil? && (output.length > 0))
|
||||
if ($?.exitstatus != 0) and (raise_on_failure)
|
||||
@@ -521,7 +522,7 @@ module RakefileHelpers
|
||||
raise "C unit tests failed." if result =~ /FAILED/
|
||||
end
|
||||
|
||||
def run_examples(verbose=false, raise_on_failure=true)
|
||||
def run_examples()
|
||||
report "\n"
|
||||
report "-----------------\n"
|
||||
report "VALIDATE EXAMPLES\n"
|
||||
@@ -529,11 +530,20 @@ module RakefileHelpers
|
||||
total_tests = 0
|
||||
total_failures = 0
|
||||
total_ignored = 0
|
||||
[ "cd #{File.join("..", "examples", "make_example")} && make clean && make setup && make test",
|
||||
"cd #{File.join("..", "examples", "temp_sensor")} && rake ci"
|
||||
].each do |cmd|
|
||||
report "Testing '#{cmd}'"
|
||||
execute(cmd, verbose, false).each_line do |line|
|
||||
puts "DEBUG DIS #{$cmock_test_config_file}"
|
||||
cfg_file = "#{($cmock_test_config_file =~ /[\\\/]/) ? '../' : ''}#{$cmock_test_config_file}"
|
||||
|
||||
# Determine which examples are valid for this platform
|
||||
examples = {
|
||||
:make_example => "cd #{File.join("..", "examples", "make_example")} && make clean && make setup && make test",
|
||||
:rake_example => "cd #{File.join("..", "examples", "temp_sensor")} && rake config[\"#{cfg_file}\"] ci"
|
||||
}
|
||||
examples.delete(:make_example) unless ($cmock_test_config_file =~ /gcc/)
|
||||
|
||||
# Run the examples
|
||||
examples.each_pair do |key, cmd|
|
||||
report "Testing Example: '#{key}'"
|
||||
execute(cmd, true, false).each_line do |line|
|
||||
if line =~ /(\d+) TOTAL TESTS (\d+) TOTAL FAILURES (\d+) IGNORED/
|
||||
total_tests += Regexp.last_match(1).to_i
|
||||
total_failures += Regexp.last_match(2).to_i
|
||||
@@ -541,10 +551,12 @@ module RakefileHelpers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Report the results from the examples
|
||||
result = "#{total_tests} Tests #{total_failures} Failures #{total_ignored} Ignored\n"
|
||||
result += total_failures > 0 ? "FAILED\n" : "OK\n"
|
||||
save_test_results('examples', result)
|
||||
raise "Examples failed." if total_failures > 0 && raise_on_failure
|
||||
raise "Examples failed." if total_failures > 0
|
||||
end
|
||||
|
||||
def fail_out(msg)
|
||||
|
||||
Reference in New Issue
Block a user