- add ceedling/cmock/unity as testing framework and support
- unified makefile project for the whole repos - new separate project for tests
This commit is contained in:
		
							
								
								
									
										15
									
								
								tests/vendor/ceedling/plugins/bullseye/assets/template.erb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/vendor/ceedling/plugins/bullseye/assets/template.erb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| % function_string = hash[:coverage][:functions].to_s | ||||
| % branch_string   = hash[:coverage][:branches].to_s | ||||
| % format_string   = "%#{[function_string.length, branch_string.length].max}i" | ||||
| <%=@ceedling[:plugin_reportinator].generate_banner("#{hash[:header]}: CODE COVERAGE SUMMARY")%> | ||||
| % if (!hash[:coverage][:functions].nil?) | ||||
| FUNCTIONS: <%=sprintf(format_string, hash[:coverage][:functions])%>% | ||||
| % else | ||||
| FUNCTIONS: none | ||||
| % end | ||||
| % if (!hash[:coverage][:branches].nil?) | ||||
| BRANCHES:  <%=sprintf(format_string, hash[:coverage][:branches])%>% | ||||
| % else | ||||
| BRANCHES:  none | ||||
| % end | ||||
|  | ||||
							
								
								
									
										162
									
								
								tests/vendor/ceedling/plugins/bullseye/bullseye.rake
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								tests/vendor/ceedling/plugins/bullseye/bullseye.rake
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,162 @@ | ||||
|  | ||||
| directory(BULLSEYE_BUILD_OUTPUT_PATH) | ||||
| directory(BULLSEYE_RESULTS_PATH) | ||||
| directory(BULLSEYE_ARTIFACTS_PATH) | ||||
| directory(BULLSEYE_DEPENDENCIES_PATH) | ||||
|  | ||||
| CLEAN.include(File.join(BULLSEYE_BUILD_OUTPUT_PATH, '*')) | ||||
| CLEAN.include(File.join(BULLSEYE_RESULTS_PATH, '*')) | ||||
| CLEAN.include(File.join(BULLSEYE_DEPENDENCIES_PATH, '*')) | ||||
|  | ||||
| CLOBBER.include(File.join(BULLSEYE_BUILD_PATH, '**/*')) | ||||
|  | ||||
|  | ||||
| rule(/#{BULLSEYE_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ => [ | ||||
|     proc do |task_name| | ||||
|       @ceedling[:file_finder].find_compilation_input_file(task_name) | ||||
|     end | ||||
|   ]) do |object| | ||||
|  | ||||
|   if (File.basename(object.source) =~ /^(#{PROJECT_TEST_FILE_PREFIX}|#{CMOCK_MOCK_PREFIX}|#{BULLSEYE_IGNORE_SOURCES.join('|')})/i) | ||||
|     @ceedling[:generator].generate_object_file( | ||||
|       TOOLS_BULLSEYE_COMPILER, | ||||
|       BULLSEYE_SYM, | ||||
|       object.source, | ||||
|       object.name, | ||||
|       @ceedling[:file_path_utils].form_test_build_list_filepath( object.name ) ) | ||||
|   else | ||||
|     @ceedling[BULLSEYE_SYM].generate_coverage_object_file(object.source, object.name) | ||||
|   end | ||||
|  | ||||
| end | ||||
|  | ||||
| rule(/#{BULLSEYE_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_EXECUTABLE}$/) do |bin_file| | ||||
|   @ceedling[:generator].generate_executable_file( | ||||
|     TOOLS_BULLSEYE_LINKER, | ||||
|     BULLSEYE_SYM, | ||||
|     bin_file.prerequisites, | ||||
|     bin_file.name, | ||||
|     @ceedling[:file_path_utils].form_test_build_map_filepath(bin_file.name)) | ||||
| end | ||||
|  | ||||
| rule(/#{BULLSEYE_RESULTS_PATH}\/#{'.+\\'+EXTENSION_TESTPASS}$/ => [ | ||||
|      proc do |task_name| | ||||
|        @ceedling[:file_path_utils].form_test_executable_filepath(task_name) | ||||
|      end | ||||
|   ]) do |test_result| | ||||
|   @ceedling[:generator].generate_test_results(TOOLS_BULLSEYE_FIXTURE, BULLSEYE_SYM, test_result.source, test_result.name) | ||||
| end | ||||
|  | ||||
| rule(/#{BULLSEYE_DEPENDENCIES_PATH}\/#{'.+\\'+EXTENSION_DEPENDENCIES}$/ => [ | ||||
|     proc do |task_name| | ||||
|       @ceedling[:file_finder].find_compilation_input_file(task_name) | ||||
|     end | ||||
|   ]) do |dep| | ||||
|   @ceedling[:generator].generate_dependencies_file( | ||||
|     TOOLS_TEST_DEPENDENCIES_GENERATOR, | ||||
|     BULLSEYE_SYM, | ||||
|     dep.source, | ||||
|     File.join(BULLSEYE_BUILD_OUTPUT_PATH, File.basename(dep.source).ext(EXTENSION_OBJECT) ), | ||||
|     dep.name) | ||||
| end | ||||
|  | ||||
| task :directories => [BULLSEYE_BUILD_OUTPUT_PATH, BULLSEYE_RESULTS_PATH, BULLSEYE_DEPENDENCIES_PATH, BULLSEYE_ARTIFACTS_PATH] | ||||
|  | ||||
| namespace BULLSEYE_SYM do | ||||
|  | ||||
|   task :source_coverage => COLLECTION_ALL_SOURCE.pathmap("#{BULLSEYE_BUILD_OUTPUT_PATH}/%n#{@ceedling[:configurator].extension_object}") | ||||
|  | ||||
|   desc "Run code coverage for all tests" | ||||
|   task :all => [:directories] do | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[BULLSEYE_SYM].config) | ||||
|     @ceedling[:test_invoker].setup_and_invoke(COLLECTION_ALL_TESTS, BULLSEYE_SYM) | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
|  | ||||
|   desc "Run single test w/ coverage ([*] real test or source file name, no path)." | ||||
|   task :* do | ||||
|     message = "\nOops! '#{BULLSEYE_ROOT_NAME}:*' isn't a real task. " + | ||||
|               "Use a real test or source file name (no path) in place of the wildcard.\n" + | ||||
|               "Example: rake #{BULLSEYE_ROOT_NAME}:foo.c\n\n" | ||||
|    | ||||
|     @ceedling[:streaminator].stdout_puts( message ) | ||||
|   end | ||||
|    | ||||
|   desc "Run tests by matching regular expression pattern." | ||||
|   task :pattern, [:regex] => [:directories] do |t, args| | ||||
|     matches = [] | ||||
|      | ||||
|     COLLECTION_ALL_TESTS.each do |test| | ||||
|       matches << test if test =~ /#{args.regex}/ | ||||
|     end | ||||
|    | ||||
|     if (matches.size > 0) | ||||
|       @ceedling[:configurator].replace_flattened_config(@ceedling[BULLSEYE_SYM].config) | ||||
|       @ceedling[:test_invoker].setup_and_invoke(matches, BULLSEYE_SYM, {:force_run => false}) | ||||
|       @ceedling[:configurator].restore_config | ||||
|     else | ||||
|       @ceedling[:streaminator].stdout_puts("\nFound no tests matching pattern /#{args.regex}/.") | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   desc "Run tests whose test path contains [dir] or [dir] substring." | ||||
|   task :path, [:dir] => [:directories] do |t, args| | ||||
|     matches = [] | ||||
|      | ||||
|     COLLECTION_ALL_TESTS.each do |test| | ||||
|       matches << test if File.dirname(test).include?(args.dir.gsub(/\\/, '/')) | ||||
|     end | ||||
|    | ||||
|     if (matches.size > 0) | ||||
|       @ceedling[:configurator].replace_flattened_config(@ceedling[BULLSEYE_SYM].config) | ||||
|       @ceedling[:test_invoker].setup_and_invoke(matches, BULLSEYE_SYM, {:force_run => false}) | ||||
|       @ceedling[:configurator].restore_config | ||||
|     else | ||||
|       @ceedling[:streaminator].stdout_puts("\nFound no tests including the given path or path component.") | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   desc "Run code coverage for changed files" | ||||
|   task :delta => [:directories] do | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[BULLSEYE_SYM].config) | ||||
|     @ceedling[:test_invoker].setup_and_invoke(COLLECTION_ALL_TESTS, BULLSEYE_SYM, {:force_run => false}) | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
|    | ||||
|   # use a rule to increase efficiency for large projects | ||||
|   # bullseye test tasks by regex | ||||
|   rule(/^#{BULLSEYE_TASK_ROOT}\S+$/ => [ | ||||
|       proc do |task_name| | ||||
|         test = task_name.sub(/#{BULLSEYE_TASK_ROOT}/, '') | ||||
|         test = "#{PROJECT_TEST_FILE_PREFIX}#{test}" if not (test.start_with?(PROJECT_TEST_FILE_PREFIX)) | ||||
|         @ceedling[:file_finder].find_test_from_file_path(test) | ||||
|       end | ||||
|   ]) do |test| | ||||
|     @ceedling[:rake_wrapper][:directories].invoke | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[BULLSEYE_SYM].config) | ||||
|     @ceedling[:test_invoker].setup_and_invoke([test.source], BULLSEYE_SYM) | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
|  | ||||
| end | ||||
|  | ||||
| if PROJECT_USE_DEEP_DEPENDENCIES | ||||
| namespace REFRESH_SYM do | ||||
|   task BULLSEYE_SYM do | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[BULLSEYE_SYM].config) | ||||
|     @ceedling[:test_invoker].refresh_deep_dependencies | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
| end | ||||
| end | ||||
|  | ||||
| namespace UTILS_SYM do | ||||
|    | ||||
|   desc "Open Bullseye code coverage browser" | ||||
|   task BULLSEYE_SYM do | ||||
|     command = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_BROWSER) | ||||
|     @ceedling[:tool_executor].exec(command[:line], command[:options]) | ||||
|   end | ||||
|    | ||||
| end | ||||
|  | ||||
							
								
								
									
										53
									
								
								tests/vendor/ceedling/plugins/bullseye/config/defaults.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								tests/vendor/ceedling/plugins/bullseye/config/defaults.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| --- | ||||
