ceedling 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/Rakefile +1 -0
  2. data/bin/ceedling +1 -1
  3. data/lib/ceedling/version.rb +2 -2
  4. data/lib/ceedling/version.rb.erb +1 -1
  5. data/new_project_template/vendor/ceedling/lib/configurator.rb +16 -23
  6. data/new_project_template/vendor/ceedling/lib/configurator_builder.rb +3 -3
  7. data/new_project_template/vendor/ceedling/lib/constants.rb +1 -0
  8. data/new_project_template/vendor/ceedling/lib/defaults.rb +5 -2
  9. data/new_project_template/vendor/ceedling/lib/file_finder.rb +5 -5
  10. data/new_project_template/vendor/ceedling/lib/file_path_utils.rb +8 -0
  11. data/new_project_template/vendor/ceedling/lib/generator.rb +7 -21
  12. data/new_project_template/vendor/ceedling/lib/generator_helper.rb +40 -0
  13. data/new_project_template/vendor/ceedling/lib/generator_test_results.rb +4 -5
  14. data/new_project_template/vendor/ceedling/lib/generator_test_runner.rb +8 -150
  15. data/new_project_template/vendor/ceedling/lib/objects.yml +5 -0
  16. data/new_project_template/vendor/ceedling/lib/rakefile.rb +1 -0
  17. data/new_project_template/vendor/ceedling/lib/rules_release.rake +11 -2
  18. data/new_project_template/vendor/ceedling/lib/rules_tests.rake +7 -2
  19. data/new_project_template/vendor/ceedling/lib/setupinator.rb +0 -1
  20. data/new_project_template/vendor/ceedling/lib/system_wrapper.rb +4 -4
  21. data/new_project_template/vendor/ceedling/lib/tasks_release.rake +1 -1
  22. data/new_project_template/vendor/ceedling/lib/test_invoker_helper.rb +1 -1
  23. data/new_project_template/vendor/ceedling/lib/tool_executor_helper.rb +2 -2
  24. data/new_project_template/vendor/ceedling/plugins/bullseye/bullseye.rake +6 -1
  25. data/new_project_template/vendor/ceedling/plugins/bullseye/bullseye.rb +7 -2
  26. data/new_project_template/vendor/ceedling/plugins/bullseye/readme.txt +0 -0
  27. data/new_project_template/vendor/ceedling/plugins/gcov/gcov.rake +6 -1
  28. data/new_project_template/vendor/ceedling/plugins/gcov/gcov.rb +7 -2
  29. data/new_project_template/vendor/ceedling/plugins/gcov/readme.txt +0 -0
  30. data/new_project_template/vendor/ceedling/plugins/xml_tests_report/xml_tests_report.rb +1 -1
  31. data/new_project_template/vendor/ceedling/release/build.info +2 -1
  32. data/new_project_template/vendor/ceedling/vendor/unity/auto/generate_test_runner.rb +308 -0
  33. data/new_project_template/vendor/ceedling/vendor/unity/src/unity_internals.h +13 -13
  34. metadata +9 -5
data/Rakefile CHANGED
@@ -31,6 +31,7 @@ task :update_tools do
31
31
  {:src => 'vendor/constructor/lib/', :dest => 'vendor/constructor/'},
32
32
  {:src => 'vendor/deep_merge/lib/', :dest => 'vendor/deep_merge/'},
33
33
  {:src => 'vendor/diy/lib', :dest => 'vendor/diy/'},
34
+ {:src => 'vendor/unity/auto/', :dest => 'vendor/unity/'},
34
35
  {:src => 'vendor/unity/release/', :dest => 'vendor/unity/'},
35
36
  {:src => 'vendor/unity/src/', :dest => 'vendor/unity/'},
36
37
  {:src => 'vendor/c_exception/docs/CExceptionSummary.pdf', :dest => 'docs/', :is_file => true},
@@ -37,7 +37,7 @@ class CeedlingTasks < Thor
37
37
  end
38
38
  end
39
39
 
40
- desc "example [PROJ_NAME] [DEST]", "create specified example project (in DEST, if specified)"
40
+ desc "example PROJ_NAME [DEST]", "create specified example project (in DEST, if specified)"
41
41
  def example(proj_name, dest=".")
42
42
  dest = "." if dest.nil?
43
43
  directory Ceedling::NEW_PROJECT_DIR, dest
@@ -2,10 +2,10 @@
2
2
  module Ceedling
3
3
  module Version
4
4
  # @private
5
- GEM = "0.0.5"
5
+ GEM = "0.0.7"
6
6
 
7
7
  # @private
8
- CEEDLING = "0.9.175"
8
+ CEEDLING = "0.9.185"
9
9
  # @private
10
10
  CEXCEPTION = "1.2.16"
11
11
  # @private
@@ -2,7 +2,7 @@
2
2
  module Ceedling
3
3
  module Version
4
4
  # @private
5
- GEM = "0.0.5"
5
+ GEM = "0.0.6"
6
6
 
7
7
  # @private
8
8
  CEEDLING = "<%= versions["CEEDLING"] %>"
@@ -78,22 +78,6 @@ class Configurator
78
78
  @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE_DEPENDENCIES ) if (config[:project][:release_build] and config[:project][:use_auxiliary_dependencies])
79
79
  end
80
80
 
81
-
82
- def populate_unity_defines(config)
83
- run_test = true
84
-
85
- config[:unity][:defines].each do |define|
86
- if (define =~ /RUN_TEST\s*\(.+\)\s*=/)
87
- run_test = false
88
- break
89
- end
90
- end
91
-
92
- if (run_test)
93
- config[:unity][:defines] << "\"RUN_TEST(func, line_num)=TestRun(func, #func, line_num)\""
94
- end
95
- end
96
-
97
81
 
98
82
  def populate_cmock_defaults(config)
99
83
  # cmock has its own internal defaults handling, but we need to set these specific values
@@ -122,9 +106,13 @@ class Configurator
122
106
  cmock[:includes].uniq!
123
107
  end
124
108
 
109
+ @runner_config = cmock
125
110
  @cmock_builder.manufacture(cmock)
126
111
  end
127
-
112
+
113
+ def get_runner_config
114
+ @runner_config
115
+ end
128
116
 
129
117
  # grab tool names from yaml and insert into tool structures so available for error messages
130
118
  # set up default values
@@ -192,12 +180,17 @@ class Configurator
192
180
 
193
181
  def eval_environment_variables(config)
194
182
  config[:environment].each do |hash|
195
- key = hash.keys[0]
196
- value_string = hash[key].to_s
197
- if (value_string =~ RUBY_STRING_REPLACEMENT_PATTERN)
198
- value_string.replace(@system_wrapper.module_eval(value_string))
199
- end
200
- @system_wrapper.env_set(key.to_s.upcase, value_string)
183
+ key = hash.keys[0]
184
+ value = hash[key]
185
+ items = []
186
+
187
+ interstitial = ((key == :path) ? File::PATH_SEPARATOR : '')
188
+ items = ((value.class == Array) ? hash[key] : [value])
189
+
190
+ items.map { |item| item.replace( @system_wrapper.module_eval( item ) ) if (item =~ RUBY_STRING_REPLACEMENT_PATTERN) }
191
+ hash[key] = items.join( interstitial )
192
+
193
+ @system_wrapper.env_set( key.to_s.upcase, hash[key] )
201
194
  end
