Add ability to specify random seed value in tests.

This commit is contained in:
Mark VanderVoord
2026-07-08 16:00:43 -04:00
parent f57e036c00
commit bcddcc19b5
2 changed files with 9 additions and 1 deletions
+7
View File
@@ -29,6 +29,7 @@ end
$cmock_test_config_file = DEFAULT_CONFIG_FILE
$cmock_test_overlay_file = nil
$cmock_test_seed = nil
task :prep_system_tests => SYSTEM_TEST_SUPPORT_DIRS
task :default => [:test]
@@ -41,6 +42,12 @@ task :config, [:config_file, :cmock_overlay] do |t, args|
$cmock_test_overlay_file = args[:cmock_overlay]
end
desc "Fix the minitest random seed for repeatable Ruby unit test ordering"
task :seed, [:seed_value] do |t, args|
$cmock_test_seed = args[:seed_value]
ENV['TESTOPTS'] = "#{ENV['TESTOPTS']} --seed=#{$cmock_test_seed}".strip
end
task :config_toolchains do
configure_toolchain($cmock_test_config_file, $cmock_test_overlay_file)
end
+2 -1
View File
@@ -315,7 +315,8 @@ module RakefileHelpers
total_runs = total_failures = total_errors = total_skips = 0
Dir['unit/*_test.rb'].sort.each do |tst|
report "\nRunning #{tst.to_s}"
output = execute("ruby -I. #{tst} -v", true, false)
seed_opt = $cmock_test_seed ? " --seed=#{$cmock_test_seed}" : ''
output = execute("ruby -I. #{tst} -v#{seed_opt}", true, false)
output.each_line do |line|
if line =~ /(\d+) runs, \d+ assertions, (\d+) failures, (\d+) errors, (\d+) skips/
total_runs += Regexp.last_match(1).to_i