From 80601ce66ad001479442985d2b204dfa35fc4e7c Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Fri, 18 Oct 2024 21:07:08 -0400 Subject: [PATCH] refactor gcov to run using new flow (and tweak flow to support it) --- lib/ceedling/build_batchinator.rb | 7 ++++--- lib/ceedling/generator.rb | 5 +++-- lib/ceedling/loginator.rb | 4 ++++ lib/ceedling/plugin_manager.rb | 2 +- lib/ceedling/test_invoker.rb | 10 +++++----- plugins/gcov/lib/gcov.rb | 23 ++++++++++++++--------- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/ceedling/build_batchinator.rb b/lib/ceedling/build_batchinator.rb index a5729ff7..27d61661 100644 --- a/lib/ceedling/build_batchinator.rb +++ b/lib/ceedling/build_batchinator.rb @@ -61,7 +61,8 @@ def exec(workload:, things:, &block) yield @queue.pop(true) end end - # First, handle thread exceptions (should always be due to empty queue) + + # First, handle thread exceptions (should always be due to empty queue) rescue ThreadError => e # Typical case: do nothing and allow thread to wind down @@ -70,7 +71,7 @@ def exec(workload:, things:, &block) @loginator.log(e.message, Verbosity::ERRORS) # Shutdown all worker threads - shutdown_threads(threads) #TODO IT SEEMS LIKE threads MIGHT NOT BE VALID YET + shutdown_threads(threads) raise(e) # Raise exception again end @@ -84,7 +85,7 @@ def exec(workload:, things:, &block) @loginator.log(e.message, Verbosity::ERRORS) # Shutdown all worker threads - shutdown_threads(threads) #TODO IT SEEMS LIKE threads MIGHT NOT BE VALID YET + shutdown_threads(threads) raise(e) # Raise exception again after intervening end diff --git a/lib/ceedling/generator.rb b/lib/ceedling/generator.rb index 6bfcecf3..a51e3e55 100644 --- a/lib/ceedling/generator.rb +++ b/lib/ceedling/generator.rb @@ -139,12 +139,13 @@ def generate_object_file_c( :flags => flags, :defines => defines, :list => list, - :dependencies => dependencies + :dependencies => dependencies, + :msg => String(msg) } @plugin_manager.pre_compile_execute(arg_hash) - msg = String(msg) + msg = arg_hash[:msg] msg = @reportinator.generate_module_progress( operation: "Compiling", module_name: module_name, diff --git a/lib/ceedling/loginator.rb b/lib/ceedling/loginator.rb index 18726acb..5b635d32 100644 --- a/lib/ceedling/loginator.rb +++ b/lib/ceedling/loginator.rb @@ -309,3 +309,7 @@ def logfile(string, stream='') end end + +END { + @ceedling[:loginator].wrapup +} \ No newline at end of file diff --git a/lib/ceedling/plugin_manager.rb b/lib/ceedling/plugin_manager.rb index 85a402c9..afba6409 100644 --- a/lib/ceedling/plugin_manager.rb +++ b/lib/ceedling/plugin_manager.rb @@ -39,7 +39,7 @@ def load_programmatic_plugins(plugins, system_objects) # Add plugins to hash of all system objects system_objects[hash[:plugin].downcase().to_sym()] = object - rescue + rescue @loginator.log( "Exception raised while trying to load plugin: #{hash[:plugin]}", Verbosity::ERRORS ) raise # Raise again for backtrace, etc. end diff --git a/lib/ceedling/test_invoker.rb b/lib/ceedling/test_invoker.rb index 5cd28503..e3be7dea 100644 --- a/lib/ceedling/test_invoker.rb +++ b/lib/ceedling/test_invoker.rb @@ -238,7 +238,7 @@ def setup_and_invoke(tests:, context:TEST_SYM, options:{}) testable = mock[:testable] arg_hash = { - context: TEST_SYM, + context: context, mock: mock[:name], test: testable[:name], input_filepath: details[:input], @@ -287,7 +287,7 @@ def setup_and_invoke(tests:, context:TEST_SYM, options:{}) @batchinator.build_step("Test Runners") do @batchinator.exec(workload: :compile, things: @testables) do |_, details| arg_hash = { - context: TEST_SYM, + context: context, mock_list: details[:mock_list], includes_list: @test_context_extractor.lookup_header_includes_list( details[:filepath] ), test_filepath: details[:filepath], @@ -349,7 +349,7 @@ def setup_and_invoke(tests:, context:TEST_SYM, options:{}) details[:no_link_objects] = test_no_link_objects details[:results_pass] = test_pass details[:results_fail] = test_fail - details[:tool] = TOOLS_TEST_COMPILER #TODO: VERIFY THIS GETS REPLACED WHEN IN GCOV OR BULLSEYE MODE + details[:tool] = TOOLS_TEST_COMPILER end end end @@ -358,8 +358,8 @@ def setup_and_invoke(tests:, context:TEST_SYM, options:{}) @batchinator.build_step("Building Objects") do @testables.each do |_, details| details[:objects].each do |obj| - src = @file_finder.find_build_input_file(filepath: obj, context: TEST_SYM) - compile_test_component(tool: details[:tool], context: TEST_SYM, test: details[:name], source: src, object: obj, msg: details[:msg]) + src = @file_finder.find_build_input_file(filepath: obj, context: context) + compile_test_component(tool: details[:tool], context: context, test: details[:name], source: src, object: obj, msg: details[:msg]) end end end diff --git a/plugins/gcov/lib/gcov.rb b/plugins/gcov/lib/gcov.rb index ff9607e2..55de600a 100755 --- a/plugins/gcov/lib/gcov.rb +++ b/plugins/gcov/lib/gcov.rb @@ -61,15 +61,20 @@ def automatic_reporting_enabled? end def pre_compile_execute(arg_hash) - source = arg_hash[:source] - - # Handle assembly file that comes through - if File.extname(source) == EXTENSION_ASSEMBLY - arg_hash[:tool] = TOOLS_TEST_ASSEMBLER - # If a source file (not unity, mocks, etc.) is to be compiled use code coverage compiler - elsif @configurator.collection_all_source.include?(source) - arg_hash[:tool] = TOOLS_GCOV_COMPILER - arg_hash[:msg] = "Compiling #{File.basename(source)} with coverage..." + if arg_hash[:context] == GCOV_SYM + source = arg_hash[:source] + + # If a source file (not unity, mocks, etc.) is to be compiled use code coverage compiler + if (File.extname(source) != EXTENSION_ASSEMBLY) && @configurator.collection_all_source.include?(source) + arg_hash[:tool] = TOOLS_GCOV_COMPILER + arg_hash[:msg] = "Compiling #{File.basename(source)} with coverage..." + end + end + end + + def pre_link_execute(arg_hash) + if arg_hash[:context] == GCOV_SYM + arg_hash[:tool] = TOOLS_GCOV_LINKER end end