202
195
  end
203
196
 
@@ -261,8 +261,8 @@ class ConfiguratorBuilder
261
261
  extra_paths = []
262
262
  extra_paths << FilePathUtils::form_ceedling_vendor_path(UNITY_LIB_PATH)
263
263
  extra_paths << FilePathUtils::form_ceedling_vendor_path(CEXCEPTION_LIB_PATH) if (in_hash[:project_use_exceptions])
264
- extra_paths << FilePathUtils::form_ceedling_vendor_path(CMOCK_LIB_PATH) if (in_hash[:project_use_mocks])
265
- extra_paths << in_hash[:cmock_mock_path] if (in_hash[:project_use_mocks])
264
+ extra_paths << FilePathUtils::form_ceedling_vendor_path(CMOCK_LIB_PATH) if (in_hash[:project_use_mocks])
265
+ extra_paths << in_hash[:cmock_mock_path] if (in_hash[:project_use_mocks])
266
266
 
267
267
  return {
268
268
  :collection_paths_test_support_source_include_vendor =>
@@ -371,7 +371,7 @@ class ConfiguratorBuilder
371
371
 
372
372
  # no build paths here so plugins can remap if necessary (i.e. path mapping happens at runtime)
373
373
  objects << CEXCEPTION_C_FILE.ext( in_hash[:extension_object] ) if (in_hash[:project_use_exceptions])
374
-
374
+
375
375
  return {:collection_release_artifact_extra_link_objects => objects}
376
376
  end
377
377
 
@@ -76,6 +76,7 @@ UTILS_SYM = UTILS_ROOT_NAME.to_sym
76
76
  RUBY_STRING_REPLACEMENT_PATTERN = /#\{.+\}/
77
77
  RUBY_EVAL_REPLACEMENT_PATTERN = /^\{(.+)\}$/
78
78
  TOOL_EXECUTOR_ARGUMENT_REPLACEMENT_PATTERN = /(\$\{(\d+)\})/
79
+ TEST_STDOUT_STATISTICS_PATTERN = /-+\s+(\d+)\s+Tests\s+(\d+)\s+Failures\s+(\d+)\s+Ignored\s+(OK|FAIL)\s*/i
79
80
 
80
81
  NULL_FILE_PATH = '/dev/null'
81
82
 
@@ -16,6 +16,7 @@ DEFAULT_TEST_COMPILER_TOOL = {
16
16
  "-DGNU_COMPILER".freeze,
17
17
  "-c \"${1}\"".freeze,
18
18
  "-o \"${2}\"".freeze,
19
+ # gcc's list file output options are complex; no use of ${3} parameter in default config
19
20
  ].freeze
20
21
  }
21
22
 
