Class: GeneratorTestResultsSanityChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/ceedling/generator_test_results_sanity_checker.rb

Instance Method Summary collapse

Instance Method Details

#verify(results, unity_exit_code) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ceedling/generator_test_results_sanity_checker.rb', line 18

def verify(results, unity_exit_code)

  # do no sanity checking if it's disabled
  return if (@configurator.sanity_checks == TestResultsSanityChecks::NONE)
  raise CeedlingException.new( "Test results nil or empty" ) if results.nil? || results.empty?

  ceedling_ignores_count   = results[:ignores].size 
  ceedling_failures_count  = results[:failures].size
  ceedling_tests_summation = (ceedling_ignores_count + ceedling_failures_count + results[:successes].size)

  # Exit code handling is not a sanity check that can always be performed because 
  # command line simulators may or may not pass through Unity's exit code
  if (@configurator.sanity_checks >= TestResultsSanityChecks::THOROUGH)
    # many platforms limit exit codes to a maximum of 255
    if ((ceedling_failures_count != unity_exit_code) and (unity_exit_code < 255))
      sanity_check_warning(results[:source][:file], "Unity's exit code (#{unity_exit_code}) does not match Ceedling's summation of failed test cases (#{ceedling_failures_count}).")
    end
    
    if ((ceedling_failures_count < 255) and (unity_exit_code == 255))
      sanity_check_warning(results[:source][:file], "Ceedling's summation of failed test cases (#{ceedling_failures_count}) is less than Unity's exit code (255 or more).")
    end
  end
  
  if (ceedling_ignores_count != results[:counts][:ignored])
    sanity_check_warning(results[:source][:file], "Unity's final ignore count (#{results[:counts][:ignored]}) does not match Ceedling's summation of ignored test cases (#{ceedling_ignores_count}).")
  end
  
  if (ceedling_failures_count != results[:counts][:failed])
    sanity_check_warning(results[:source][:file], "Unity's final fail count (#{results[:counts][:failed]}) does not match Ceedling's summation of failed test cases (#{ceedling_failures_count}).")
  end

  if (ceedling_tests_summation != results[:counts][:total])
    sanity_check_warning(results[:source][:file], "Unity's final test count (#{results[:counts][:total]}) does not match Ceedling's summation of all test cases (#{ceedling_tests_summation}).")
  end
  
end