Class: Generator
Instance Method Summary collapse
- #generate_executable_file(tool, context, objects, flags, executable, map = '', libraries = [], libpaths = []) ⇒ Object
- #generate_mock(context:, mock:, test:, input_filepath:, output_path:) ⇒ Object
- #generate_object_file_asm(tool:, module_name:, context:, source:, object:, search_paths: [], flags: [], defines: [], list: '', dependencies: '', msg: nil) ⇒ Object
- #generate_object_file_c(tool:, module_name:, context:, source:, object:, search_paths: [], flags: [], defines: [], list: '', dependencies: '', msg: nil) ⇒ Object
- #generate_test_results(tool:, context:, test_name:, test_filepath:, executable:, result:) ⇒ Object
- #generate_test_runner(context:, mock_list:, includes_list:, test_filepath:, input_filepath:, runner_filepath:) ⇒ Object
- #setup ⇒ Object
Instance Method Details
#generate_executable_file(tool, context, objects, flags, executable, map = '', libraries = [], libpaths = []) ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/ceedling/generator.rb', line 243 def generate_executable_file(tool, context, objects, flags, executable, map='', libraries=[], libpaths=[]) shell_result = {} arg_hash = { :tool => tool, :context => context, :objects => objects, :flags => flags, :executable => executable, :map => map, :libraries => libraries, :libpaths => libpaths } @plugin_manager.pre_link_execute(arg_hash) msg = @reportinator.generate_progress("Linking #{File.basename(arg_hash[:executable])}") @loginator.log( msg ) command = @tool_executor.build_command_line( arg_hash[:tool], arg_hash[:flags], arg_hash[:objects], arg_hash[:executable], arg_hash[:map], arg_hash[:libraries], arg_hash[:libpaths] ) begin shell_result = @tool_executor.exec( command ) rescue ShellException => ex shell_result = ex.shell_result raise ex ensure arg_hash[:shell_command] = command[:line] arg_hash[:shell_result] = shell_result @plugin_manager.post_link_execute(arg_hash) end end |
#generate_mock(context:, mock:, test:, input_filepath:, output_path:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ceedling/generator.rb', line 38 def generate_mock(context:, mock:, test:, input_filepath:, output_path:) arg_hash = { :header_file => input_filepath, :test => test, :context => context, :output_path => output_path } @plugin_manager.pre_mock_generate( arg_hash ) begin # Below is a workaround that instantiates CMock anew: # 1. To allow dfferent output path per mock # 2. To avoid any thread safety complications # TODO: # - Add option to CMock to generate mock to any destination path # - Make CMock thread-safe # Get default config created by Ceedling and customize it config = @generator_mocks.build_configuration( output_path ) # Generate mock msg = @reportinator.generate_module_progress( operation: "Generating mock for", module_name: test, filename: File.basename(input_filepath) ) @loginator.log( msg ) cmock = @generator_mocks.manufacture( config ) cmock.setup_mocks( arg_hash[:header_file] ) rescue StandardError => ex # Re-raise execption but decorate it with CMock to better identify it raise( ex, "CMock >> #{ex.}", ex.backtrace ) ensure @plugin_manager.post_mock_generate( arg_hash ) end end |
#generate_object_file_asm(tool:, module_name:, context:, source:, object:, search_paths: [], flags: [], defines: [], list: '', dependencies: '', msg: nil) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/ceedling/generator.rb', line 180 def generate_object_file_asm( tool:, module_name:, context:, source:, object:, search_paths:[], flags:[], defines:[], list:'', dependencies:'', msg:nil ) shell_result = {} arg_hash = { :tool => tool, :module_name => module_name, :operation => OPERATION_ASSEMBLE_SYM, :context => context, :source => source, :object => object, :search_paths => search_paths, :flags => flags, :defines => defines, :list => list, :dependencies => dependencies } @plugin_manager.pre_compile_execute(arg_hash) msg = String(msg) msg = @reportinator.generate_module_progress( operation: "Assembling", module_name: module_name, filename: File.basename(arg_hash[:source]) ) if msg.empty? @loginator.log( msg ) command = @tool_executor.build_command_line( arg_hash[:tool], arg_hash[:flags], arg_hash[:source], arg_hash[:object], arg_hash[:search_paths], arg_hash[:defines], arg_hash[:list], arg_hash[:dependencies] ) begin shell_result = @tool_executor.exec( command ) rescue ShellException => ex shell_result = ex.shell_result raise ex ensure arg_hash[:shell_command] = command[:line] arg_hash[:shell_result] = shell_result @plugin_manager.post_compile_execute(arg_hash) end end |
#generate_object_file_c(tool:, module_name:, context:, source:, object:, search_paths: [], flags: [], defines: [], list: '', dependencies: '', msg: nil) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/ceedling/generator.rb', line 117 def generate_object_file_c( tool:, module_name:, context:, source:, object:, search_paths:[], flags:[], defines:[], list:'', dependencies:'', msg:nil ) shell_result = {} arg_hash = { :tool => tool, :module_name => module_name, :operation => OPERATION_COMPILE_SYM, :context => context, :source => source, :object => object, :search_paths => search_paths, :flags => flags, :defines => defines, :list => list, :dependencies => dependencies, :msg => String(msg) } @plugin_manager.pre_compile_execute(arg_hash) msg = arg_hash[:msg] msg = @reportinator.generate_module_progress( operation: "Compiling", module_name: module_name, filename: File.basename(arg_hash[:source]) ) if msg.empty? @loginator.log( msg ) command = @tool_executor.build_command_line( arg_hash[:tool], arg_hash[:flags], arg_hash[:source], arg_hash[:object], arg_hash[:list], arg_hash[:dependencies], arg_hash[:search_paths], arg_hash[:defines] ) begin shell_result = @tool_executor.exec( command ) rescue ShellException => ex shell_result = ex.shell_result raise ex ensure arg_hash[:shell_command] = command[:line] arg_hash[:shell_result] = shell_result @plugin_manager.post_compile_execute(arg_hash) end end |
#generate_test_results(tool:, context:, test_name:, test_filepath:, executable:, result:) ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/ceedling/generator.rb', line 283 def generate_test_results(tool:, context:, test_name:, test_filepath:, executable:, result:) arg_hash = { :tool => tool, :context => context, :test_name => test_name, :test_filepath => test_filepath, :executable => executable, :result_file => result } @plugin_manager.pre_test_fixture_execute( arg_hash ) msg = @reportinator.generate_progress( "Running #{File.basename(arg_hash[:executable])}" ) @loginator.log( msg ) # Unity's exit code is equivalent to the number of failed tests. # We tell @tool_executor not to fail out if there are failures # so that we can run all tests and collect all results. command = @tool_executor.build_command_line( arg_hash[:tool], # Apply additional test case filters @test_runner_manager.collect_cmdline_args(), arg_hash[:executable] ) # Run the test executable itself # We allow it to fail without an exception. # We'll analyze its results apart from tool_executor command[:options][:boom] = false shell_result = @tool_executor.exec( command ) filename = File.basename( test_filepath ) # Handle crashes if @helper.test_crash?( filename, executable, shell_result ) @helper.log_test_results_crash( executable, shell_result, @configurator.project_config_hash[:project_use_backtrace] ) # Lookup test cases and filter based on any matchers specified for the build task test_cases = @test_context_extractor.lookup_test_cases( test_filepath ) test_cases = @generator_test_results.filter_test_cases( test_cases ) case @configurator.project_config_hash[:project_use_backtrace] # If we have the options and tools to learn more, dig into the details when :gdb shell_result = @backtrace.do_gdb( filename, executable, shell_result, test_cases ) # Simple test-case-by-test-case exercise when :simple shell_result = @backtrace.do_simple( filename, executable, shell_result, test_cases ) else # :none # Otherwise, call a crash a single failure so it shows up in the report shell_result = @generator_test_results.create_crash_failure( filename, shell_result, test_cases ) end end processed = @generator_test_results.process_and_write_results( executable, shell_result, arg_hash[:result_file], @file_finder.find_test_file_from_filepath( arg_hash[:executable] ) ) arg_hash[:result_file] = processed[:result_file] arg_hash[:results] = processed[:results] # For raw output display if no plugins enabled for nice display arg_hash[:shell_result] = shell_result @plugin_manager.post_test_fixture_execute( arg_hash ) end |
#generate_test_runner(context:, mock_list:, includes_list:, test_filepath:, input_filepath:, runner_filepath:) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ceedling/generator.rb', line 77 def generate_test_runner(context:, mock_list:, includes_list:, test_filepath:, input_filepath:, runner_filepath:) arg_hash = { :context => context, :test_file => test_filepath, :input_file => input_filepath, :runner_file => runner_filepath} @plugin_manager.pre_runner_generate( arg_hash ) # Collect info we need module_name = File.basename( arg_hash[:test_file] ) msg = @reportinator.generate_progress("Generating runner for #{module_name}") @loginator.log( msg ) unity_test_runner_generator = @test_context_extractor.lookup_test_runner_generator( test_filepath ) if unity_test_runner_generator.nil? msg = "Could not find test runner generator for #{test_filepath}" raise CeedlingException.new( msg ) end # Build runner file begin unity_test_runner_generator.generate( module_name: module_name, runner_filepath: runner_filepath, mock_list: mock_list, test_file_includes: includes_list, header_extension: @configurator.extension_header ) rescue StandardError => ex # Re-raise execption but decorate it to better identify it in Ceedling output raise( ex, "Unity Runner Generator >> #{ex.}", ex.backtrace ) ensure @plugin_manager.post_runner_generate(arg_hash) end end |
#setup ⇒ Object
32 33 34 35 36 |
# File 'lib/ceedling/generator.rb', line 32 def setup() # Aliases @helper = @generator_helper @backtrace = @generator_test_results_backtrace end |