@@ -72,7 +73,7 @@ DEFAULT_TEST_FILE_PREPROCESSOR_TOOL = {
72
73
  :arguments => [
73
74
  '-E'.freeze,
74
75
  {"-I\"$\"" => 'COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'}.freeze,
75
- {"-I\"$\"" => 'PATHS_TEST_TOOLCHAIN_INCLUDE'}.freeze,
76
+ {"-I\"$\"" => 'COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'}.freeze,
76
77
  {"-D$" => 'COLLECTION_DEFINES_TEST_AND_VENDOR'}.freeze,
77
78
  {"-D$" => 'DEFINES_TEST_PREPROCESS'}.freeze,
78
79
  "-DGNU_PREPROCESSOR".freeze,
@@ -109,7 +110,7 @@ DEFAULT_RELEASE_DEPENDENCIES_GENERATOR_TOOL = {
109
110
  :background_exec => BackgroundExec::NONE.freeze,
110
111
  :optional => false.freeze,
111
112
  :arguments => [
112
- {"-I\"$\"" => 'COLLECTION_PATHS_SOURCE_AND_INCLUDE'}.freeze,
113
+ {"-I\"$\"" => 'COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR'}.freeze,
113
114
  {"-I\"$\"" => 'COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE'}.freeze,
114
115
  {"-D$" => 'COLLECTION_DEFINES_RELEASE_AND_VENDOR'}.freeze,
115
116
  {"-D$" => 'DEFINES_RELEASE_PREPROCESS'}.freeze,
@@ -137,6 +138,7 @@ DEFAULT_RELEASE_COMPILER_TOOL = {
137
138
  "-DGNU_COMPILER".freeze,
138
139
  "-c \"${1}\"".freeze,
139
140
  "-o \"${2}\"".freeze,
141
+ # gcc's list file output options are complex; no use of ${3} parameter in default config
140
142
  ].freeze
141
143
  }
142
144
 
@@ -256,6 +258,7 @@ DEFAULT_CEEDLING_CONFIG = {
256
258
  :object => '.o',
257
259
  :executable => ( SystemWrapper.windows? ? EXTENSION_WIN_EXE : EXTENSION_NONWIN_EXE ),
258
260
  :map => '.map',
261
+ :list => '.lst',
259
262
  :testpass => '.pass',
260
263
  :testfail => '.fail',
261
264
  :dependencies => '.d',
@@ -83,8 +83,8 @@ class FileFinder
83
83
  end
84
84
 
85
85
 
86
- def find_compilation_input_file(file_path)
87
- found_file = ''
86
+ def find_compilation_input_file(file_path, complain=:error)
87
+ found_file = nil
88
88
 
89
89
  source_file = File.basename(file_path).ext(@configurator.extension_source)
90
90
 
@@ -96,21 +96,21 @@ class FileFinder
96
96
  @file_finder_helper.find_file_in_collection(
97
97
  source_file,
98
98
  @file_wrapper.directory_listing( File.join(@configurator.project_test_runners_path, '*') ),
99
- :error)
99
+ complain)
100
100
 
101
101
  elsif (@configurator.project_use_mocks and (source_file =~ /#{@configurator.cmock_mock_prefix}/))
102
102
  found_file =
103
103
  @file_finder_helper.find_file_in_collection(
104
104
  source_file,
105
105
  @file_wrapper.directory_listing( File.join(@configurator.cmock_mock_path, '*') ),
106
- :error)
106
+ complain)
107
107
 
108
108
  else
109
109
  found_file =
110
110
  @file_finder_helper.find_file_in_collection(
111
111
  source_file,
112
112
  @configurator.collection_all_existing_compilation_input,
113
- :error)
113
+ complain)
114
114
  end
115
115
 
116
116
  return found_file
@@ -107,6 +107,10 @@ class FilePathUtils
107
107
  def form_release_build_asm_objects_filelist(files)
108
108
  return (@file_wrapper.instantiate_file_list(files)).pathmap("#{@configurator.project_release_build_output_asm_path}/%n#{@configurator.extension_object}")
109
109
  end
110
+
111
+ def form_release_build_c_list_filepath(filepath)
112
+ return File.join( @configurator.project_release_build_output_c_path, File.basename(filepath).ext(@configurator.extension_list) )
113
+ end
110
114
 
111
115
  def form_release_dependencies_filelist(files)
112
116
  return (@file_wrapper.instantiate_file_list(files)).pathmap("#{@configurator.project_release_dependencies_path}/%n#{@configurator.extension_dependencies}")
@@ -149,6 +153,10 @@ class FilePathUtils
149
153
  return File.join( @configurator.project_test_build_output_path, File.basename(filepath).ext(@configurator.extension_map) )
150
154
  end
151
155
 
156
+ def form_test_build_list_filepath(filepath)
157
+ return File.join( @configurator.project_test_build_output_path, File.basename(filepath).ext(@configurator.extension_list) )
158
+ end
159
+
152
160
  def form_preprocessed_file_filepath(filepath)
153
161
  return File.join( @configurator.project_test_preprocess_files_path, File.basename(filepath) )
154
162
  end
@@ -1,9 +1,9 @@
1
- require 'constants' # for Verbosity constants class
1
+ require 'constants'
2
2
 
3
3
 
4
4
  class Generator
5
5
 
6
- constructor :configurator, :preprocessinator, :cmock_builder, :generator_test_runner, :generator_test_results, :test_includes_extractor, :tool_executor, :file_finder, :file_path_utils, :streaminator, :plugin_manager, :file_wrapper
6
+ constructor :configurator, :generator_helper, :preprocessinator, :cmock_builder, :generator_test_runner, :generator_test_results, :test_includes_extractor, :tool_executor, :file_finder, :file_path_utils, :streaminator, :plugin_manager, :file_wrapper
7
7
 
8
8
 
9
9
  def generate_shallow_includes_list(context, file)
@@ -40,7 +40,6 @@ class Generator
40
40
  # test_filepath may be either preprocessed test file or original test file
41
41
  def generate_test_runner(context, test_filepath, runner_filepath)
42
42
  arg_hash = {:context => context, :test_file => test_filepath, :runner_file => runner_filepath}
43
-
44
43
  @plugin_manager.pre_runner_execute(arg_hash)
45
44
 
46
45
  # collect info we need
@@ -51,23 +50,17 @@ class Generator
51
50
  @streaminator.stdout_puts("Generating runner for #{module_name}...", Verbosity::NORMAL)
52
51
 
53
52
  # build runner file
54
- @file_wrapper.open(runner_filepath, 'w') do |output|
55
- @generator_test_runner.create_header(output, mock_list)
56
- @generator_test_runner.create_externs(output, test_cases)
57
- @generator_test_runner.create_mock_management(output, mock_list)
58
- @generator_test_runner.create_runtest(output, mock_list, test_cases)
59
- @generator_test_runner.create_main(output, module_name, test_cases)
60
- end
53
+ @generator_test_runner.generate(module_name, runner_filepath, test_cases, mock_list)
61
54
 
62
55
  @plugin_manager.post_runner_execute(arg_hash)
63
56
  end
64
57
 
65
- def generate_object_file(tool, context, source, object)
66
- arg_hash = {:tool => tool, :context => context, :source => source, :object => object}
58
+ def generate_object_file(tool, context, source, object, list='')
59
+ arg_hash = {:tool => tool, :context => context, :source => source, :object => object, :list => list}
67
60
  @plugin_manager.pre_compile_execute(arg_hash)
68
61
 
69
62
  @streaminator.stdout_puts("Compiling #{File.basename(arg_hash[:source])}...", Verbosity::NORMAL)
70
- command = @tool_executor.build_command_line(arg_hash[:tool], arg_hash[:source], arg_hash[:object])
63
+ command = @tool_executor.build_command_line(arg_hash[:tool], arg_hash[:source], arg_hash[:object], arg_hash[:list])
71
64
  shell_result = @tool_executor.exec( command[:line], command[:options] )
72
65
 
73
66
  arg_hash[:shell_result] = shell_result
@@ -116,14 +109,7 @@ class Generator
116
109
  command[:options][:boom] = false
117
110
  shell_result = @tool_executor.exec( command[:line], command[:options] )
118
111
 
119
- if (shell_result[:output].nil? or shell_result[:output].strip.empty?)
120
- notice = "\n" +
121
- "ERROR: Test executable \"#{File.basename(executable)}\" did not produce any results.\n" +
122
- "This is most often a symptom of bad memory accesses in source or test code.\n\n"
123
-
124
- @streaminator.stderr_puts(notice, Verbosity::COMPLAIN)
125
- raise
126
- end
112
+ @generator_helper.test_results_error_handler(executable, shell_result)
127
113
 
128
114
  processed = @generator_test_results.process_and_write_results( shell_result,
129
115
  arg_hash[:result_file],
@@ -0,0 +1,40 @@
1
+ require 'constants'
2
+
3
+
4
+ class GeneratorHelper
5
+
6
+ constructor :streaminator
7
+
8
+
9
+ def test_results_error_handler(executable, shell_result)
10
+ notice = ''
11
+ error = false
12
+
13
+ if (shell_result[:output].nil? or shell_result[:output].strip.empty?)
14
+ error = true
15
+ # mirror style of generic tool_executor failure output
16
+ notice = "\n" +
17
+ "ERROR: Test executable \"#{File.basename(executable)}\" failed.\n" +
18
+ "> Produced no output to $stdout.\n"
19
+ elsif ((shell_result[:output] =~ TEST_STDOUT_STATISTICS_PATTERN).nil?)
20
+ error = true
21
+ # mirror style of generic tool_executor failure output
22
+ notice = "\n" +
23
+ "ERROR: Test executable \"#{File.basename(executable)}\" failed.\n" +
24
+ "> Produced no test results in $stdout:\n" +
25
+ "#{shell_result[:output].strip}\n"
26
+ end
27
+
28
+ if (error)
29
+ # since we told the tool executor to ignore the exit code, handle it explicitly here
30
+ notice += "> And exited with status: [#{shell_result[:exit_code]}] (count of failed tests).\n" if (shell_result[:exit_code] != nil)
31
+ notice += "> And then likely crashed.\n" if (shell_result[:exit_code] == nil)
32
+
33
+ notice += "> This is often a symptom of a bad memory access in source or test code.\n\n"
34
+
35
+ @streaminator.stderr_puts(notice, Verbosity::COMPLAIN)
36
+ raise
37
+ end
38
+ end
39
+
40
+ end
@@ -4,12 +4,11 @@ require 'constants'
4
4
 
5
5
 
6
6
  class GeneratorTestResults
7
- TEST_STATISTICS_REGEX = /-+\s+(\d+)\s+Tests\s+(\d+)\s+Failures\s+(\d+)\s+Ignored\s+(OK|FAIL)\s*/i
8
7
 
9
8
  constructor :configurator, :generator_test_results_sanity_checker, :yaml_wrapper
10
9
 
11
10
  def process_and_write_results(unity_shell_result, results_file, test_file)
12
- output_file = results_file
11
+ output_file = results_file
13
12
 
14
13
  results = get_results_structure
15
14
 
@@ -17,7 +16,7 @@ class GeneratorTestResults
17
16
  results[:source][:file] = File.basename(test_file)
18
17
 
19
18
  # process test statistics
20
- if (unity_shell_result[:output] =~ TEST_STATISTICS_REGEX)
19
+ if (unity_shell_result[:output] =~ TEST_STDOUT_STATISTICS_PATTERN)
21
20
  results[:counts][:total] = $1.to_i
22
21
  results[:counts][:failed] = $2.to_i
23
22
  results[:counts][:ignored] = $3.to_i
@@ -25,10 +24,10 @@ class GeneratorTestResults
25
24
  end
26
25
 
27
26
  # remove test statistics lines
28
- unity_shell_result[:output].sub!(TEST_STATISTICS_REGEX, '')
27
+ output_string = unity_shell_result[:output].sub(TEST_STDOUT_STATISTICS_PATTERN, '')
29
28
 
30
29
  # bust up the output into individual lines
31
- raw_unity_lines = unity_shell_result[:output].split(/\n|\r\n/)
30
+ raw_unity_lines = output_string.split(/\n|\r\n/)
32
31
 
33
32
  raw_unity_lines.each do |line|
34
33
  # process unity output
@@ -3,7 +3,6 @@ class GeneratorTestRunner
3
3
 
4
4
  constructor :configurator, :file_path_utils, :file_wrapper
5
5
 
6
-
7
6
  def find_test_cases(test_file)
8
7
  tests = []
9
8
  tests_and_line_numbers = []
@@ -53,154 +52,13 @@ class GeneratorTestRunner
53
52
  return tests_and_line_numbers
54
53
  end
55
54
 
56
-
57
- def create_header(output, mock_list)
58
- output << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
59
- output << "#include \"unity.h\"\n"
60
-
61
- @configurator.test_runner_includes.each do |include|
62
- output << "#include \"#{include}\"\n"
63
- end
64
-
65
- output << "#include <setjmp.h>\n"
66
- output << "#include <stdio.h>\n"
67
-
68
- if (@configurator.project_use_exceptions == true)
69
- output << "#include \"CException.h\"\n"
70
- end
71
-
72
- unless (mock_list.empty?)
73
- header_extension = @configurator.extension_header
74
- mock_list.each do |mock|
75
- output << "#include \"#{mock}#{header_extension}\"\n"
76
- end
77
- if (@configurator.cmock_enforce_strict_ordering == true)
78
- output << "\n"
79
- output << "int GlobalExpectCount;\n"
80
- output << "int GlobalVerifyOrder;\n"
81
- output << "char* GlobalOrderError;\n"
82
- end
83
- end
84
-
85
- output << "\n"
86
- output << "char MessageBuffer[50];\n"
87
- end
88
-
89
-
90
- def create_externs(output, test_cases)
91
- output << "\n"
92
- output << "extern void setUp(void);\n"
93
- output << "extern void tearDown(void);\n"
94
- output << "\n" if not test_cases.empty?
95
-
96
- test_cases.each do |item|
97
- output << "extern void #{item[:test]}(void);\n"
98
- end
99
- end
100
-
101
-
102
- def create_mock_management(output, mock_list)
103
-
104
- unless (mock_list.empty?)
105
- header_extension = @configurator.extension_header
106
-
107
- output << "\n"
108
- output << "static void CMock_Init(void)\n"
109
- output << "{\n"
110
-
111
- if (@configurator.cmock_enforce_strict_ordering == true)
112
- output << " GlobalExpectCount = 0;\n"
113
- output << " GlobalVerifyOrder = 0;\n"
114
- output << " GlobalOrderError = NULL;\n"
115
- end
116
-
117
- mock_list.each do |mock|
118
- output << " #{mock.sub(/#{'\\'+header_extension}/, '')}_Init();\n"
119
- end
120
- output << "}\n"
121
- output << "\n"
122
-
123
- output << "static void CMock_Verify(void)\n"
124
- output << "{\n"
125
- mock_list.each do |mock|
126
- output << " #{mock.sub(/#{'\\'+header_extension}/, '')}_Verify();\n"
127
- end
128
- output << "}\n"
129
- output << "\n"
130
-
131
- output << "static void CMock_Destroy(void)\n"
132
- output << "{\n"
133
- mock_list.each do |mock|
134
- output << " #{mock.sub(/#{'\\'+header_extension}/, '')}_Destroy();\n"
135
- end
136
- output << "}\n"
137
- output << "\n"
138
-
139
- output << "void CMock_VerifyAndReset(void)\n"
140
- output << "{\n"
141
- output << " CMock_Verify();\n"
142
- output << " CMock_Destroy();\n"
143
- output << " CMock_Init();\n"
144
- output << "}\n"
145
- output << "\n"
146
- end
147
-
148
- end
149
-
150
-
151
- def create_runtest(output, mock_list, test_cases)
152
-
153
- unless(test_cases.empty?)
154
- use_exceptions = @configurator.project_use_exceptions
155
-
156
- tab = ' ' # default spacing
157
- tab = ' ' if (use_exceptions)
158
-
159
- output << "\n"
160
- output << "static void TestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)\n"
161
- output << "{\n"
162
- output << " Unity.CurrentTestName = FuncName;\n"
163
- output << " Unity.CurrentTestLineNumber = FuncLineNum;\n"
164
- output << " Unity.NumberOfTests++;\n"
165
- output << " if (TEST_PROTECT())\n"
166
- output << " {\n"
167
- output << " CEXCEPTION_T e;\n" if use_exceptions
168
- output << " Try {\n" if use_exceptions
169
- output << "#{tab}CMock_Init();\n" unless (mock_list.empty?)
170
- output << "#{tab}setUp();\n"
171
- output << "#{tab}Func();\n"
172
- output << "#{tab}CMock_Verify();\n" unless (mock_list.empty?)
173
- output << " } Catch(e) { TEST_FAIL_MESSAGE(\"Unhandled Exception!\"); }\n" if use_exceptions
174
- output << " }\n"
175
- output << " CMock_Destroy();\n" unless (mock_list.empty?)
176
- output << " if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))\n"
177
- output << " {\n"
178
- output << " tearDown();\n"
179
- output << " }\n"
180
- output << " UnityConcludeTest();\n"
181
- output << "}\n"
182
- end
183
-
184
- end
185
-
186
-
187
- def create_main(output, module_name, test_cases)
188
- output << "\n"
189
- output << "int main(void)\n"
190
- output << "{\n"
191
- output << " UnityBegin();\n"
192
- output << " Unity.TestFile = \"#{module_name}\";\n"
193
- output << "\n"
194
-
195
- output << " // RUN_TEST calls runTest\n" unless (test_cases.empty?)
196
- test_cases.each do |item|
197
- output << " RUN_TEST(#{item[:test]}, #{item[:line_number]});\n"
198
- end
199
-
200
- output << "\n"
201
- output << " return UnityEnd();\n"
202
- output << "}\n"
203
- output << "\n"
55
+ def generate(module_name, runner_filepath, test_cases, mock_list)
56
+ require 'generate_test_runner.rb'
57
+ @test_runner_generator ||= UnityTestRunnerGenerator.new( @configurator.get_runner_config )
58
+ @test_runner_generator.generate( module_name,
59
+ runner_filepath,
60
+ test_cases,
61
+ @configurator.test_runner_includes,
62
+ mock_list)
204
63
  end
205
-
206
64
  end
@@ -170,6 +170,7 @@ task_invoker:
170
170
  generator:
171
171
  compose:
172
172
  - configurator
173
+ - generator_helper
173
174
  - preprocessinator
174
175
  - cmock_builder
175
176
  - generator_test_runner
@@ -182,6 +183,10 @@ generator:
182
183
  - plugin_manager
183
184
  - file_wrapper
184
185
 
186
+ generator_helper:
187
+ compose:
188
+ - streaminator
189
+
185
190
  generator_test_results:
186
191
  compose:
187
192
  - configurator
@@ -7,6 +7,7 @@ CEEDLING_VENDOR = File.join(CEEDLING_ROOT, 'vendor')
7
7
  CEEDLING_RELEASE = File.join(CEEDLING_ROOT, 'release')
8
8
 
9
9
  $LOAD_PATH.unshift( CEEDLING_LIB )
10
+ $LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'unity/auto') )
10
11
  $LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'diy/lib') )