|  | ||||
| :paths: | ||||
|   :bullseye_toolchain_include: [] | ||||
|  | ||||
| :tools: | ||||
|   :bullseye_instrumentation: | ||||
|     :executable: covc | ||||
|     :arguments: | ||||
|       - '--file $': ENVIRONMENT_COVFILE | ||||
|       - -q | ||||
|       - ${1} | ||||
|   :bullseye_compiler: | ||||
|     :executable: gcc | ||||
|     :arguments: | ||||
|       - -g | ||||
|       - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR | ||||
|       - -I"$": COLLECTION_PATHS_BULLSEYE_TOOLCHAIN_INCLUDE | ||||
|       - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR | ||||
|       - -DBULLSEYE_COMPILER | ||||
|       - -c "${1}" | ||||
|       - -o "${2}" | ||||
|   :bullseye_linker: | ||||
|     :executable: gcc | ||||
|     :arguments: | ||||
|       - ${1} | ||||
|       - -o ${2} | ||||
|       - -L$: PLUGINS_BULLSEYE_LIB_PATH | ||||
|       - -lcov | ||||
|   :bullseye_fixture: | ||||
|     :executable: ${1} | ||||
|   :bullseye_report_covsrc: | ||||
|     :executable: covsrc | ||||
|     :arguments: | ||||
|       - '--file $': ENVIRONMENT_COVFILE | ||||
|       - -q | ||||
|       - -w140 | ||||
|   :bullseye_report_covfn: | ||||
|     :executable: covfn | ||||
|     :stderr_redirect: :auto | ||||
|     :arguments: | ||||
|       - '--file $': ENVIRONMENT_COVFILE | ||||
|       - --width 120 | ||||
|       - --no-source | ||||
|       - '"${1}"' | ||||
|   :bullseye_browser: | ||||
|     :executable: CoverageBrowser | ||||
|     :background_exec: :auto | ||||
|     :optional: TRUE | ||||
|     :arguments: | ||||
|       - '"$"': ENVIRONMENT_COVFILE | ||||
|  | ||||
| ... | ||||
							
								
								
									
										172
									
								
								tests/vendor/ceedling/plugins/bullseye/lib/bullseye.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								tests/vendor/ceedling/plugins/bullseye/lib/bullseye.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,172 @@ | ||||
