class Object
¶ ↑
Ceedling - Test-Centered Build System for C ThrowTheSwitch.org Copyright (c) 2010-25 Mike Karlesky, Mark VanderVoord, & Greg Williams SPDX-License-Identifier: MIT
¶ ↑
Constants
- BACKTRACE_GDB_SCRIPT_FILE
- CEEDLING_PLUGINS
- CEEDLING_RUNTIME_CONFIG
- CEEDLING_VENDOR
-
Assign a default value for system testing where CEEDLING_APPCFG may not be present TODO: Create code config & test structure that does not internalize a test path like this
- CEXCEPTION_C_FILE
- CEXCEPTION_H_FILE
- CEXCEPTION_LIB_PATH
- CEXCEPTION_ROOT_PATH
- CEXCEPTION_SYM
- CMOCK_C_FILE
- CMOCK_H_FILE
- CMOCK_LIB_PATH
- CMOCK_ROOT_PATH
- CMOCK_SYM
- DEFAULT_BUILD_LOGS_PATH
- DEFAULT_CEEDLING_LOGFILE
- DEFAULT_CEEDLING_PROJECT_CONFIG
- DEFAULT_PROJECT_FILENAME
- DEFAULT_RELEASE_ASSEMBLER_TOOL
- DEFAULT_RELEASE_COMPILER_TOOL
- DEFAULT_RELEASE_DEPENDENCIES_GENERATOR_TOOL
- DEFAULT_RELEASE_LINKER_TOOL
- DEFAULT_RELEASE_TARGET_NAME
- DEFAULT_TESTS_RESULTS_REPORT_TEMPLATE
- DEFAULT_TEST_ASSEMBLER_TOOL
- DEFAULT_TEST_BACKTRACE_GDB_TOOL
- DEFAULT_TEST_COMPILER_TOOL
- DEFAULT_TEST_FILE_DIRECTIVES_ONLY_PREPROCESSOR_TOOL
- DEFAULT_TEST_FILE_FULL_PREPROCESSOR_TOOL
- DEFAULT_TEST_FIXTURE_SIMPLE_BACKTRACE_TOOL
- DEFAULT_TEST_FIXTURE_TOOL
- DEFAULT_TEST_LINKER_TOOL
- DEFAULT_TEST_NESTED_INCLUDES_PREPROCESSOR_TOOL
- DEFAULT_TEST_SHALLOW_INCLUDES_PREPROCESSOR_TOOL
- DEFAULT_TOOLS_RELEASE
- DEFAULT_TOOLS_RELEASE_ASSEMBLER
- DEFAULT_TOOLS_RELEASE_DEPENDENCIES
- DEFAULT_TOOLS_TEST
- DEFAULT_TOOLS_TEST_ASSEMBLER
- DEFAULT_TOOLS_TEST_GDB_BACKTRACE
- DEFAULT_TOOLS_TEST_PREPROCESSORS
- DEFINES_DEPENDENCY_CACHE_FILE
- EXTENSION_CORE_SOURCE
-
Vendor frameworks, generated mocks, generated runners are always .c files
- EXTENSION_NONWIN_EXE
- EXTENSION_WIN_EXE
- GENERATED_DIR_PATH
- GIT_COMMIT_SHA_FILENAME
- INPUT_CONFIGURATION_CACHE_FILE
- MD_FLAG
- NEWLINE_TOKEN
-
Escaped newline literal (literally double-slash-n) for “encoding” multiline strings as single string
- NULL_FILE_PATH
- OPERATION_ASSEMBLE_SYM
- OPERATION_COMPILE_SYM
- OPERATION_LINK_SYM
- OPERATION_PREPROCESS_SYM
- PREPROCESS_DIRECTIVES_ONLY_DIR
- PREPROCESS_FULL_EXPANSION_DIR
- PREPROCESS_SYM
- RELEASE_BASE_PATH
- RELEASE_ROOT_NAME
- RELEASE_SYM
- RELEASE_TASK_ROOT
- RUNNER_BUILD_CMDLINE_ARGS_DEFINE
- STDERR_STARTUP_NONBLOCKING_MODE
- STDIN_STARTUP_NONBLOCKING_MODE
- STDOUT_STARTUP_NONBLOCKING_MODE
- TESTS_BASE_PATH
- TEST_ROOT_NAME
- TEST_SYM
- TEST_TASK_ROOT
- UNITY_C_FILE
- UNITY_H_FILE
- UNITY_INTERNALS_H_FILE
- UNITY_LIB_PATH
- UNITY_ROOT_PATH
- UNITY_SYM
- UNITY_TEST_RESULTS_TEMPLATE
-
Ruby Here
- UTILS_ROOT_NAME
- UTILS_SYM
- UTILS_TASK_ROOT
- VENDORS_FILES
- VERBOSITY_OPTIONS
Public Instance Methods
Source
# File lib/ceedling/file_path_utils.rb, line 15 def ceedling_form_filepath(destination_path, original_filepath, new_extension=nil) filename = File.basename(original_filepath) filename.replace(filename.ext(new_extension)) if (!new_extension.nil?) return File.join( destination_path.gsub(/\\/, '/'), filename ) end
global utility methods (for plugins, project files, etc.)
Source
# File lib/ceedling/system_utils.rb, line 9 def deep_clone Marshal::load(Marshal.dump(self)) end
Source
# File lib/ceedling/tool_executor.rb, line 171 def dehashify_argument_elements(tool_name, hash) build_string = '' elements = [] # grab the substitution string (hash key) substitution = hash.keys[0].to_s # grab the string(s) to squirt into the substitution string (hash value) expand = hash[hash.keys[0]] if (expand.nil?) error = "Tool '#{tool_name}' could not expand nil elements for substitution string '#{substitution}'." raise CeedlingException.new( error ) end # array-ify expansion input if only a single string expansion = ((expand.class == String) ? [expand] : expand) expansion.each do |item| # String eval substitution if (item =~ PATTERNS::RUBY_STRING_REPLACEMENT) elements << @system_wrapper.module_eval(item) # Global constants elsif (@system_wrapper.constants_include?(item)) const = Object.const_get(item) if (const.nil?) error = "Tool '#{tool_name}' found constant '#{item}' to be nil." raise CeedlingException.new( error ) else elements << const end elsif (item.class == Array) elements << item elsif (item.class == String) error = "Tool '#{tool_name}' cannot expand nonexistent value '#{item}' for substitution string '#{substitution}'." raise CeedlingException.new( error ) else error = "Tool '#{tool_name}' cannot expand value having type '#{item.class}' for substitution string '#{substitution}'." raise CeedlingException.new( error ) end end # expand elements (whether string or array) into substitution string & replace escaped '\$' elements.flatten! elements.each do |element| build_string.concat( substitution.sub(/([^\\]*)\$/, "\\1#{element}") ) # don't replace escaped '\$' but allow us to replace just a lonesome '$' build_string.gsub!(/\\\$/, '$') build_string.concat(' ') end return build_string.strip end
handle argument hash: keys are substitution strings, values are data to be expanded within substitution strings
Source
# File lib/ceedling/plugin_manager.rb, line 118 def execute_plugins(method, *args) @plugin_objects.each do |plugin| begin if plugin.respond_to?(method) message = @reportinator.generate_progress( "Plugin | #{camelize( plugin.name )} > :#{method}" ) @loginator.log( message, Verbosity::OBNOXIOUS ) plugin.send(method, *args) end rescue @loginator.log( "Exception raised in plugin `#{plugin.name}` within build hook :#{method}", Verbosity::ERRORS ) raise # Raise again for backtrace, etc. end end end
Source
# File lib/ceedling/tool_executor.rb, line 131 def expandify_element(tool_name, element, *args) match = // to_process = nil args_index = 0 # handle ${#} input replacement if (element =~ PATTERNS::TOOL_EXECUTOR_ARGUMENT_REPLACEMENT) args_index = ($2.to_i - 1) if (args.nil? or args[args_index].nil?) error = "Tool '#{tool_name}' expected valid argument data to accompany replacement operator #{$1}." raise CeedlingException.new( error ) end match = /#{Regexp.escape($1)}/ to_process = args[args_index] end # simple string argument: replace escaped '\$' and strip element.sub!(/\\\$/, '$') element.strip! build_string = '' # handle array or anything else passed into method to be expanded in place of replacement operators case (to_process) when Array then to_process.each {|value| build_string.concat( "#{element.sub(match, value.to_s)} " ) } if (to_process.size > 0) else build_string.concat( element.sub(match, to_process.to_s) ) end # handle inline ruby string substitution if (build_string =~ PATTERNS::RUBY_STRING_REPLACEMENT) build_string.replace(@system_wrapper.module_eval(build_string)) end return build_string.strip end
handle simple text string argument & argument array string replacement operators
Source
# File vendor/cmock/lib/cmock.rb, line 53 def generate_skeleton(src) name = File.basename(src, '.*') puts "Creating skeleton for #{name}..." unless @silent @cm_generator.create_skeleton(name, @cm_parser.parse(name, File.read(src))) end
Source
# File vendor/cmock/lib/cmock_unityhelper_parser.rb, line 54 def import_source source = @config.load_unity_helper return {} if source.nil? c_types = {} source = source.gsub(/\/\/.*$/, '') # remove line comments source = source.gsub(/\/\*.*?\*\//m, '') # remove block comments # scan for comparison helpers match_regex = Regexp.new("^\\s*#define\\s+(UNITY_TEST_ASSERT_EQUAL_(\\w+))\\s*\\(#{Array.new(4, '\s*\w+\s*').join(',')}\\)") pairs = source.scan(match_regex).flatten.compact (pairs.size / 2).times do |i| expect = pairs[i * 2] ctype = pairs[(i * 2) + 1] c_types[ctype] = expect unless expect.include?('_ARRAY') end # scan for array variants of those helpers match_regex = Regexp.new("^\\s*#define\\s+(UNITY_TEST_ASSERT_EQUAL_(\\w+_ARRAY))\\s*\\(#{Array.new(5, '\s*\w+\s*').join(',')}\\)") pairs = source.scan(match_regex).flatten.compact (pairs.size / 2).times do |i| expect = pairs[i * 2] ctype = pairs[(i * 2) + 1] c_types[ctype.gsub('_ARRAY', '*')] = expect end c_types end
Source
# File lib/ceedling/rakefile.rb, line 23 def log_runtime(run, start_time_s, end_time_s, enabled) return if !enabled return if !defined?(PROJECT_VERBOSITY) return if (PROJECT_VERBOSITY < Verbosity::NORMAL) duration = Reportinator.generate_duration( start_time_s: start_time_s, end_time_s: end_time_s ) return if duration.empty? @ceedling[:loginator].log() # Blank line @ceedling[:loginator].log( "Ceedling #{run} completed in #{duration}", Verbosity::NORMAL) end
Operation duration logging
Source
# File lib/ceedling/tool_executor.rb, line 223 def pretty_tool_name(command) # Titleize command's name -- each word capitalized plus underscores replaced with spaces name = "#{command[:name].split(/ |\_/).map(&:capitalize).join(" ")}" executable = command[:executable].empty? ? '<no executable>' : command[:executable] # 'Name' (executable) return "'#{name}' " + "(#{executable})" end
Source
# File lib/ceedling/rakefile.rb, line 102 def test_failures_handler() # $stdout test reporting plugins store test failures exit(1) if @ceedling[:plugin_manager].plugins_failed? && !CEEDLING_APPCFG.tests_graceful_fail? end