11
12
  $LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'constructor/lib') )
12
13
  $LOAD_PATH.unshift( File.join(CEEDLING_VENDOR, 'cmock/lib') )
@@ -9,7 +9,11 @@ rule(/#{PROJECT_RELEASE_BUILD_OUTPUT_ASM_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ =>
9
9
  @ceedling[:file_finder].find_assembly_file(task_name)
10
10
  end
11
11
  ]) do |object|
12
- @ceedling[:generator].generate_object_file(TOOLS_RELEASE_ASSEMBLER, RELEASE_SYM, object.source, object.name)
12
+ @ceedling[:generator].generate_object_file(
13
+ TOOLS_RELEASE_ASSEMBLER,
14
+ RELEASE_SYM,
15
+ object.source,
16
+ object.name )
13
17
  end
14
18
  end
15
19
 
@@ -19,7 +23,12 @@ rule(/#{PROJECT_RELEASE_BUILD_OUTPUT_C_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ => [
19
23
  @ceedling[:file_finder].find_compilation_input_file(task_name)
20
24
  end
21
25
  ]) do |object|
22
- @ceedling[:generator].generate_object_file(TOOLS_RELEASE_COMPILER, RELEASE_SYM, object.source, object.name)
26
+ @ceedling[:generator].generate_object_file(
27
+ TOOLS_RELEASE_COMPILER,
28
+ RELEASE_SYM,
29
+ object.source,
30
+ object.name,
31
+ @ceedling[:file_path_utils].form_release_build_c_list_filepath( object.name ) )
23
32
  end