| require 'plugin' | ||||
| require 'constants' | ||||
|  | ||||
| BULLSEYE_ROOT_NAME         = 'bullseye' | ||||
| BULLSEYE_TASK_ROOT         = BULLSEYE_ROOT_NAME + ':' | ||||
| BULLSEYE_SYM               = BULLSEYE_ROOT_NAME.to_sym | ||||
|  | ||||
| BULLSEYE_BUILD_PATH        = "#{PROJECT_BUILD_ROOT}/#{BULLSEYE_ROOT_NAME}" | ||||
| BULLSEYE_BUILD_OUTPUT_PATH = "#{BULLSEYE_BUILD_PATH}/out" | ||||
| BULLSEYE_RESULTS_PATH      = "#{BULLSEYE_BUILD_PATH}/results" | ||||
| BULLSEYE_DEPENDENCIES_PATH = "#{BULLSEYE_BUILD_PATH}/dependencies" | ||||
| BULLSEYE_ARTIFACTS_PATH    = "#{PROJECT_BUILD_ARTIFACTS_ROOT}/#{BULLSEYE_ROOT_NAME}" | ||||
|  | ||||
| BULLSEYE_IGNORE_SOURCES    = ['unity', 'cmock', 'cexception'] | ||||
|  | ||||
|  | ||||
| class Bullseye < Plugin | ||||
|  | ||||
|   def setup | ||||
|     @result_list = [] | ||||
|     @environment = [ {:covfile => File.join( BULLSEYE_ARTIFACTS_PATH, 'test.cov' )} ] | ||||
|     @plugin_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||||
|     @coverage_template_all = @ceedling[:file_wrapper].read(File.join(@plugin_root, 'assets/template.erb')) | ||||
|   end | ||||
|  | ||||
|   def config | ||||
|     { | ||||
|       :project_test_build_output_path     => BULLSEYE_BUILD_OUTPUT_PATH, | ||||
|       :project_test_results_path          => BULLSEYE_RESULTS_PATH, | ||||
|       :project_test_dependencies_path     => BULLSEYE_DEPENDENCIES_PATH, | ||||
|       :defines_test                       => DEFINES_TEST + ['CODE_COVERAGE'], | ||||
|       :collection_defines_test_and_vendor => COLLECTION_DEFINES_TEST_AND_VENDOR + ['CODE_COVERAGE'] | ||||
|     } | ||||
|   end | ||||
|  | ||||
|   def generate_coverage_object_file(source, object) | ||||
|     arg_hash = {:tool => TOOLS_BULLSEYE_INSTRUMENTATION, :context => BULLSEYE_SYM, :source => source, :object => object} | ||||
|     @ceedling[:plugin_manager].pre_compile_execute(arg_hash) | ||||
|  | ||||
|     @ceedling[:streaminator].stdout_puts("Compiling #{File.basename(source)} with coverage...") | ||||
|     compile_command  =  | ||||
|       @ceedling[:tool_executor].build_command_line( | ||||
|         TOOLS_BULLSEYE_COMPILER, | ||||
|         source, | ||||
|         object, | ||||
|         @ceedling[:file_path_utils].form_test_build_list_filepath( object ) ) | ||||
|     coverage_command = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_INSTRUMENTATION, compile_command[:line] ) | ||||
|  | ||||
|     shell_result     = @ceedling[:tool_executor].exec( coverage_command[:line], coverage_command[:options] ) | ||||
|      | ||||
|     arg_hash[:shell_result] = shell_result | ||||
|     @ceedling[:plugin_manager].post_compile_execute(arg_hash) | ||||
|   end | ||||
|  | ||||
|   def post_test_fixture_execute(arg_hash) | ||||
|     result_file = arg_hash[:result_file] | ||||
|    | ||||
|     if ((result_file =~ /#{BULLSEYE_RESULTS_PATH}/) and (not @result_list.include?(result_file))) | ||||
|       @result_list << arg_hash[:result_file] | ||||
|     end | ||||
|   end | ||||
|      | ||||
|   def post_build | ||||
|     return if (not @ceedling[:task_invoker].invoked?(/^#{BULLSEYE_TASK_ROOT}/)) | ||||
|  | ||||
|     # test results | ||||
|     results = @ceedling[:plugin_reportinator].assemble_test_results(@result_list) | ||||
|     hash = { | ||||
|       :header => BULLSEYE_ROOT_NAME.upcase, | ||||
|       :results => results | ||||
|     } | ||||
|      | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) do | ||||
|       message = '' | ||||
|       message = 'Unit test failures.' if (results[:counts][:failed] > 0) | ||||
|       message | ||||
|     end | ||||
|      | ||||
|     # coverage results | ||||
|     return if (verify_coverage_file() == false) | ||||
|     if (@ceedling[:task_invoker].invoked?(/^#{BULLSEYE_TASK_ROOT}(all|delta)/)) | ||||
|       command      = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_REPORT_COVSRC) | ||||
|       shell_result = @ceedling[:tool_executor].exec(command[:line], command[:options]) | ||||
|       report_coverage_results_all(shell_result[:output]) | ||||
|     else | ||||
|       report_per_function_coverage_results(@ceedling[:test_invoker].sources) | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def summary | ||||
|     return if (verify_coverage_file() == false) | ||||
|     result_list = @ceedling[:file_path_utils].form_pass_results_filelist( BULLSEYE_RESULTS_PATH, COLLECTION_ALL_TESTS ) | ||||
|  | ||||
|     # test results | ||||
|     # get test results for only those tests in our configuration and of those only tests with results on disk | ||||
|     hash = { | ||||
|       :header => BULLSEYE_ROOT_NAME.upcase, | ||||
|       :results => @ceedling[:plugin_reportinator].assemble_test_results(result_list, {:boom => false}) | ||||
|     } | ||||
|  | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) | ||||
|      | ||||
|     # coverage results | ||||
|     command = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_REPORT_COVSRC) | ||||
|     shell_result = @ceedling[:tool_executor].exec(command[:line], command[:options]) | ||||
|     report_coverage_results_all(shell_result[:output]) | ||||
|   end | ||||
|  | ||||
|   private ################################### | ||||
|  | ||||
|   def report_coverage_results_all(coverage) | ||||
|     results = { | ||||
|       :header => BULLSEYE_ROOT_NAME.upcase, | ||||
|       :coverage => { | ||||
|         :functions => nil, | ||||
|         :branches  => nil | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (coverage =~ /^Total.*?=\s+([0-9]+)\%/) | ||||
|       results[:coverage][:functions] = $1.to_i | ||||
|     end | ||||
|      | ||||
|     if (coverage =~ /^Total.*=\s+([0-9]+)\%\s*$/) | ||||
|       results[:coverage][:branches] = $1.to_i | ||||
|     end | ||||
|  | ||||
|     @ceedling[:plugin_reportinator].run_report($stdout, @coverage_template_all, results) | ||||
|   end | ||||
|  | ||||
|   def report_per_function_coverage_results(sources) | ||||
|     banner = @ceedling[:plugin_reportinator].generate_banner( "#{BULLSEYE_ROOT_NAME.upcase}: CODE COVERAGE SUMMARY" ) | ||||
|     @ceedling[:streaminator].stdout_puts "\n" + banner | ||||
|  | ||||
|     coverage_sources = sources.clone | ||||
|     coverage_sources.delete_if {|item| item =~ /#{CMOCK_MOCK_PREFIX}.+#{EXTENSION_SOURCE}$/} | ||||
|     coverage_sources.delete_if {|item| item =~ /#{BULLSEYE_IGNORE_SOURCES.join('|')}#{EXTENSION_SOURCE}$/} | ||||
|  | ||||
|     coverage_sources.each do |source| | ||||
|       command          = @ceedling[:tool_executor].build_command_line(TOOLS_BULLSEYE_REPORT_COVFN, source) | ||||
|       shell_results    = @ceedling[:tool_executor].exec(command[:line], command[:options]) | ||||
|       coverage_results = shell_results[:output].deep_clone | ||||
|       coverage_results.sub!(/.*\n.*\n/,'') # Remove the Bullseye tool banner | ||||
|       if (coverage_results =~ /warning cov814: report is empty/) | ||||
|         coverage_results = "WARNING: #{source} contains no coverage data!\n\n" | ||||
|         @ceedling[:streaminator].stdout_puts(coverage_results, Verbosity::COMPLAIN) | ||||
|       else | ||||
|         coverage_results += "\n" | ||||
|         @ceedling[:streaminator].stdout_puts(coverage_results) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def verify_coverage_file | ||||
|     exist = @ceedling[:file_wrapper].exist?( ENVIRONMENT_COVFILE ) | ||||
|  | ||||
|     if (!exist) | ||||
|       banner = @ceedling[:plugin_reportinator].generate_banner( "#{BULLSEYE_ROOT_NAME.upcase}: CODE COVERAGE SUMMARY" ) | ||||
|       @ceedling[:streaminator].stdout_puts "\n" + banner + "\nNo coverage file.\n\n" | ||||
|     end | ||||
|      | ||||
|     return exist | ||||
|   end | ||||
|    | ||||
| end | ||||
|  | ||||
|  | ||||
| # end blocks always executed following rake run | ||||
| END { | ||||
|   # cache our input configurations to use in comparison upon next execution | ||||
|   @ceedling[:cacheinator].cache_test_config( @ceedling[:setupinator].config_hash ) if (@ceedling[:task_invoker].invoked?(/^#{BULLSEYE_TASK_ROOT}/)) | ||||
| } | ||||
							
								
								
									
										0
									
								
								tests/vendor/ceedling/plugins/bullseye/readme.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/vendor/ceedling/plugins/bullseye/readme.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
									
										34
									
								
								tests/vendor/ceedling/plugins/gcov/defaults.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								tests/vendor/ceedling/plugins/gcov/defaults.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| --- | ||||
|  | ||||
| :tools: | ||||
|   :gcov_compiler: | ||||
|     :executable: gcc | ||||
|     :arguments: | ||||
|       - -g | ||||
|       - -fprofile-arcs | ||||
|       - -ftest-coverage | ||||
|       - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR | ||||
|       - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE | ||||
|       - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR | ||||
|       - -DGCOV_COMPILER | ||||
|       - -c "${1}" | ||||
|       - -o "${2}" | ||||
|   :gcov_linker: | ||||
|     :executable: gcc | ||||
|     :arguments: | ||||
|       - -fprofile-arcs | ||||
|       - -ftest-coverage | ||||
|       - ${1} | ||||
|       - -o ${2} | ||||
|   :gcov_fixture: | ||||
|     :executable: ${1} | ||||
|   :gcov_report: | ||||
|     :executable: gcov | ||||
|     :arguments: | ||||
|       - -n | ||||
|       - -p | ||||
|       - -b | ||||
|       - -o "$": GCOV_BUILD_OUTPUT_PATH | ||||
|       - "\"${1}\"" | ||||
|  | ||||
| ... | ||||
							
								
								
									
										152
									
								
								tests/vendor/ceedling/plugins/gcov/gcov.rake
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								tests/vendor/ceedling/plugins/gcov/gcov.rake
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,152 @@ | ||||
|  | ||||
| directory(GCOV_BUILD_OUTPUT_PATH) | ||||
| directory(GCOV_RESULTS_PATH) | ||||
| directory(GCOV_ARTIFACTS_PATH) | ||||
| directory(GCOV_DEPENDENCIES_PATH) | ||||
|  | ||||
| CLEAN.include(File.join(GCOV_BUILD_OUTPUT_PATH, '*')) | ||||
| CLEAN.include(File.join(GCOV_RESULTS_PATH, '*')) | ||||
| CLEAN.include(File.join(GCOV_DEPENDENCIES_PATH, '*')) | ||||
|  | ||||
| CLOBBER.include(File.join(GCOV_BUILD_PATH, '**/*')) | ||||
|  | ||||
|  | ||||
| rule(/#{GCOV_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_OBJECT}$/ => [ | ||||
|     proc do |task_name| | ||||
|       @ceedling[:file_finder].find_compilation_input_file(task_name) | ||||
|     end | ||||
|   ]) do |object| | ||||
|  | ||||
|   if (File.basename(object.source) =~ /^(#{PROJECT_TEST_FILE_PREFIX}|#{CMOCK_MOCK_PREFIX}|#{GCOV_IGNORE_SOURCES.join('|')})/i) | ||||
|     @ceedling[:generator].generate_object_file( | ||||
|       TOOLS_GCOV_COMPILER, | ||||
|       GCOV_SYM, | ||||
|       object.source, | ||||
|       object.name, | ||||
|       @ceedling[:file_path_utils].form_test_build_list_filepath( object.name ) ) | ||||
|   else | ||||
|     @ceedling[GCOV_SYM].generate_coverage_object_file(object.source, object.name) | ||||
|   end | ||||
|  | ||||
| end | ||||
|  | ||||
| rule(/#{GCOV_BUILD_OUTPUT_PATH}\/#{'.+\\'+EXTENSION_EXECUTABLE}$/) do |bin_file| | ||||
|   @ceedling[:generator].generate_executable_file( | ||||
|     TOOLS_GCOV_LINKER, | ||||
|     GCOV_SYM, | ||||
|     bin_file.prerequisites, | ||||
|     bin_file.name, | ||||
|     @ceedling[:file_path_utils].form_test_build_map_filepath(bin_file.name)) | ||||
| end | ||||
|  | ||||
| rule(/#{GCOV_RESULTS_PATH}\/#{'.+\\'+EXTENSION_TESTPASS}$/ => [ | ||||
|      proc do |task_name| | ||||
|        @ceedling[:file_path_utils].form_test_executable_filepath(task_name) | ||||
|      end | ||||
|   ]) do |test_result| | ||||
|   @ceedling[:generator].generate_test_results(TOOLS_GCOV_FIXTURE, GCOV_SYM, test_result.source, test_result.name) | ||||
| end | ||||
|  | ||||
| rule(/#{GCOV_DEPENDENCIES_PATH}\/#{'.+\\'+EXTENSION_DEPENDENCIES}$/ => [ | ||||
|     proc do |task_name| | ||||
|       @ceedling[:file_finder].find_compilation_input_file(task_name) | ||||
|     end | ||||
|   ]) do |dep| | ||||
|   @ceedling[:generator].generate_dependencies_file( | ||||
|     TOOLS_TEST_DEPENDENCIES_GENERATOR, | ||||
|     GCOV_SYM, | ||||
|     dep.source, | ||||
|     File.join(GCOV_BUILD_OUTPUT_PATH, File.basename(dep.source).ext(EXTENSION_OBJECT) ), | ||||
|     dep.name) | ||||
| end | ||||
|  | ||||
| task :directories => [GCOV_BUILD_OUTPUT_PATH, GCOV_RESULTS_PATH, GCOV_DEPENDENCIES_PATH, GCOV_ARTIFACTS_PATH] | ||||
|  | ||||
| namespace GCOV_SYM do | ||||
|  | ||||
|   task :source_coverage => COLLECTION_ALL_SOURCE.pathmap("#{GCOV_BUILD_OUTPUT_PATH}/%n#{@ceedling[:configurator].extension_object}") | ||||
|  | ||||
|   desc "Run code coverage for all tests" | ||||
|   task :all => [:directories] do | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[GCOV_SYM].config) | ||||
|     @ceedling[:test_invoker].setup_and_invoke(COLLECTION_ALL_TESTS, GCOV_SYM) | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
|  | ||||
|   desc "Run single test w/ coverage ([*] real test or source file name, no path)." | ||||
|   task :* do | ||||
|     message = "\nOops! '#{GCOV_ROOT_NAME}:*' isn't a real task. " + | ||||
|               "Use a real test or source file name (no path) in place of the wildcard.\n" + | ||||
|               "Example: rake #{GCOV_ROOT_NAME}:foo.c\n\n" | ||||
|    | ||||
|     @ceedling[:streaminator].stdout_puts( message ) | ||||
|   end | ||||
|    | ||||
|   desc "Run tests by matching regular expression pattern." | ||||
|   task :pattern, [:regex] => [:directories] do |t, args| | ||||
|     matches = [] | ||||
|      | ||||
|     COLLECTION_ALL_TESTS.each do |test| | ||||
|       matches << test if test =~ /#{args.regex}/ | ||||
|     end | ||||
|    | ||||
|     if (matches.size > 0) | ||||
|       @ceedling[:configurator].replace_flattened_config(@ceedling[GCOV_SYM].config) | ||||
|       @ceedling[:test_invoker].setup_and_invoke(matches, GCOV_SYM, {:force_run => false}) | ||||
|       @ceedling[:configurator].restore_config | ||||
|     else | ||||
|       @ceedling[:streaminator].stdout_puts("\nFound no tests matching pattern /#{args.regex}/.") | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   desc "Run tests whose test path contains [dir] or [dir] substring." | ||||
|   task :path, [:dir] => [:directories] do |t, args| | ||||
|     matches = [] | ||||
|      | ||||
|     COLLECTION_ALL_TESTS.each do |test| | ||||
|       matches << test if File.dirname(test).include?(args.dir.gsub(/\\/, '/')) | ||||
|     end | ||||
|    | ||||
|     if (matches.size > 0) | ||||
|       @ceedling[:configurator].replace_flattened_config(@ceedling[GCOV_SYM].config) | ||||
|       @ceedling[:test_invoker].setup_and_invoke(matches, GCOV_SYM, {:force_run => false}) | ||||
|       @ceedling[:configurator].restore_config | ||||
|     else | ||||
|       @ceedling[:streaminator].stdout_puts("\nFound no tests including the given path or path component.") | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   desc "Run code coverage for changed files" | ||||
|   task :delta => [:directories] do | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[GCOV_SYM].config) | ||||
|     @ceedling[:test_invoker].setup_and_invoke(COLLECTION_ALL_TESTS, GCOV_SYM, {:force_run => false}) | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
|    | ||||
|   # use a rule to increase efficiency for large projects | ||||
|   # gcov test tasks by regex | ||||
|   rule(/^#{GCOV_TASK_ROOT}\S+$/ => [ | ||||
|       proc do |task_name| | ||||
|         test = task_name.sub(/#{GCOV_TASK_ROOT}/, '') | ||||
|         test = "#{PROJECT_TEST_FILE_PREFIX}#{test}" if not (test.start_with?(PROJECT_TEST_FILE_PREFIX)) | ||||
|         @ceedling[:file_finder].find_test_from_file_path(test) | ||||
|       end | ||||
|   ]) do |test| | ||||
|     @ceedling[:rake_wrapper][:directories].invoke | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[GCOV_SYM].config) | ||||
|     @ceedling[:test_invoker].setup_and_invoke([test.source], GCOV_SYM) | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
|    | ||||
| end | ||||
|  | ||||
| if PROJECT_USE_DEEP_DEPENDENCIES | ||||
| namespace REFRESH_SYM do | ||||
|   task GCOV_SYM do | ||||
|     @ceedling[:configurator].replace_flattened_config(@ceedling[GCOV_SYM].config) | ||||
|     @ceedling[:test_invoker].refresh_deep_dependencies | ||||
|     @ceedling[:configurator].restore_config | ||||
|   end | ||||
| end | ||||
| end | ||||
|  | ||||
							
								
								
									
										128
									
								
								tests/vendor/ceedling/plugins/gcov/gcov.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								tests/vendor/ceedling/plugins/gcov/gcov.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,128 @@ | ||||
| require 'plugin' | ||||
| require 'constants' | ||||
|  | ||||
| GCOV_ROOT_NAME         = 'gcov' | ||||
| GCOV_TASK_ROOT         = GCOV_ROOT_NAME + ':' | ||||
| GCOV_SYM               = GCOV_ROOT_NAME.to_sym | ||||
|  | ||||
| GCOV_BUILD_PATH        = "#{PROJECT_BUILD_ROOT}/#{GCOV_ROOT_NAME}" | ||||
| GCOV_BUILD_OUTPUT_PATH = "#{GCOV_BUILD_PATH}/out" | ||||
| GCOV_RESULTS_PATH      = "#{GCOV_BUILD_PATH}/results" | ||||
| GCOV_DEPENDENCIES_PATH = "#{GCOV_BUILD_PATH}/dependencies" | ||||
| GCOV_ARTIFACTS_PATH    = "#{PROJECT_BUILD_ARTIFACTS_ROOT}/#{GCOV_ROOT_NAME}" | ||||
|  | ||||
| GCOV_IGNORE_SOURCES    = ['unity', 'cmock', 'cexception'] | ||||
|  | ||||
|  | ||||
| class Gcov < Plugin | ||||
|  | ||||
|   attr_reader :config | ||||
|  | ||||
|   def setup | ||||
|     @result_list = []   | ||||
|    | ||||
|     @config = { | ||||
|       :project_test_build_output_path     => GCOV_BUILD_OUTPUT_PATH, | ||||
|       :project_test_results_path          => GCOV_RESULTS_PATH, | ||||
|       :project_test_dependencies_path     => GCOV_DEPENDENCIES_PATH, | ||||
|       :defines_test                       => DEFINES_TEST + ['CODE_COVERAGE'], | ||||
|       :collection_defines_test_and_vendor => COLLECTION_DEFINES_TEST_AND_VENDOR + ['CODE_COVERAGE'] | ||||
|       } | ||||
|      | ||||
|     @coverage_template_all = @ceedling[:file_wrapper].read( File.join( PLUGINS_GCOV_PATH, 'template.erb') ) | ||||
|   end | ||||
|  | ||||
|   def generate_coverage_object_file(source, object) | ||||
|     compile_command =  | ||||
|       @ceedling[:tool_executor].build_command_line( | ||||
|         TOOLS_GCOV_COMPILER, | ||||
|         source, | ||||
|         object, | ||||
|         @ceedling[:file_path_utils].form_test_build_list_filepath( object ) ) | ||||
|     @ceedling[:streaminator].stdout_puts("Compiling #{File.basename(source)} with coverage...") | ||||
|     @ceedling[:tool_executor].exec( compile_command[:line], compile_command[:options] ) | ||||
|   end | ||||
|  | ||||
|   def post_test_fixture_execute(arg_hash) | ||||
|     result_file = arg_hash[:result_file] | ||||
|    | ||||
|     if ((result_file =~ /#{GCOV_RESULTS_PATH}/) and (not @result_list.include?(result_file))) | ||||
|       @result_list << arg_hash[:result_file] | ||||
|     end | ||||
|   end | ||||
|      | ||||
|   def post_build | ||||
|     return if (not @ceedling[:task_invoker].invoked?(/^#{GCOV_TASK_ROOT}/)) | ||||
|  | ||||
|     # test results | ||||
|     results = @ceedling[:plugin_reportinator].assemble_test_results(@result_list) | ||||
|     hash = { | ||||
|       :header => GCOV_ROOT_NAME.upcase, | ||||
|       :results => results | ||||
|     } | ||||
|      | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) do | ||||
|       message = '' | ||||
|       message = 'Unit test failures.' if (results[:counts][:failed] > 0) | ||||
|       message | ||||
|     end | ||||
|      | ||||
|     if (@ceedling[:task_invoker].invoked?(/^#{GCOV_TASK_ROOT}(all|delta)/)) | ||||
|       report_coverage_results_summary(@ceedling[:test_invoker].sources) | ||||
|     else | ||||
|       report_per_file_coverage_results(@ceedling[:test_invoker].sources) | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def summary | ||||
|     result_list = @ceedling[:file_path_utils].form_pass_results_filelist( GCOV_RESULTS_PATH, COLLECTION_ALL_TESTS ) | ||||
|  | ||||
|     # test results | ||||
|     # get test results for only those tests in our configuration and of those only tests with results on disk | ||||
|     hash = { | ||||
|       :header => GCOV_ROOT_NAME.upcase, | ||||
|       :results => @ceedling[:plugin_reportinator].assemble_test_results(result_list, {:boom => false}) | ||||
|     } | ||||
|  | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) | ||||
|      | ||||
|     # coverage results | ||||
|     # command = @ceedling[:tool_executor].build_command_line(TOOLS_GCOV_REPORT_COVSRC) | ||||
|     # shell_result = @ceedling[:tool_executor].exec(command[:line], command[:options]) | ||||
|     # report_coverage_results_all(shell_result[:output]) | ||||
|   end | ||||
|  | ||||
|   private ################################### | ||||
|  | ||||
|   def report_coverage_results_summary(sources) | ||||
|  | ||||
|   end | ||||
|  | ||||
|   def report_per_file_coverage_results(sources) | ||||
|     banner = @ceedling[:plugin_reportinator].generate_banner "#{GCOV_ROOT_NAME.upcase}: CODE COVERAGE SUMMARY" | ||||
|     @ceedling[:streaminator].stdout_puts "\n" + banner | ||||
|  | ||||
|     coverage_sources = sources.clone | ||||
|     coverage_sources.delete_if {|item| item =~ /#{CMOCK_MOCK_PREFIX}.+#{EXTENSION_SOURCE}$/} | ||||
|     coverage_sources.delete_if {|item| item =~ /#{GCOV_IGNORE_SOURCES.join('|')}#{EXTENSION_SOURCE}$/} | ||||
|  | ||||
|     coverage_sources.each do |source| | ||||
|       basename         = File.basename(source) | ||||
|       command          = @ceedling[:tool_executor].build_command_line(TOOLS_GCOV_REPORT, basename) | ||||
|       shell_results    = @ceedling[:tool_executor].exec(command[:line], command[:options]) | ||||
|       coverage_results = shell_results[:output] | ||||
|  | ||||
|       if (coverage_results.strip =~ /(File\s+'#{Regexp.escape(source)}'.+$)/m) | ||||
|         report = ((($1.lines.to_a)[1..-1])).map{|line| basename + ' ' + line}.join('') | ||||
|         @ceedling[:streaminator].stdout_puts(report + "\n\n") | ||||
|       end | ||||
|     end | ||||
|   end | ||||
|  | ||||
| end | ||||
|  | ||||
| # end blocks always executed following rake run | ||||
| END { | ||||
|   # cache our input configurations to use in comparison upon next execution | ||||
|   @ceedling[:cacheinator].cache_test_config( @ceedling[:setupinator].config_hash ) if (@ceedling[:task_invoker].invoked?(/^#{GCOV_TASK_ROOT}/)) | ||||
| } | ||||
							
								
								
									
										0
									
								
								tests/vendor/ceedling/plugins/gcov/readme.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/vendor/ceedling/plugins/gcov/readme.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
									
										15
									
								
								tests/vendor/ceedling/plugins/gcov/template.erb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/vendor/ceedling/plugins/gcov/template.erb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| % function_string = hash[:coverage][:functions].to_s | ||||
| % branch_string   = hash[:coverage][:branches].to_s | ||||
| % format_string   = "%#{[function_string.length, branch_string.length].max}i" | ||||
| <%=@ceedling[:plugin_reportinator].generate_banner("#{BULLSEYE_ROOT_NAME.upcase}: CODE COVERAGE SUMMARY")%> | ||||
| % if (!hash[:coverage][:functions].nil?) | ||||
| FUNCTIONS: <%=sprintf(format_string, hash[:coverage][:functions])%>% | ||||
| % else | ||||
| FUNCTIONS: none | ||||
| % end | ||||
| % if (!hash[:coverage][:branches].nil?) | ||||
| BRANCHES:  <%=sprintf(format_string, hash[:coverage][:branches])%>% | ||||
| % else | ||||
| BRANCHES:  none | ||||
| % end | ||||
|  | ||||
							
								
								
									
										4
									
								
								tests/vendor/ceedling/plugins/module_generator/config/module_generator.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/vendor/ceedling/plugins/module_generator/config/module_generator.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| :module_generator: | ||||
|   :project_root: ./ | ||||
|   :source_root: src/ | ||||
|   :test_root: test/ | ||||
							
								
								
									
										144
									
								
								tests/vendor/ceedling/plugins/module_generator/lib/module_generator.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										144
									
								
								tests/vendor/ceedling/plugins/module_generator/lib/module_generator.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,144 @@ | ||||
| require 'plugin' | ||||
| require 'constants' | ||||
| require 'erb' | ||||
| require 'fileutils' | ||||
|  | ||||
| class ModuleGenerator < Plugin | ||||
|  | ||||
|   attr_reader :config | ||||
|  | ||||
|   def setup | ||||
|    | ||||
|     #---- New module templates | ||||
|      | ||||
|     @test_template = (<<-EOS).left_margin | ||||
|       #include "unity.h" | ||||
|       <%if defined?(MODULE_GENERATOR_TEST_INCLUDES) && (MODULE_GENERATOR_TEST_INCLUDES.class == Array) && !MODULE_GENERATOR_TEST_INCLUDES.empty?%> | ||||
|       <%MODULE_GENERATOR_TEST_INCLUDES.each do |header_file|%> | ||||
|       #include "<%=header_file%>" | ||||
|       <%end%> | ||||
|       <%end%> | ||||
|       #include "<%=@context[:headername]%>" | ||||
|        | ||||
|       void setUp(void) | ||||
|       { | ||||
|       } | ||||
|        | ||||
|       void tearDown(void) | ||||
|       { | ||||
|       } | ||||
|        | ||||
|       void test_<%=name%>_needs_to_be_implemented(void) | ||||
|       { | ||||
|       <%="\t"%>TEST_IGNORE_MESSAGE("Implement me!"); | ||||
|       } | ||||
|       EOS | ||||
|  | ||||
|     @source_template = (<<-EOS).left_margin | ||||
|       <%if defined?(MODULE_GENERATOR_SOURCE_INCLUDES) && (MODULE_GENERATOR_SOURCE_INCLUDES.class == Array) && !MODULE_GENERATOR_SOURCE_INCLUDES.empty?%> | ||||
|       <%MODULE_GENERATOR_SOURCE_INCLUDES.each do |header_file|%> | ||||
|       #include "<%=header_file%>" | ||||
|       <%end%> | ||||
|       <%end%> | ||||
|       #include "<%=@context[:headername]%>" | ||||
|       EOS | ||||
|  | ||||
|     @header_template = (<<-EOS).left_margin | ||||
|       #ifndef <%=@context[:name]%>_H | ||||
|       #define <%=@context[:name]%>_H | ||||
|        | ||||
|       <%if defined?(MODULE_GENERATOR_HEADER_INCLUDES) && (MODULE_GENERATOR_HEADER_INCLUDES.class == Array) && !MODULE_GENERATOR_HEADER_INCLUDES.empty?%> | ||||
|       <%MODULE_GENERATOR_HEADER_INCLUDES.each do |header_file|%> | ||||
|       #include "<%=header_file%>" | ||||
|       <%end%> | ||||
|       <%end%> | ||||
|        | ||||
|       #endif // <%=@context[:name]%>_H | ||||
|       EOS | ||||
|   end | ||||
|  | ||||
|   def create(path, optz={}) | ||||
|    | ||||
|     extract_context(path, optz) | ||||
|  | ||||
|     if !optz.nil? && (optz[:destroy] == true) | ||||
|       @ceedling[:streaminator].stdout_puts "Destroying '#{path}'..." | ||||
|       @files.each do |file| | ||||
|         if File.exist?(file[:path]) | ||||
|           @ceedling[:streaminator].stdout_puts "File #{file[:path]} deleted" | ||||
|         else | ||||
|           @ceedling[:streaminator].stdout_puts "File #{file[:path]} does not exist!" | ||||
|         end | ||||
|       end | ||||
|       exit | ||||
|     end | ||||
|  | ||||
|     @ceedling[:streaminator].stdout_puts "Generating '#{path}'..." | ||||
|  | ||||
|     [File.dirname(@files[0][:path]), File.dirname(@files[1][:path])].each do |dir| | ||||
|       makedirs(dir, {:verbose => true}) | ||||
|     end | ||||
|  | ||||
|     # define_name = headername.gsub(/\.h$/, '_H').upcase | ||||
|  | ||||
|     @files[0][:template] = @test_template | ||||
|     @files[1][:template] = @source_template | ||||
|     @files[2][:template] = @header_template | ||||
|  | ||||
|     @files.each do |file| | ||||
|       if File.exist?(file[:path]) | ||||
|         @ceedling[:streaminator].stdout_puts "File #{file[:path]} already exists!" | ||||
|       else | ||||
|         File.open(file[:path], 'w') do |new_file| | ||||
|           new_file << ERB.new(file[:template], 0, "<>").result(binding) | ||||
|         end | ||||
|         @ceedling[:streaminator].stdout_puts "File #{file[:path]} created" | ||||
|       end | ||||
|     end | ||||
|  | ||||
|   end | ||||
|    | ||||
|   private | ||||
|    | ||||
|   def extract_context(path, optz={}) | ||||
|     if (!defined?(MODULE_GENERATOR_PROJECT_ROOT) || | ||||
|         !defined?(MODULE_GENERATOR_SOURCE_ROOT) || | ||||
|         !defined?(MODULE_GENERATOR_TEST_ROOT)) | ||||
|       raise "You must have ':module_generator:project_root:', ':module_generator:source_root:' and ':module_generator:test_root:' defined in your Ceedling configuration file" | ||||
|     end | ||||
|      | ||||
|     @context = {} | ||||
|  | ||||
|     @context[:paths] = { | ||||
|       :base => @ceedling[:file_wrapper].get_expanded_path(MODULE_GENERATOR_PROJECT_ROOT).gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''), | ||||
|       :src => MODULE_GENERATOR_SOURCE_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, ''), | ||||
|       :test => MODULE_GENERATOR_TEST_ROOT.gsub('\\', '/').sub(/^\//, '').sub(/\/$/, '') | ||||
|     } | ||||
|  | ||||
|     location = File.dirname(path.gsub('\\', '/')) | ||||
|     location.sub!(/^\/?#{@context[:paths][:base]}\/?/i, '') | ||||
|     location.sub!(/^\/?#{@context[:paths][:src]}\/?/i, '') | ||||
|     location.sub!(/^\/?#{@context[:paths][:test]}\/?/i, '') | ||||
|      | ||||
|     @context[:location] = location | ||||
|  | ||||
|     @context[:name] = File.basename(path).sub(/\.[ch]$/, '') | ||||
|      | ||||
|     # p @context[:name] | ||||
|      | ||||
|     @context[:testname] = "test_#{@context[:name]}.c" | ||||
|     @context[:sourcename] = "#{@context[:name]}.c" | ||||
|     @context[:headername] = "#{@context[:name]}.h" | ||||
|      | ||||
|     # p @context | ||||
|  | ||||
|     @files = [ | ||||
|       {:path => File.join(MODULE_GENERATOR_PROJECT_ROOT, @context[:paths][:test], location, @context[:testname])}, | ||||
|       {:path => File.join(MODULE_GENERATOR_PROJECT_ROOT, @context[:paths][:src],  location, @context[:sourcename])}, | ||||
|       {:path => File.join(MODULE_GENERATOR_PROJECT_ROOT, @context[:paths][:src],  location, @context[:headername])} | ||||
|     ] | ||||
|      | ||||
|     # p @files | ||||
|   end | ||||
|    | ||||
| end | ||||
							
								
								
									
										14
									
								
								tests/vendor/ceedling/plugins/module_generator/module_generator.rake
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tests/vendor/ceedling/plugins/module_generator/module_generator.rake
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
|  | ||||
| namespace :module do | ||||
|  | ||||
|   desc "Generate module (source, header and test files)" | ||||
|     task :create, :module_path do |t, args| | ||||
|     @ceedling[:module_generator].create(args[:module_path]) | ||||
|   end | ||||
|  | ||||
|   desc "Destroy module (source, header and test files)" | ||||
|   task :destroy, :module_path do |t, args| | ||||
|     @ceedling[:module_generator].create(args[:module_path], {:destroy => true}) | ||||
|   end | ||||
|    | ||||
| end | ||||
							
								
								
									
										4
									
								
								tests/vendor/ceedling/plugins/stdout_ide_tests_report/config/stdout_ide_tests_report.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/vendor/ceedling/plugins/stdout_ide_tests_report/config/stdout_ide_tests_report.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| --- | ||||
| :plugins: | ||||
|   # tell Ceedling we got results display taken care of | ||||
|   :display_raw_test_results: FALSE | ||||
							
								
								
									
										44
									
								
								tests/vendor/ceedling/plugins/stdout_ide_tests_report/lib/stdout_ide_tests_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								tests/vendor/ceedling/plugins/stdout_ide_tests_report/lib/stdout_ide_tests_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| require 'plugin' | ||||
| require 'defaults' | ||||
|  | ||||
| class StdoutIdeTestsReport < Plugin | ||||
|    | ||||
|   def setup | ||||
|     @result_list = [] | ||||
|   end | ||||
|      | ||||
|   def post_test_fixture_execute(arg_hash) | ||||
|     return if not (arg_hash[:context] == TEST_SYM) | ||||
|  | ||||
|     @result_list << arg_hash[:result_file] | ||||
|   end | ||||
|    | ||||
|   def post_build | ||||
|     return if (not @ceedling[:task_invoker].test_invoked?) | ||||
|      | ||||
|     results = @ceedling[:plugin_reportinator].assemble_test_results(@result_list) | ||||
|     hash = { | ||||
|       :header => '', | ||||
|       :results => results | ||||
|     } | ||||
|      | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) do | ||||
|       message = '' | ||||
|       message = 'Unit test failures.' if (hash[:results][:counts][:failed] > 0) | ||||
|       message | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def summary | ||||
|     result_list = @ceedling[:file_path_utils].form_pass_results_filelist( PROJECT_TEST_RESULTS_PATH, COLLECTION_ALL_TESTS ) | ||||
|  | ||||
|     # get test results for only those tests in our configuration and of those only tests with results on disk | ||||
|     hash = { | ||||
|       :header => '', | ||||
|       :results => @ceedling[:plugin_reportinator].assemble_test_results(result_list, {:boom => false}) | ||||
|     } | ||||
|  | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) | ||||
|   end | ||||
|  | ||||
| end | ||||
							
								
								
									
										59
									
								
								tests/vendor/ceedling/plugins/stdout_pretty_tests_report/assets/template.erb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								tests/vendor/ceedling/plugins/stdout_pretty_tests_report/assets/template.erb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| % ignored        = hash[:results][:counts][:ignored] | ||||
| % failed         = hash[:results][:counts][:failed] | ||||
| % stdout_count   = hash[:results][:counts][:stdout] | ||||
| % header_prepend = ((hash[:header].length > 0) ? "#{hash[:header]}: " : '') | ||||
| % banner_width   = 25 + header_prepend.length # widest message | ||||
|  | ||||
| % if (ignored > 0) | ||||
| <%=@ceedling[:plugin_reportinator].generate_banner(header_prepend + 'IGNORED UNIT TEST SUMMARY')%> | ||||
| %   hash[:results][:ignores].each do |ignore| | ||||
| [<%=ignore[:source][:file]%>] | ||||
| %     ignore[:collection].each do |item| | ||||
|   Test: <%=item[:test]%> | ||||
| % if (not item[:message].empty?) | ||||
|   At line (<%=item[:line]%>): "<%=item[:message]%>" | ||||
| % else | ||||
|   At line (<%=item[:line]%>) | ||||
| % end | ||||
|  | ||||
| %     end | ||||
| %   end | ||||
| % end | ||||
| % if (failed > 0) | ||||
| <%=@ceedling[:plugin_reportinator].generate_banner(header_prepend + 'FAILED UNIT TEST SUMMARY')%> | ||||
| %   hash[:results][:failures].each do |failure| | ||||
| [<%=failure[:source][:file]%>] | ||||
| %     failure[:collection].each do |item| | ||||
|   Test: <%=item[:test]%> | ||||
| % if (not item[:message].empty?) | ||||
|   At line (<%=item[:line]%>): "<%=item[:message]%>" | ||||
| % else | ||||
|   At line (<%=item[:line]%>) | ||||
| % end | ||||
|  | ||||
| %     end | ||||
| %   end | ||||
| % end | ||||
| % if (stdout_count > 0) | ||||
| <%=@ceedling[:plugin_reportinator].generate_banner(header_prepend + 'UNIT TEST OTHER OUTPUT')%> | ||||
| %   hash[:results][:stdout].each do |string| | ||||
| [<%=string[:source][:file]%>] | ||||
| %     string[:collection].each do |item| | ||||
|   - "<%=item%>" | ||||
| %     end | ||||
|  | ||||
| %   end | ||||
| % end | ||||
| % total_string = hash[:results][:counts][:total].to_s | ||||
| % format_string = "%#{total_string.length}i" | ||||
| <%=@ceedling[:plugin_reportinator].generate_banner(header_prepend + 'OVERALL UNIT TEST SUMMARY')%> | ||||
| % if (hash[:results][:counts][:total] > 0) | ||||
| TESTED:  <%=hash[:results][:counts][:total].to_s%> | ||||
| PASSED:  <%=sprintf(format_string, hash[:results][:counts][:passed])%> | ||||
| FAILED:  <%=sprintf(format_string, failed)%> | ||||
| IGNORED: <%=sprintf(format_string, ignored)%> | ||||
| % else | ||||
|  | ||||
| No tests executed. | ||||
| % end | ||||
|  | ||||
| @@ -0,0 +1,4 @@ | ||||
| --- | ||||
| :plugins: | ||||
|   # tell Ceedling we got results display taken care of | ||||
|   :display_raw_test_results: FALSE | ||||
							
								
								
									
										47
									
								
								tests/vendor/ceedling/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								tests/vendor/ceedling/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| require 'plugin' | ||||
| require 'defaults' | ||||
|  | ||||
| class StdoutPrettyTestsReport < Plugin | ||||
|    | ||||
|   def setup | ||||
|     @result_list = [] | ||||
|     @plugin_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||||
|     template = @ceedling[:file_wrapper].read(File.join(@plugin_root, 'assets/template.erb')) | ||||
|     @ceedling[:plugin_reportinator].register_test_results_template( template ) | ||||
|   end | ||||
|    | ||||
|   def post_test_fixture_execute(arg_hash) | ||||
|     return if not (arg_hash[:context] == TEST_SYM) | ||||
|    | ||||
|     @result_list << arg_hash[:result_file] | ||||
|   end | ||||
|    | ||||
|   def post_build | ||||
|     return if not (@ceedling[:task_invoker].test_invoked?) | ||||
|  | ||||
|     results = @ceedling[:plugin_reportinator].assemble_test_results(@result_list) | ||||
|     hash = { | ||||
|       :header => '', | ||||
|       :results => results | ||||
|     } | ||||
|  | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) do | ||||
|       message = '' | ||||
|       message = 'Unit test failures.' if (results[:counts][:failed] > 0) | ||||
|       message | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def summary | ||||
|     result_list = @ceedling[:file_path_utils].form_pass_results_filelist( PROJECT_TEST_RESULTS_PATH, COLLECTION_ALL_TESTS ) | ||||
|  | ||||
|     # get test results for only those tests in our configuration and of those only tests with results on disk | ||||
|     hash = { | ||||
|       :header => '', | ||||
|       :results => @ceedling[:plugin_reportinator].assemble_test_results(result_list, {:boom => false}) | ||||
|     } | ||||
|  | ||||
|     @ceedling[:plugin_reportinator].run_test_results_report(hash) | ||||
|   end | ||||
|  | ||||
| end | ||||
							
								
								
									
										71
									
								
								tests/vendor/ceedling/plugins/warnings_report/warnings_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								tests/vendor/ceedling/plugins/warnings_report/warnings_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| require 'plugin' | ||||
| require 'constants' | ||||
|  | ||||
| class WarningsReport < Plugin | ||||
|  | ||||
|   def setup | ||||
|     @stderr_redirect = nil | ||||
|     @log_paths = {} | ||||
|   end | ||||
|  | ||||
|   def pre_compile_execute( arg_hash ) | ||||
|     # at beginning of compile, override tool's stderr_redirect so we can parse $stderr + $stdout | ||||
|     set_stderr_redirect( arg_hash ) | ||||
|   end | ||||
|    | ||||
|   def post_compile_execute( arg_hash ) | ||||
|     # after compilation, grab output for parsing/logging, restore stderr_redirect, log warning if it exists | ||||
|     output = arg_hash[:shell_result][:output] | ||||
|     restore_stderr_redirect( arg_hash ) | ||||
|     write_warning_log( arg_hash[:context], output ) | ||||
|   end | ||||
|  | ||||
|   def pre_link_execute( arg_hash ) | ||||
|     # at beginning of link, override tool's stderr_redirect so we can parse $stderr + $stdout | ||||
|     set_stderr_redirect( arg_hash ) | ||||
|   end | ||||
|    | ||||
|   def post_link_execute( arg_hash ) | ||||
|     # after linking, grab output for parsing/logging, restore stderr_redirect, log warning if it exists | ||||
|     output = arg_hash[:shell_result][:output] | ||||
|     restore_stderr_redirect( arg_hash ) | ||||
|     write_warning_log( arg_hash[:context], output ) | ||||
|   end | ||||
|  | ||||
|   private | ||||
|    | ||||
|   def set_stderr_redirect( hash ) | ||||
|     @stderr_redirect = hash[:tool][:stderr_redirect] | ||||
|     hash[:tool][:stderr_redirect] = StdErrRedirect::AUTO     | ||||
|   end | ||||
|    | ||||
|   def restore_stderr_redirect( hash ) | ||||
|     hash[:tool][:stderr_redirect] = @stderr_redirect     | ||||
|   end | ||||
|    | ||||
|   def write_warning_log( context, output ) | ||||
|     # if $stderr/$stdout contain "warning", log it | ||||
|     if (output =~ /warning/i) | ||||
|       # generate a log path & file io write flags | ||||
|       logging = generate_log_path( context ) | ||||
|       @ceedling[:file_wrapper].write( logging[:path], output + "\n", logging[:flags] ) if (not logging.nil?) | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   def generate_log_path( context ) | ||||
|     # if path has already been generated, return it & 'append' file io flags (append to log) | ||||
|     return { :path => @log_paths[context], :flags => 'a' } if (not @log_paths[context].nil?) | ||||
|      | ||||
|     # first time through, generate path & 'write' file io flags (create new log) | ||||
|     base_path = File.join( PROJECT_BUILD_ARTIFACTS_ROOT, context.to_s ) | ||||
|     file_path = File.join( base_path, 'warnings.log' ) | ||||
|      | ||||
|     if (@ceedling[:file_wrapper].exist?( base_path )) | ||||
|       @log_paths[context] = file_path | ||||
|       return { :path => file_path, :flags => 'w' } | ||||
|     end | ||||
|      | ||||
|     return nil | ||||
|   end | ||||
|  | ||||
| end | ||||
							
								
								
									
										110
									
								
								tests/vendor/ceedling/plugins/xml_tests_report/xml_tests_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								tests/vendor/ceedling/plugins/xml_tests_report/xml_tests_report.rb
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| require 'plugin' | ||||
| require 'constants' | ||||
|  | ||||
| class XmlTestsReport < Plugin | ||||
|  | ||||
|   def setup | ||||
|     @results_list = {} | ||||
|     @test_counter = 0 | ||||
|   end | ||||
|  | ||||
|   def post_test_fixture_execute(arg_hash) | ||||
|     context = arg_hash[:context] | ||||
|  | ||||
|     @results_list[context] = [] if (@results_list[context].nil?) | ||||
|  | ||||
|     @results_list[context] << arg_hash[:result_file] | ||||
|   end | ||||
|    | ||||
|   def post_build | ||||
|     @results_list.each_key do |context| | ||||
|       results = @ceedling[:plugin_reportinator].assemble_test_results(@results_list[context]) | ||||
|  | ||||
|       file_path = File.join( PROJECT_BUILD_ARTIFACTS_ROOT, context.to_s, 'report.xml' ) | ||||
|    | ||||
|       @ceedling[:file_wrapper].open( file_path, 'w' ) do |f| | ||||
|         @test_counter = 1 | ||||
|         write_results( results, f ) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
|    | ||||
|   private | ||||
|    | ||||
|   def write_results( results, stream ) | ||||
|     write_header( stream ) | ||||
|     write_failures( results[:failures], stream ) | ||||
|     write_tests( results[:successes], stream, 'SuccessfulTests' ) | ||||
|     write_tests( results[:ignores], stream, 'IgnoredTests' ) | ||||
|     write_statistics( results[:counts], stream ) | ||||
|     write_footer( stream ) | ||||
|   end | ||||
|    | ||||
|   def write_header( stream ) | ||||
|     stream.puts "<?xml version='1.0' encoding='utf-8' ?>" | ||||
|     stream.puts "<TestRun>" | ||||
|   end | ||||
|  | ||||
|   def write_failures( results, stream ) | ||||
|     if (results.size == 0) | ||||
|       stream.puts "\t<FailedTests/>" | ||||
|       return | ||||
|     end | ||||
|  | ||||
|     stream.puts "\t<FailedTests>" | ||||
|    | ||||
|     results.each do |result| | ||||
|         result[:collection].each do |item| | ||||
|           filename = File.join( result[:source][:path], result[:source][:file] ) | ||||
|          | ||||
|           stream.puts "\t\t<FailedTest id=\"#{@test_counter}\">" | ||||
|           stream.puts "\t\t\t<Name>#{filename}::#{item[:test]}</Name>" | ||||
|   				stream.puts "\t\t\t<FailureType>Assertion</FailureType>" | ||||
|           stream.puts "\t\t\t<Location>" | ||||
|           stream.puts "\t\t\t\t<File>#{filename}</File>" | ||||
|           stream.puts "\t\t\t\t<Line>#{item[:line]}</Line>" | ||||
|           stream.puts "\t\t\t</Location>" | ||||
|           stream.puts "\t\t\t<Message>#{item[:message]}</Message>" | ||||
|           stream.puts "\t\t</Test>" | ||||
|           @test_counter += 1 | ||||
|         end | ||||
|     end | ||||
|      | ||||
|     stream.puts "\t</FailedTests>"       | ||||
|   end | ||||
|    | ||||
|   def write_tests( results, stream, tag ) | ||||
|     if (results.size == 0) | ||||
|       stream.puts "\t<#{tag}/>" | ||||
|       return | ||||
|     end | ||||
|  | ||||
|     stream.puts "\t<#{tag}>" | ||||
|    | ||||
|     results.each do |result| | ||||
|         result[:collection].each do |item| | ||||
|           stream.puts "\t\t<Test id=\"#{@test_counter}\">" | ||||
|           stream.puts "\t\t\t<Name>#{File.join( result[:source][:path], result[:source][:file] )}::#{item[:test]}</Name>" | ||||
|           stream.puts "\t\t</Test>" | ||||
|           @test_counter += 1 | ||||
|         end | ||||
|     end | ||||
|      | ||||
|     stream.puts "\t</#{tag}>"       | ||||
|   end | ||||
|  | ||||
|   def write_statistics( counts, stream ) | ||||
|     stream.puts "\t<Statistics>" | ||||
|     stream.puts "\t\t<Tests>#{counts[:total]}</Tests>" | ||||
|     stream.puts "\t\t<Ignores>#{counts[:ignored]}</Ignores>" | ||||
|     stream.puts "\t\t<FailuresTotal>#{counts[:failed]}</FailuresTotal>" | ||||
|     stream.puts "\t\t<Errors>0</Errors>" | ||||
|     stream.puts "\t\t<Failures>#{counts[:failed]}</Failures>" | ||||
|     stream.puts "\t</Statistics>" | ||||
|   end | ||||
|    | ||||
|   def write_footer( stream ) | ||||
|     stream.puts "</TestRun>" | ||||
|   end | ||||
|    | ||||
| end | ||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach