mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-30 05:57:27 +00:00
Add ability to specify random seed value in tests.
This commit is contained in:
@@ -29,6 +29,7 @@ end
|
|||||||
|
|
||||||
$cmock_test_config_file = DEFAULT_CONFIG_FILE
|
$cmock_test_config_file = DEFAULT_CONFIG_FILE
|
||||||
$cmock_test_overlay_file = nil
|
$cmock_test_overlay_file = nil
|
||||||
|
$cmock_test_seed = nil
|
||||||
|
|
||||||
task :prep_system_tests => SYSTEM_TEST_SUPPORT_DIRS
|
task :prep_system_tests => SYSTEM_TEST_SUPPORT_DIRS
|
||||||
task :default => [:test]
|
task :default => [:test]
|
||||||
@@ -41,6 +42,12 @@ task :config, [:config_file, :cmock_overlay] do |t, args|
|
|||||||
$cmock_test_overlay_file = args[:cmock_overlay]
|
$cmock_test_overlay_file = args[:cmock_overlay]
|
||||||
end
|
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
|
task :config_toolchains do
|
||||||
configure_toolchain($cmock_test_config_file, $cmock_test_overlay_file)
|
configure_toolchain($cmock_test_config_file, $cmock_test_overlay_file)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -315,7 +315,8 @@ module RakefileHelpers
|
|||||||
total_runs = total_failures = total_errors = total_skips = 0
|
total_runs = total_failures = total_errors = total_skips = 0
|
||||||
Dir['unit/*_test.rb'].sort.each do |tst|
|
Dir['unit/*_test.rb'].sort.each do |tst|
|
||||||
report "\nRunning #{tst.to_s}"
|
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|
|
output.each_line do |line|
|
||||||
if line =~ /(\d+) runs, \d+ assertions, (\d+) failures, (\d+) errors, (\d+) skips/
|
if line =~ /(\d+) runs, \d+ assertions, (\d+) failures, (\d+) errors, (\d+) skips/
|
||||||
total_runs += Regexp.last_match(1).to_i
|
total_runs += Regexp.last_match(1).to_i
|
||||||
|
|||||||
Reference in New Issue
Block a user