24
33
 
25
34
 
@@ -14,7 +14,12 @@ rule(/#{PROJECT_TEST_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ => [
14
14
  @ceedling[:file_finder].find_compilation_input_file(task_name)
15
15
  end
16
16
  ]) do |object|
17
- @ceedling[:generator].generate_object_file(TOOLS_TEST_COMPILER, TEST_SYM, object.source, object.name)
17
+ @ceedling[:generator].generate_object_file(
18
+ TOOLS_TEST_COMPILER,
19
+ TEST_SYM,
20
+ object.source,
21
+ object.name,
22
+ @ceedling[:file_path_utils].form_test_build_list_filepath( object.name ) )
18
23
  end
19
24
 
20
25
 
@@ -24,7 +29,7 @@ rule(/#{PROJECT_TEST_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_EXECUTABLE}$/) do |b
24
29
  TEST_SYM,
25
30
  bin_file.prerequisites,
26
31
  bin_file.name,
27
- @ceedling[:file_path_utils].form_test_build_map_filepath(bin_file.name))
32
+ @ceedling[:file_path_utils].form_test_build_map_filepath( bin_file.name ) )
28
33
  end
29
34
 
30
35
 
@@ -21,7 +21,6 @@ class Setupinator
21
21
  # note: configurator modifies the cmock section of the hash with a couple defaults to tie
22
22
  # project together - the modified hash is used to build cmock object
23
23
  @ceedling[:configurator].populate_defaults( config_hash )
24
- @ceedling[:configurator].populate_unity_defines( config_hash )
25
24
  @ceedling[:configurator].populate_cmock_defaults( config_hash )
26
25
  @ceedling[:configurator].find_and_merge_plugins( config_hash )
27
26
  @ceedling[:configurator].tools_setup( config_hash )
@@ -42,16 +42,16 @@ class SystemWrapper
42
42
 
43
43
  def shell_backticks(command)
44
44
  return {
45
- :output => `#{command}`,
46
- :exit_code => ($?.exitstatus)
45
+ :output => `#{command}`.freeze,
46
+ :exit_code => ($?.exitstatus).freeze
47
47
  }
48
48
  end
49
49
 
50
50
  def shell_system(command)
51
51
  system( command )
52
52
  return {
53
- :output => '',
54
- :exit_code => ($?.exitstatus)
53
+ :output => ''.freeze,
54
+ :exit_code => ($?.exitstatus).freeze
55
55
  }
56
56
  end
57
57
 
@@ -9,7 +9,7 @@ task RELEASE_SYM => [:directories] do
9
9
 
10
10
  core_objects = []
11
11
  extra_objects = @ceedling[:file_path_utils].form_release_build_c_objects_filelist( COLLECTION_RELEASE_ARTIFACT_EXTRA_LINK_OBJECTS )
12
-
12
+
13
13
  @ceedling[:project_config_manager].process_release_config_change
14
14
  core_objects.concat( @ceedling[:release_invoker].setup_and_invoke_c_objects( COLLECTION_ALL_SOURCE ) )
15
15
 
@@ -23,7 +23,7 @@ class TestInvokerHelper
23
23
  sources = []
24
24
  includes = @test_includes_extractor.lookup_includes_list(test)
25
25
 
26
- includes.each { |include| sources << @file_finder.find_source_file(include, :ignore) }
26
+ includes.each { |include| sources << @file_finder.find_compilation_input_file(include, :ignore) }
27
27
 
28
28
  return sources.compact
29
29
  end
@@ -87,7 +87,7 @@ class ToolExecutorHelper
87
87
  if ((shell_result[:exit_code] == 0) or ((shell_result[:exit_code] != 0) and not boom))
88
88
  output = "> Shell executed command:\n"
89
89
  output += "#{command_str}\n"
90
- output += "> Produced response:\n" if (not shell_result[:output].empty?)
90
+ output += "> Produced output:\n" if (not shell_result[:output].empty?)
91
91
  output += "#{shell_result[:output].strip}\n" if (not shell_result[:output].empty?)
92
92
  output += "> And exited with status: [#{shell_result[:exit_code]}].\n" if (shell_result[:exit_code] != 0)
93
93
  output += "\n"
@@ -102,7 +102,7 @@ class ToolExecutorHelper
102
102
  output = "ERROR: Shell command failed.\n"
103
103
  output += "> Shell executed command:\n"
104
104
  output += "'#{command_str}'\n"
105
- output += "> Produced response:\n" if (not shell_result[:output].empty?)
105
+ output += "> Produced output:\n" if (not shell_result[:output].empty?)
106
106
  output += "#{shell_result[:output].strip}\n" if (not shell_result[:output].empty?)
107
107
  output += "> And exited with status: [#{shell_result[:exit_code]}].\n" if (shell_result[:exit_code] != nil)
108
108
  output += "> And then likely crashed.\n" if (shell_result[:exit_code] == nil)
@@ -18,7 +18,12 @@ rule(/#{BULLSEYE_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ => [
18
18
  ]) do |object|
19
19
 
20
20
  if (File.basename(object.source) =~ /^(#{PROJECT_TEST_FILE_PREFIX}|#{CMOCK_MOCK_PREFIX}|unity|cmock|cexception)/i)
21
- @ceedling[:generator].generate_object_file(TOOLS_BULLSEYE_COMPILER, BULLSEYE_CONTEXT, object.source, object.name)
21
+ @ceedling[:generator].generate_object_file(
22
+ TOOLS_BULLSEYE_COMPILER,
23
+ BULLSEYE_CONTEXT,
24
+ object.source,
25
+ object.name,
26
+ @ceedling[:file_path_utils].form_test_build_list_filepath( object.name ) )
22
27
  else
23
28
  @ceedling[BULLSEYE_CONTEXT].generate_coverage_object_file(object.source, object.name)
24
29
  end
@@ -35,7 +35,12 @@ class Bullseye < Plugin
35
35
  @ceedling[:plugin_manager].pre_compile_execute(arg_hash)
36
36
 
37
37
  @ceedling[:streaminator].stdout_puts("Compiling #{File.basename(source)} with coverage...")
38
- compile_command = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_COMPILER, source, object)
38
+ compile_command =
39
+ @ceedling[:tool_executor].build_command_line(
40
+ TOOLS_BULLSEYE_COMPILER,
41
+ source,
42
+ object,
43
+ @ceedling[:file_path_utils].form_test_build_list_filepath( object ) )
39
44
  coverage_command = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_INSTRUMENTATION, compile_command[:line] )
40
45
 
41
46
  shell_result = @ceedling[:tool_executor].exec( coverage_command[:line], coverage_command[:options] )
@@ -124,7 +129,7 @@ class Bullseye < Plugin
124
129
  sources.each do |source|
125
130
  command = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_REPORT_COVFN, source)
126
131
  shell_results = @ceedling[:tool_executor].exec(command[:line], command[:options])
127
- coverage_results = shell_results[:output]
132
+ coverage_results = shell_results[:output].deep_clone
128
133
  coverage_results.sub!(/.*\n.*\n/,'') # Remove the Bullseye tool banner
129
134
  if (coverage_results =~ /warning cov814: report is empty/)
130
135
  coverage_results = "WARNING: #{source} contains no coverage data!\n\n"
@@ -18,7 +18,12 @@ rule(/#{GCOV_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ => [
18
18
  ]) do |object|
19
19
 
20
20
  if (File.basename(object.source) =~ /^(#{PROJECT_TEST_FILE_PREFIX}|#{CMOCK_MOCK_PREFIX}|unity|cmock|cexception)/i)
21
- @ceedling[:generator].generate_object_file(TOOLS_GCOV_COMPILER, GCOV_CONTEXT, object.source, object.name)
21
+ @ceedling[:generator].generate_object_file(
22
+ TOOLS_GCOV_COMPILER,
23
+ GCOV_CONTEXT,
24
+ object.source,
25
+ object.name,
26
+ @ceedling[:file_path_utils].form_test_build_list_filepath( object.name ) )
22
27
  else
23
28
  @ceedling[GCOV_CONTEXT].generate_coverage_object_file(object.source, object.name)
24
29
  end
@@ -29,7 +29,12 @@ class Gcov < Plugin
29
29
  end
30
30
 
31
31
  def generate_coverage_object_file(source, object)
32
- compile_command = @ceedling[:tool_executor].build_command_line(TOOLS_GCOV_COMPILER, source, object)
32
+ compile_command =
33
+ @ceedling[:tool_executor].build_command_line(
34
+ TOOLS_GCOV_COMPILER,
35
+ source,
36
+ object,
37
+ @ceedling[:file_path_utils].form_test_build_list_filepath( object ) )
33
38
  @ceedling[:streaminator].stdout_puts("Compiling #{File.basename(source)} with coverage...")
34
39
  @ceedling[:tool_executor].exec( compile_command[:line], compile_command[:options] )
35
40
  end
@@ -101,7 +106,7 @@ class Gcov < Plugin
101
106
 
102
107
  if (coverage_results.strip =~ /(File\s+'#{Regexp.escape(source)}'.+$)/m)
103
108
  report = ((($1.lines.to_a)[1..-1])).map{|line| basename + ' ' + line}.join('')
104
- @ceedling[:streaminator].stdout_puts (report + "\n\n")
109
+ @ceedling[:streaminator].stdout_puts(report + "\n\n")
105
110
  end
106
111
  end
107
112
  end
@@ -10,7 +10,7 @@ class XmlTestsReport < Plugin
10
10
  end
11
11
 
12
12
  def post_test_execute(arg_hash)
13
- return if not (arg_hash[:context] == TEST_TASKS_CONTEXT)
13
+ return if not (arg_hash[:context] == TEST_SYM)
14
14
 
15
15
  @results_list << arg_hash[:result_file]
16
16
  end
@@ -0,0 +1,308 @@
1
+ # ==========================================
2
+ # Unity Project - A Test Framework for C
3
+ # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
+ # [Released under MIT License. Please refer to license.txt for details]
5
+ # ==========================================
6
+
7
+ File.expand_path(File.join(File.dirname(__FILE__),'colour_prompt'))
8
+
9
+ class UnityTestRunnerGenerator
10
+
11
+ def initialize(options = nil)
12
+ @options = { :includes => [], :plugins => [], :framework => :unity }
13
+ case(options)
14
+ when NilClass then @options
15
+ when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
16
+ when Hash then @options.merge!(options)
17
+ else raise "If you specify arguments, it should be a filename or a hash of options"
18
+ end
19
+ end
20
+
21
+ def self.grab_config(config_file)
22
+ options = { :includes => [], :plugins => [], :framework => :unity }
23
+ unless (config_file.nil? or config_file.empty?)
24
+ require 'yaml'
25
+ yaml_guts = YAML.load_file(config_file)
26
+ options.merge!(yaml_guts[:unity] ? yaml_guts[:unity] : yaml_guts[:cmock])
27
+ raise "No :unity or :cmock section found in #{config_file}" unless options
28
+ end
29
+ return(options)
30
+ end
31
+
32
+ def run(input_file, output_file, options=nil)
33
+ tests = []
34
+ includes = []
35
+ used_mocks = []
36
+
37
+ @options.merge!(options) unless options.nil?
38
+ module_name = File.basename(input_file)
39
+
40
+ #pull required data from source file
41
+ File.open(input_file, 'r') do |input|
42
+ tests = find_tests(input)
43
+ includes = find_includes(input)
44
+ used_mocks = find_mocks(includes)
45
+ end
46
+
47
+ #build runner file
48
+ generate(input_file, output_file, tests, includes, used_mocks)
49
+
50
+ #determine which files were used to return them
51
+ all_files_used = [input_file, output_file]
52
+ all_files_used += includes.map {|filename| filename + '.c'} unless includes.empty?
53
+ all_files_used += @options[:includes] unless @options[:includes].empty?
54
+ return all_files_used.uniq
55
+ end
56
+
57
+ def generate(input_file, output_file, tests, includes, used_mocks)
58
+ File.open(output_file, 'w') do |output|
59
+ create_header(output, used_mocks)
60
+ create_externs(output, tests, used_mocks)
61
+ create_mock_management(output, used_mocks)
62
+ create_suite_setup_and_teardown(output)
63
+ create_reset(output, used_mocks)
64
+ create_main(output, input_file, tests)
65
+ end
66
+ end
67
+
68
+ def find_tests(input_file)
69
+ tests_raw = []
70
+ tests_args = []
71
+ tests_and_line_numbers = []
72
+
73
+ input_file.rewind
74
+ source_raw = input_file.read
75
+ source_scrubbed = source_raw.gsub(/\/\/.*$/, '') # remove line comments
76
+ source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
77
+ lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
78
+ | (;|\{|\}) /x) # Match ;, {, and } as end of lines
79
+
80
+ lines.each_with_index do |line, index|
81
+ #find tests
82
+ if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+(test.*?)\s*\(\s*(.*)\s*\)/
83
+ arguments = $1
84
+ name = $2
85
+ call = $3
86
+ args = nil
87
+ if (@options[:use_param_tests] and !arguments.empty?)
88
+ args = []
89
+ arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) {|a| args << a[0]}
90
+ end
91
+ tests_and_line_numbers << { :test => name, :args => args, :call => call, :line_number => 0 }
92
+ tests_args = []
93
+ end
94
+ end
95
+
96
+ #determine line numbers and create tests to run
97
+ source_lines = source_raw.split("\n")
98
+ source_index = 0;
99
+ tests_and_line_numbers.size.times do |i|
100
+ source_lines[source_index..-1].each_with_index do |line, index|
101
+ if (line =~ /#{tests_and_line_numbers[i][:test]}/)
102
+ source_index += index
103
+ tests_and_line_numbers[i][:line_number] = source_index + 1
104
+ break
105
+ end
106
+ end
107
+ end
108
+
109
+ return tests_and_line_numbers
110
+ end
111
+
112
+ def find_includes(input_file)
113
+ input_file.rewind
114
+ includes = []
115
+ input_file.readlines.each do |line|
116
+ scan_results = line.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/)
117
+ includes << scan_results[0][0] if (scan_results.size > 0)
118
+ end
119
+ return includes
120
+ end
121
+
122
+ def find_mocks(includes)
123
+ mock_headers = []
124
+ includes.each do |include_file|
125
+ mock_headers << File.basename(include_file) if (include_file =~ /^mock/i)
126
+ end
127
+ return mock_headers
128
+ end
129
+
130
+ def create_header(output, mocks)
131
+ output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
132
+ create_runtest(output, mocks)
133
+ output.puts("\n//=======Automagically Detected Files To Include=====")
134
+ output.puts("#include \"#{@options[:framework].to_s}.h\"")
135
+ output.puts('#include "cmock.h"') unless (mocks.empty?)
136
+ @options[:includes].flatten.uniq.compact.each do |inc|
137
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
138
+ end
139
+ output.puts('#include <setjmp.h>')
140
+ output.puts('#include <stdio.h>')
141
+ output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
142
+ mocks.each do |mock|
143
+ output.puts("#include \"#{mock.gsub('.h','')}.h\"")
144
+ end
145
+ if @options[:enforce_strict_ordering]
146
+ output.puts('')
147
+ output.puts('int GlobalExpectCount;')
148
+ output.puts('int GlobalVerifyOrder;')
149
+ output.puts('char* GlobalOrderError;')
150
+ end
151
+ end
152
+
153
+ def create_externs(output, tests, mocks)
154
+ output.puts("\n//=======External Functions This Runner Calls=====")
155
+ output.puts("extern void setUp(void);")
156
+ output.puts("extern void tearDown(void);")
157
+ tests.each do |test|
158
+ output.puts("extern void #{test[:test]}(#{test[:call]});")
159
+ end
160
+ output.puts('')
161
+ end
162
+
163
+ def create_mock_management(output, mocks)
164
+ unless (mocks.empty?)
165
+ output.puts("\n//=======Mock Management=====")
166
+ output.puts("static void CMock_Init(void)")
167
+ output.puts("{")
168
+ if @options[:enforce_strict_ordering]
169
+ output.puts(" GlobalExpectCount = 0;")
170
+ output.puts(" GlobalVerifyOrder = 0;")
171
+ output.puts(" GlobalOrderError = NULL;")
172
+ end
173
+ mocks.each do |mock|
174
+ output.puts(" #{mock}_Init();")
175
+ end
176
+ output.puts("}\n")
177
+
178
+ output.puts("static void CMock_Verify(void)")
179
+ output.puts("{")
180
+ mocks.each do |mock|
181
+ output.puts(" #{mock}_Verify();")
182
+ end
183
+ output.puts("}\n")
184
+
185
+ output.puts("static void CMock_Destroy(void)")
186
+ output.puts("{")
187
+ mocks.each do |mock|
188
+ output.puts(" #{mock}_Destroy();")
189
+ end
190
+ output.puts("}\n")
191
+ end
192
+ end
193
+
194
+ def create_suite_setup_and_teardown(output)
195
+ unless (@options[:suite_setup].nil?)
196
+ output.puts("\n//=======Suite Setup=====")
197
+ output.puts("static int suite_setup(void)")
198
+ output.puts("{")
199
+ output.puts(@options[:suite_setup])
200
+ output.puts("}")
201
+ end
202
+ unless (@options[:suite_teardown].nil?)
203
+ output.puts("\n//=======Suite Teardown=====")
204
+ output.puts("static int suite_teardown(int num_failures)")
205
+ output.puts("{")
206
+ output.puts(@options[:suite_teardown])
207
+ output.puts("}")
208
+ end
209
+ end
210
+
211
+ def create_runtest(output, used_mocks)
212
+ cexception = @options[:plugins].include? :cexception
213
+ va_args1 = @options[:use_param_tests] ? ', ...' : ''
214
+ va_args2 = @options[:use_param_tests] ? '__VA_ARGS__' : ''
215
+ output.puts("\n//=======Test Runner Used To Run Each Test Below=====")
216
+ output.puts("#define RUN_TEST_NO_ARGS") if @options[:use_param_tests]
217
+ output.puts("#define RUN_TEST(TestFunc, TestLineNum#{va_args1}) \\")
218
+ output.puts("{ \\")
219
+ output.puts(" Unity.CurrentTestName = #TestFunc#{va_args2.empty? ? '' : " \"(\" ##{va_args2} \")\""}; \\")
220
+ output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
221
+ output.puts(" Unity.NumberOfTests++; \\")
222
+ output.puts(" if (TEST_PROTECT()) \\")
223
+ output.puts(" { \\")
224
+ output.puts(" CEXCEPTION_T e; \\") if cexception
225
+ output.puts(" Try { \\") if cexception
226
+ output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
227
+ output.puts(" setUp(); \\")
228
+ output.puts(" TestFunc(#{va_args2}); \\")
229
+ output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
230
+ output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
231
+ output.puts(" } \\")
232
+ output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
233
+ output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
234
+ output.puts(" { \\")
235
+ output.puts(" tearDown(); \\")
236
+ output.puts(" } \\")
237
+ output.puts(" UnityConcludeTest(); \\")
238
+ output.puts("}\n")
239
+ end
240
+
241
+ def create_reset(output, used_mocks)
242
+ output.puts("\n//=======Test Reset Option=====")
243
+ output.puts("void resetTest()")
244
+ output.puts("{")
245
+ output.puts(" CMock_Verify();") unless (used_mocks.empty?)
246
+ output.puts(" CMock_Destroy();") unless (used_mocks.empty?)
247
+ output.puts(" tearDown();")
248
+ output.puts(" CMock_Init();") unless (used_mocks.empty?)
249
+ output.puts(" setUp();")
250
+ output.puts("}")
251
+ end
252
+
253
+ def create_main(output, filename, tests)
254
+ output.puts("\n\n//=======MAIN=====")
255
+ output.puts("int main(void)")
256
+ output.puts("{")
257
+ output.puts(" suite_setup();") unless @options[:suite_setup].nil?
258
+ output.puts(" Unity.TestFile = \"#{filename}\";")
259
+ output.puts(" UnityBegin();")
260
+ if (@options[:use_param_tests])
261
+ tests.each do |test|
262
+ if ((test[:args].nil?) or (test[:args].empty?))
263
+ output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, RUN_TEST_NO_ARGS);")
264
+ else
265
+ test[:args].each {|args| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, #{args});")}
266
+ end
267
+ end
268
+ else
269
+ tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") }
270
+ end
271
+ output.puts()
272
+ output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());")
273
+ output.puts("}")
274
+ end
275
+ end
276
+
277
+
278
+ if ($0 == __FILE__)
279
+ options = { :includes => [] }
280
+ yaml_file = nil
281
+
282
+ #parse out all the options first
283
+ ARGV.reject! do |arg|
284
+ case(arg)
285
+ when '-cexception'
286
+ options[:plugins] = [:cexception]; true
287
+ when /\.*\.yml/
288
+ options = UnityTestRunnerGenerator.grab_config(arg); true
289
+ else false
290
+ end
291
+ end
292
+
293
+ #make sure there is at least one parameter left (the input file)
294
+ if !ARGV[0]
295
+ puts ["usage: ruby #{__FILE__} (yaml) (options) input_test_file output_test_runner (includes)",
296
+ " blah.yml - will use config options in the yml file (see docs)",
297
+ " -cexception - include cexception support"].join("\n")
298
+ exit 1
299
+ end
300
+
301
+ #create the default test runner name if not specified
302
+ ARGV[1] = ARGV[0].gsub(".c","_Runner.c") if (!ARGV[1])
303
+
304
+ #everything else is an include file
305
+ options[:includes] ||= (ARGV.slice(2..-1).flatten.compact) if (ARGV.size > 2)
306
+
307
+ UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1])
308
+ end
@@ -296,24 +296,23 @@ void UnityAssertEqualFloatArray(const _UF* expected,
296
296
  #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)line, message)
297
297
 
298
298
  #define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
299
- #define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
300
- #define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
301
- #define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
299
+ #define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
300
+ #define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
301
+ #define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
302
302
  #define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
303
- #define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
304
- #define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
305
- #define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
306
- #define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
307
- #define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
308
- #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
303
+ #define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
304
+ #define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
305
+ #define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
306
+ #define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
307
+ #define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
308
+ #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
309
309
  #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((_U_SINT)(mask), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line)
310
310
 
311
311
  #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
312
312
  #define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
313
- #define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
314
- #define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
315
- #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
316
- #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
313
+ #define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
314
+ #define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
315
+ #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
317
316
 
318
317
  #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UP)(expected), (_U_SINT)(_UP)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER)
319
318
  #define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line)
@@ -340,6 +339,7 @@ void UnityAssertEqualFloatArray(const _UF* expected,
340
339
  #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _U_SINT*)(expected), (const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
341
340
  #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _U_SINT*)(expected), (const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
342
341
  #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((const _U_SINT*)(expected), (const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
342
+ #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
343
343
  #endif
344
344
 
345
345
  #ifdef UNITY_EXCLUDE_FLOAT
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ceedling
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Karlesky, Mark VanderVoord
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-04-06 00:00:00 -04:00
20
+ date: 2011-04-21 00:00:00 -04:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -186,6 +186,7 @@ files:
186
186
  - new_project_template/vendor/ceedling/lib/file_system_utils.rb
187
187
  - new_project_template/vendor/ceedling/lib/file_wrapper.rb
188
188
  - new_project_template/vendor/ceedling/lib/generator.rb
189
+ - new_project_template/vendor/ceedling/lib/generator_helper.rb
189
190
  - new_project_template/vendor/ceedling/lib/generator_test_results.rb
190
191
  - new_project_template/vendor/ceedling/lib/generator_test_results_sanity_checker.rb
191
192
  - new_project_template/vendor/ceedling/lib/generator_test_runner.rb
@@ -238,10 +239,12 @@ files:
238
239
  - new_project_template/vendor/ceedling/plugins/bullseye/bullseye.rake
239
240
  - new_project_template/vendor/ceedling/plugins/bullseye/bullseye.rb
240
241
  - new_project_template/vendor/ceedling/plugins/bullseye/defaults.yml
242
+ - new_project_template/vendor/ceedling/plugins/bullseye/readme.txt
241
243
  - new_project_template/vendor/ceedling/plugins/bullseye/template.erb
242
244
  - new_project_template/vendor/ceedling/plugins/gcov/defaults.yml
243
245
  - new_project_template/vendor/ceedling/plugins/gcov/gcov.rake
244
246
  - new_project_template/vendor/ceedling/plugins/gcov/gcov.rb
247
+ - new_project_template/vendor/ceedling/plugins/gcov/readme.txt
245
248
  - new_project_template/vendor/ceedling/plugins/gcov/template.erb
246
249
  - new_project_template/vendor/ceedling/plugins/stdout_ide_tests_report/stdout_ide_tests_report.rb
247
250
  - new_project_template/vendor/ceedling/plugins/stdout_ide_tests_report/stdout_ide_tests_report.yml
@@ -280,6 +283,7 @@ files:
280
283
  - new_project_template/vendor/ceedling/vendor/deep_merge/lib/deep_merge.rb
281
284
  - new_project_template/vendor/ceedling/vendor/diy/lib/diy.rb
282
285
  - new_project_template/vendor/ceedling/vendor/diy/lib/diy/factory.rb
286
+ - new_project_template/vendor/ceedling/vendor/unity/auto/generate_test_runner.rb
283
287
  - new_project_template/vendor/ceedling/vendor/unity/release/build.info
284
288
  - new_project_template/vendor/ceedling/vendor/unity/release/version.info
285
289
  - new_project_template/vendor/ceedling/vendor/unity/src/unity.c
@@ -315,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
319
  requirements: []
316
320
 
317
321
  rubyforge_project: ceedling
318
- rubygems_version: 1.4.2
322
+ rubygems_version: 1.6.2
319
323
  signing_key:
320
324
  specification_version: 3
321
325
  summary: Gemified version of the Ceedling C testing / build environment