From 621536d20654307467a6d942051a7f11df073a60 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Sat, 13 Apr 2024 17:02:03 -0400 Subject: [PATCH] start refactoring to use streaminator for all, and to remove decorators except when legal. --- bin/cli.rb | 2 +- bin/cli_handler.rb | 38 ++++++++++++-------------- bin/cli_helper.rb | 22 +++++++-------- bin/configinator.rb | 8 +++--- bin/logger.rb | 12 -------- bin/main.rb | 2 +- bin/mixinator.rb | 6 ++-- bin/objects.yml | 38 ++++++++++++++++++++------ bin/path_validator.rb | 8 +++--- bin/projectinator.rb | 23 ++++++++-------- lib/ceedling/config_matchinator.rb | 12 ++++---- lib/ceedling/constants.rb | 13 +++++---- lib/ceedling/rakefile.rb | 8 +++--- lib/ceedling/reportinator.rb | 2 +- lib/ceedling/streaminator.rb | 25 +++++++++++++++++ lib/ceedling/tasks_release.rake | 2 +- lib/ceedling/test_invoker.rb | 2 +- lib/ceedling/test_invoker_helper.rb | 2 +- lib/ceedling/tool_validator.rb | 6 ++-- lib/ceedling/unity_utils.rb | 2 +- plugins/beep/lib/beep.rb | 4 +-- plugins/gcov/lib/gcov.rb | 2 +- plugins/gcov/lib/gcovr_reportinator.rb | 4 +-- spec/spec_system_helper.rb | 2 +- 24 files changed, 138 insertions(+), 107 deletions(-) delete mode 100755 bin/logger.rb diff --git a/bin/cli.rb b/bin/cli.rb index c7fadcf6..dfc56da0 100755 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -254,7 +254,7 @@ def upgrade(path) \x5 > ceedling build test:all TASKS are zero or more build operations created from your project configuration. - If no tasks are provided, the built-in default tasks or your :project ā†³ + If no tasks are provided, the built-in default tasks or your :project -> :default_tasks will be executed. Optional Flags: diff --git a/bin/cli_handler.rb b/bin/cli_handler.rb index 5213c9d1..0a876af9 100755 --- a/bin/cli_handler.rb +++ b/bin/cli_handler.rb @@ -2,7 +2,7 @@ class CliHandler - constructor :configinator, :projectinator, :cli_helper, :path_validator, :actions_wrapper, :logger + constructor :configinator, :projectinator, :cli_helper, :path_validator, :actions_wrapper, :streaminator # Override to prevent exception handling from walking & stringifying the object variables. # Object variables are lengthy and produce a flood of output. @@ -24,13 +24,13 @@ def app_help(env, app_cfg, options, command, &thor_help) # If help requested for a command, show it and skip listing build tasks if !command.nil? # Block handler - @logger._print( 'šŸŒ± Application ' ) + @streaminator.stdout_puts( 'Application ', Verbosity::TITLE ) thor_help.call( command ) if block_given? return end # Display Thor-generated help listing - @logger._print( 'šŸŒ± Application ' ) + @streaminator.stdout_puts( 'Application ', Verbosity::TITLE ) thor_help.call( command ) if block_given? # If it was help for a specific command, we're done @@ -90,7 +90,7 @@ def new_project(ceedling_root, options, name, dest) @actions._touch_file( File.join(dest, 'test/support', '.gitkeep') ) end - @logger.log( "\nšŸŒ± New project '#{name}' created at #{dest}/\n" ) + @streaminator.stdout_puts( "\nNew project '#{name}' created at #{dest}/\n", Verbosity::TITLE ) end @@ -104,7 +104,7 @@ def upgrade_project(ceedling_root, options, path) end project_filepath = File.join( path, options[:project] ) - _, config = @projectinator.load( filepath:project_filepath, silent:true ) + _, config = @projectinator.load( filepath:project_filepath ) if (@helper.which_ceedling?( config ) == 'gem') msg = "Project configuration specifies the Ceedling gem, not vendored Ceedling" @@ -124,7 +124,7 @@ def upgrade_project(ceedling_root, options, path) @helper.copy_docs( ceedling_root, path ) end - @logger.log( "\nšŸŒ± Upgraded project at #{path}/\n" ) + @streaminator.stdout_puts( "\nUpgraded project at #{path}/\n", Verbosity::TITLE ) end @@ -200,11 +200,11 @@ def dumpconfig(env, app_cfg, options, filepath, sections) default_tasks: default_tasks ) else - @logger.log( " > Skipped loading Ceedling application" ) + @streaminator.stdout_puts( " > Skipped loading Ceedling application", Verbosity::OBNOXIOUS ) end ensure @helper.dump_yaml( config, filepath, sections ) - @logger.log( "\nšŸŒ± Dumped project configuration to #{filepath}\n" ) + @streaminator.stdout_puts( "\nDumped project configuration to #{filepath}\n", Verbosity::TITLE ) end end @@ -242,13 +242,13 @@ def environment(env, app_cfg, options) end end - output = "\nšŸŒ± Environment variables:\n" + output = "\nEnvironment variables:\n" env_list.sort.each do |line| output << " ā€¢ #{line}\n" end - @logger.log( output + "\n") + @streaminator.stdout_puts( output + "\n" ) end @@ -257,11 +257,11 @@ def list_examples(examples_path) raise( "No examples projects found") if examples.empty? - output = "\nšŸŒ± Available example projects:\n" + output = "\nAvailable example projects:\n" examples.each {|example| output << " ā€¢ #{example}\n" } - @logger.log( output + "\n" ) + @streaminator.stdout_puts( output + "\n" ) end @@ -294,19 +294,19 @@ def create_example(ceedling_root, examples_path, options, name, dest) # Copy in documentation @helper.copy_docs( ceedling_root, dest ) if options[:docs] - @logger.log( "\nšŸŒ± Example project '#{name}' created at #{dest}/\n" ) + @streaminator.stdout_puts( "\nExample project '#{name}' created at #{dest}/\n", Verbosity::TITLE ) end def version() require 'ceedling/version' version = <<~VERSION - šŸŒ± Ceedling => #{Ceedling::Version::CEEDLING} + Ceedling => #{Ceedling::Version::CEEDLING} CMock => #{Ceedling::Version::CMOCK} Unity => #{Ceedling::Version::UNITY} CException => #{Ceedling::Version::CEXCEPTION} VERSION - @logger.log( version ) + @streaminator.stdout_puts( version ) end @@ -319,21 +319,19 @@ def list_rake_tasks(env:, app_cfg:, filepath:nil, mixins:[]) @configinator.loadinate( filepath: filepath, mixins: mixins, - env: env, - silent: true # Suppress project config load logging + env: env ) # Save reference to loaded configuration app_cfg[:project_config] = config - @logger.log( "šŸŒ± Build & Plugin Tasks:\n(Parameterized tasks tend to require enclosing quotes and/or escape sequences in most shells)" ) + @streaminator.stdout_puts( "Build & Plugin Tasks:\n(Parameterized tasks tend to require enclosing quotes and/or escape sequences in most shells)", Verbosity::TITLE ) @helper.load_ceedling( project_filepath: project_filepath, config: config, which: app_cfg[:which_ceedling], - default_tasks: app_cfg[:default_tasks], - silent: true + default_tasks: app_cfg[:default_tasks] ) @helper.print_rake_tasks() diff --git a/bin/cli_helper.rb b/bin/cli_helper.rb index e064a76c..f34dd5f0 100755 --- a/bin/cli_helper.rb +++ b/bin/cli_helper.rb @@ -3,7 +3,7 @@ class CliHelper - constructor :file_wrapper, :actions_wrapper, :config_walkinator, :path_validator, :logger + constructor :file_wrapper, :actions_wrapper, :config_walkinator, :path_validator, :streaminator def setup #Aliases @@ -47,10 +47,10 @@ def which_ceedling?(config) end - def load_ceedling(project_filepath:, config:, which:, default_tasks:[], silent:false) + def load_ceedling(project_filepath:, config:, which:, default_tasks:[]) # Determine which Ceedling we're running # 1. Copy the which value passed in (most likely a default determined in the first moments of startup) - # 2. If a :project ā†³ :which_ceedling entry exists in the config, use it instead + # 2. If a :project -> :which_ceedling entry exists in the config, use it instead _which = which.dup() walked = @config_walkinator.fetch_value( config, :project, :which_ceedling ) _which = walked[:value] if !walked[:value].nil? @@ -70,18 +70,18 @@ def load_ceedling(project_filepath:, config:, which:, default_tasks:[], silent:f ceedling_path = File.expand_path( ceedling_path ) if !@file_wrapper.directory?( ceedling_path ) - raise "Configuration value :project ā†³ :which_ceedling => '#{_which}' points to a path relative to your project file that contains no Ceedling installation" + raise "Configuration value :project -> :which_ceedling => '#{_which}' points to a path relative to your project file that contains no Ceedling installation" end # Otherwise, :which_ceedling is an absolute path else if !@file_wrapper.exist?( ceedling_path ) - raise "Configuration value :project ā†³ :which_ceedling => '#{_which}' points to a path that contains no Ceedling installation" + raise "Configuration value :project -> :which_ceedling => '#{_which}' points to a path that contains no Ceedling installation" end end require( File.join( ceedling_path, '/lib/ceedling.rb' ) ) - @logger.log( " > Running Ceedling from #{ceedling_path}/" ) if !silent + @streaminator.stdout_puts( " > Running Ceedling from #{ceedling_path}/", Verbosity::OBNOXIOUS ) end # Set default tasks @@ -216,7 +216,7 @@ def dump_yaml(config, filepath, sections) if walked[:value].nil? # Reformat list of symbols to list of :
s _sections.map! {|section| ":#{section.to_s}"} - msg = "Cound not find configuration section #{_sections.join(' ā†³ ')}" + msg = "Cound not find configuration section #{_sections.join(' -> ')}" raise(msg) end @@ -396,9 +396,9 @@ def vendor_tools(ceedling_root, dest) private -def windows? - return ((RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false) if defined?( RbConfig ) - return ((Config::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false) -end + def windows? + return ((RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false) if defined?( RbConfig ) + return ((Config::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false) + end end diff --git a/bin/configinator.rb b/bin/configinator.rb index 54d01e8f..597ffd03 100755 --- a/bin/configinator.rb +++ b/bin/configinator.rb @@ -6,13 +6,13 @@ class Configinator constructor :config_walkinator, :projectinator, :mixinator - def loadinate(filepath:nil, mixins:[], env:{}, silent:false) + def loadinate(filepath:nil, mixins:[], env:{}) # Aliases for clarity cmdline_filepath = filepath cmdline_mixins = mixins || [] # Load raw config from command line, environment variable, or default filepath - project_filepath, config = @projectinator.load( filepath:cmdline_filepath, env:env, silent:silent ) + project_filepath, config = @projectinator.load( filepath:cmdline_filepath, env:env ) # Extract cfg_enabled_mixins mixins list plus load paths list from config cfg_enabled_mixins, cfg_load_paths = @projectinator.extract_mixins( @@ -36,7 +36,7 @@ def loadinate(filepath:nil, mixins:[], env:{}, silent:false) if not @projectinator.validate_mixins( mixins: cfg_enabled_mixins, load_paths: cfg_load_paths, - source: 'Config :mixins ā†³ :enabled =>', + source: 'Config :mixins -> :enabled =>', yaml_extension: yaml_ext ) raise 'Project configuration file section :mixins failed validation' @@ -82,7 +82,7 @@ def loadinate(filepath:nil, mixins:[], env:{}, silent:false) ) # Merge mixins - @mixinator.merge( config:config, mixins:mixins_assembled, silent:silent ) + @mixinator.merge( config:config, mixins:mixins_assembled ) return project_filepath, config end diff --git a/bin/logger.rb b/bin/logger.rb deleted file mode 100755 index 6749c6a5..00000000 --- a/bin/logger.rb +++ /dev/null @@ -1,12 +0,0 @@ - -class Logger - - def _print(str) - print( str ) - end - - def log(str) - puts( str ) - end - -end \ No newline at end of file diff --git a/bin/main.rb b/bin/main.rb index 0a2193e1..27b70cf9 100755 --- a/bin/main.rb +++ b/bin/main.rb @@ -64,7 +64,7 @@ # Bootloader boom handling rescue StandardError => e - $stderr.puts( "\nšŸŒ± ERROR: #{e.message}" ) + $stderr.puts( "\nERROR: #{e.message}" ) $stderr.puts( e.backtrace ) if ( defined?( PROJECT_DEBUG ) and PROJECT_DEBUG ) exit(1) end diff --git a/bin/mixinator.rb b/bin/mixinator.rb index cd39063b..c197a45a 100755 --- a/bin/mixinator.rb +++ b/bin/mixinator.rb @@ -2,7 +2,7 @@ class Mixinator - constructor :path_validator, :yaml_wrapper, :logger + constructor :path_validator, :yaml_wrapper, :streaminator def setup # ... @@ -80,7 +80,7 @@ def assemble_mixins(config:, env:, cmdline:) return assembly end - def merge(config:, mixins:, silent:) + def merge(config:, mixins:) mixins.each do |mixin| source = mixin.keys.first filepath = mixin.values.first @@ -97,7 +97,7 @@ def merge(config:, mixins:, silent:) config.deep_merge( _mixin ) # Log what filepath we used for this mixin - @logger.log( " + Merged #{'(empty) ' if _mixin.empty?}#{source} mixin using #{filepath}" ) if !silent + @streaminator.stdout_puts( " + Merged #{'(empty) ' if _mixin.empty?}#{source} mixin using #{filepath}", Verbosity::DEBUG ) end # Validate final configuration diff --git a/bin/objects.yml b/bin/objects.yml index 78664b4b..966d7f6b 100755 --- a/bin/objects.yml +++ b/bin/objects.yml @@ -2,15 +2,33 @@ # Loaded from ceedling/lib file_wrapper: -# Loaded from ceedling/lib yaml_wrapper: -# Loaded from ceedling/lib config_walkinator: -actions_wrapper: +stream_wrapper: + +system_wrapper: -logger: +verbosinator: + +streaminator_helper: + +loginator: + compose: + - file_wrapper + - system_wrapper + +streaminator: + compose: + - streaminator_helper + - verbosinator + - loginator + - stream_wrapper + +# Loaded from bin (here) + +actions_wrapper: # Separation of logic from CLI user interface cli_handler: @@ -20,7 +38,7 @@ cli_handler: - cli_helper - path_validator - actions_wrapper - - logger + - streaminator cli_helper: compose: @@ -28,28 +46,30 @@ cli_helper: - config_walkinator - path_validator - actions_wrapper - - logger + - streaminator path_validator: compose: - file_wrapper - - logger + - streaminator mixinator: compose: - path_validator - yaml_wrapper - - logger + - streaminator projectinator: compose: - file_wrapper - path_validator - yaml_wrapper - - logger + - streaminator configinator: compose: - config_walkinator - projectinator - mixinator + + diff --git a/bin/path_validator.rb b/bin/path_validator.rb index 68a5ec8c..389eaf58 100755 --- a/bin/path_validator.rb +++ b/bin/path_validator.rb @@ -1,7 +1,7 @@ class PathValidator - constructor :file_wrapper, :logger + constructor :file_wrapper, :streaminator def validate(paths:, source:, type: :filepath) validated = true @@ -10,20 +10,20 @@ def validate(paths:, source:, type: :filepath) # Error out on empty paths if path.empty? validated = false - @logger.log( "ERROR: #{source} contains an empty path" ) + @streaminator.stderr_puts( "ERROR: #{source} contains an empty path", Verbosity::ERRORS ) next end # Error out if path is not a directory / does not exist if (type == :directory) and !@file_wrapper.directory?( path ) validated = false - @logger.log( "ERROR: #{source} '#{path}' does not exist as a directory in the filesystem" ) + @streaminator.stderr_puts( "ERROR: #{source} '#{path}' does not exist as a directory in the filesystem", Verbosity::ERRORS ) end # Error out if filepath does not exist if (type == :filepath) and !@file_wrapper.exist?( path ) validated = false - @logger.log( "ERROR: #{source} '#{path}' does not exist in the filesystem" ) + @streaminator.stderr_puts( "ERROR: #{source} '#{path}' does not exist in the filesystem", Verbosity::ERRORS ) end end diff --git a/bin/projectinator.rb b/bin/projectinator.rb index a6b4782b..27c6474c 100755 --- a/bin/projectinator.rb +++ b/bin/projectinator.rb @@ -6,7 +6,7 @@ class Projectinator DEFAULT_PROJECT_FILEPATH = './' + DEFAULT_PROJECT_FILENAME DEFAULT_YAML_FILE_EXTENSION = '.yml' - constructor :file_wrapper, :path_validator, :yaml_wrapper, :logger + constructor :file_wrapper, :path_validator, :yaml_wrapper, :streaminator # Discovers project file path and loads configuration. # Precendence of attempts: @@ -16,10 +16,10 @@ class Projectinator # Returns: # - Absolute path of project file found and used # - Config hash loaded from project file - def load(filepath:nil, env:{}, silent:false) + def load(filepath:nil, env:{}) # Highest priority: command line argument if filepath - config = load_filepath( filepath, 'from command line argument', silent ) + config = load_filepath( filepath, 'from command line argument' ) return File.expand_path( filepath ), config # Next priority: environment variable @@ -28,15 +28,14 @@ def load(filepath:nil, env:{}, silent:false) @path_validator.standardize_paths( filepath ) config = load_filepath( filepath, - "from environment variable `#{PROJECT_FILEPATH_ENV_VAR}`", - silent + "from environment variable `#{PROJECT_FILEPATH_ENV_VAR}`" ) return File.expand_path( filepath ), config # Final option: default filepath elsif @file_wrapper.exist?( DEFAULT_PROJECT_FILEPATH ) filepath = DEFAULT_PROJECT_FILEPATH - config = load_filepath( filepath, "at default location", silent ) + config = load_filepath( filepath, "at default location" ) return File.expand_path( filepath ), config # If no user provided filepath and the default filepath does not exist, @@ -58,7 +57,7 @@ def config_available?(filepath:nil, env:{}) available = true begin - load(filepath:filepath, env:env, silent:true) + load(filepath:filepath, env:env) rescue available = false end @@ -110,7 +109,7 @@ def extract_mixins(config:, mixins_base_path:) def validate_mixin_load_paths(load_paths) validated = @path_validator.validate( paths: load_paths, - source: 'Config :mixins ā†³ :load_paths', + source: 'Config :mixins -> :load_paths', type: :directory ) @@ -128,7 +127,7 @@ def validate_mixins(mixins:, load_paths:, source:, yaml_extension:) # Validate mixin filepaths if !File.extname( mixin ).empty? or mixin.include?( File::SEPARATOR ) if !@file_wrapper.exist?( mixin ) - @logger.log( "ERROR: Cannot find mixin at #{mixin}" ) + @streaminator.stderr_puts( "ERROR: Cannot find mixin at #{mixin}" ) validated = false end @@ -143,7 +142,7 @@ def validate_mixins(mixins:, load_paths:, source:, yaml_extension:) end if !found - @logger.log( "ERROR: #{source} '#{mixin}' cannot be found in the mixin load paths as '#{mixin + yaml_extension}'" ) + @streaminator.stderr_puts( "ERROR: #{source} '#{mixin}' cannot be found in the mixin load paths as '#{mixin + yaml_extension}'", Verbosity::ERRORS ) validated = false end end @@ -183,7 +182,7 @@ def lookup_mixins(mixins:, load_paths:, yaml_extension:) private - def load_filepath(filepath, method, silent) + def load_filepath(filepath, method) begin # Load the filepath we settled on as our project configuration config = @yaml_wrapper.load( filepath ) @@ -193,7 +192,7 @@ def load_filepath(filepath, method, silent) config = {} if config.nil? # Log what the heck we loaded - @logger.log( "šŸŒ± Loaded #{'(empty) ' if config.empty?}project configuration #{method} using #{filepath}" ) if !silent + @streaminator.stderr_puts( "Loaded #{'(empty) ' if config.empty?}project configuration #{method} using #{filepath}", Verbosity::DEBUG ) return config rescue Errno::ENOENT diff --git a/lib/ceedling/config_matchinator.rb b/lib/ceedling/config_matchinator.rb index b0b3b22e..e2a00b09 100644 --- a/lib/ceedling/config_matchinator.rb +++ b/lib/ceedling/config_matchinator.rb @@ -55,7 +55,7 @@ def get_config(primary:, secondary:, tertiary:nil) return elem if tertiary.nil? # Otherwise, if an tertiary is specified but we have an array, go boom - error = "ERROR: :#{primary} ā†³ :#{secondary} present in project configuration but does not contain :#{tertiary}." + error = "ERROR: :#{primary} -> :#{secondary} present in project configuration but does not contain :#{tertiary}." raise CeedlingException.new(error) # If [primary][secondary] is a hash @@ -74,7 +74,7 @@ def get_config(primary:, secondary:, tertiary:nil) # If [primary][secondary] is nothing we expect--something other than an array or hash else - error = "ERROR: :#{primary} ā†³ :#{secondary} in project configuration is neither a list nor hash." + error = "ERROR: :#{primary} -> :#{secondary} in project configuration is neither a list nor hash." raise CeedlingException.new(error) end @@ -86,7 +86,7 @@ def validate_matchers(hash:, section:, context:, operation:nil) hash.each do |k, v| if v == nil path = generate_matcher_path(section, context, operation) - error = "ERROR: Missing list of values for [#{path} ā†³ '#{k}' matcher in project configuration." + error = "ERROR: Missing list of values for [#{path} -> '#{k}' matcher in project configuration." raise CeedlingException.new(error) end end @@ -99,7 +99,7 @@ def matches?(hash:, filepath:, section:, context:, operation:nil) # Sanity check if filepath.nil? path = generate_matcher_path(section, context, operation) - error = "ERROR: #{path} ā†³ #{matcher} matching provided nil #{filepath}" + error = "ERROR: #{path} -> #{matcher} matching provided nil #{filepath}" raise CeedlingException.new(error) end @@ -146,7 +146,7 @@ def matches?(hash:, filepath:, section:, context:, operation:nil) matched_notice(section:section, context:context, operation:operation, matcher:_matcher, filepath:filepath) else # No match path = generate_matcher_path(section, context, operation) - @streaminator.stderr_puts("#{path} ā†³ `#{matcher}` did not match #{filepath}", Verbosity::DEBUG) + @streaminator.stderr_puts("#{path} -> `#{matcher}` did not match #{filepath}", Verbosity::DEBUG) end end @@ -159,7 +159,7 @@ def matches?(hash:, filepath:, section:, context:, operation:nil) def matched_notice(section:, context:, operation:, matcher:, filepath:) path = generate_matcher_path(section, context, operation) - @streaminator.stdout_puts("#{path} ā†³ #{matcher} matched #{filepath}", Verbosity::OBNOXIOUS) + @streaminator.stdout_puts("#{path} -> #{matcher} matched #{filepath}", Verbosity::OBNOXIOUS) end def generate_matcher_path(*keys) diff --git a/lib/ceedling/constants.rb b/lib/ceedling/constants.rb index ab525d6b..9d823b4b 100644 --- a/lib/ceedling/constants.rb +++ b/lib/ceedling/constants.rb @@ -1,11 +1,12 @@ class Verbosity - SILENT = 0 # as silent as possible (though there are some messages that must be spit out) - ERRORS = 1 # only errors - COMPLAIN = 2 # spit out errors and warnings/notices - NORMAL = 3 # errors, warnings/notices, standard status messages - OBNOXIOUS = 4 # all messages including extra verbose output (used for lite debugging / verification) - DEBUG = 5 # special extra verbose output for hardcore debugging + SILENT = 0 # as silent as possible (though there are some messages that must be spit out) + ERRORS = 1 # only errors + COMPLAIN = 2 # spit out errors and warnings/notices + TITLE = 2.5 # just like NORMAL below, except extra decoration + NORMAL = 3 # errors, warnings/notices, standard status messages + OBNOXIOUS = 4 # all messages including extra verbose output (used for lite debugging / verification) + DEBUG = 5 # special extra verbose output for hardcore debugging end VERBOSITY_OPTIONS = { diff --git a/lib/ceedling/rakefile.rb b/lib/ceedling/rakefile.rb index 27aa5d7e..71f2ece2 100644 --- a/lib/ceedling/rakefile.rb +++ b/lib/ceedling/rakefile.rb @@ -15,18 +15,18 @@ def log_runtime(run, start_time_s, end_time_s, enabled) return if !enabled return if !defined?(PROJECT_VERBOSITY) - return if (PROJECT_VERBOSITY < Verbosity::ERRORS) + 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? - puts( "\nšŸŒ± Ceedling #{run} completed in #{duration}" ) + @ceedling[:streaminator].stdout_puts( "\nCeedling #{run} completed in #{duration}", Verbosity::TITLE ) end # Centralized last resort, outer exception handling def boom_handler(exception:, debug:) - $stderr.puts("šŸŒ± #{exception.class} ==> #{exception.message}") + $stderr.puts("#{exception.class} ==> #{exception.message}") if debug $stderr.puts("Backtrace ==>") $stderr.puts(exception.backtrace) @@ -122,7 +122,7 @@ def test_failures_handler() exit(0) else - puts("\nšŸŒ± Ceedling could not complete operations because of errors.") + @ceedling[:streaminator].stdout_puts("\nCeedling could not complete operations because of errors.", Verbosity::ERRORS) begin @ceedling[:plugin_manager].post_error rescue => ex diff --git a/lib/ceedling/reportinator.rb b/lib/ceedling/reportinator.rb index 9bafaed4..a24c5ba3 100644 --- a/lib/ceedling/reportinator.rb +++ b/lib/ceedling/reportinator.rb @@ -109,7 +109,7 @@ def generate_config_walk(keys, depth=0) _keys = keys.clone _keys = _keys.slice(0, depth) if depth > 0 _keys.reject! { |key| key.nil? } - return _keys.map{|key| ":#{key}"}.join(' ā†³ ') + return _keys.map{|key| ":#{key}"}.join(' -> ') end end diff --git a/lib/ceedling/streaminator.rb b/lib/ceedling/streaminator.rb index 11ed109c..09b64546 100644 --- a/lib/ceedling/streaminator.rb +++ b/lib/ceedling/streaminator.rb @@ -9,6 +9,13 @@ class Streaminator def stdout_puts(string, verbosity=Verbosity::NORMAL) if (@verbosinator.should_output?(verbosity)) + if (decorate) + if (verbosity == Verbosity::TITLE) + string.sub!(/^\n?/, "\nšŸŒ± ") + elsif (verbosity == Verbosity::ERRORS) + string.sub!(/^\n?/, "\nšŸŖ² ") + end + end @stream_wrapper.stdout_puts(string) end @@ -18,6 +25,13 @@ def stdout_puts(string, verbosity=Verbosity::NORMAL) def stderr_puts(string, verbosity=Verbosity::NORMAL) if (@verbosinator.should_output?(verbosity)) + if (decorate) + if (verbosity == Verbosity::TITLE) + string.sub!(/^\n?/, "\nšŸŒ± ") + elsif (verbosity == Verbosity::ERRORS) + string.sub!(/^\n?/, "\nšŸŖ² ") + end + end @stream_wrapper.stderr_puts(string) end @@ -27,6 +41,13 @@ def stderr_puts(string, verbosity=Verbosity::NORMAL) def stream_puts(stream, string, verbosity=Verbosity::NORMAL) if (@verbosinator.should_output?(verbosity)) + if (decorate) + if (verbosity == Verbosity::TITLE) + string.sub!(/^\n?/, "\nšŸŒ± ") + elsif (verbosity == Verbosity::ERRORS) + string.sub!(/^\n?/, "\nšŸŖ² ") + end + end stream.puts(string) end @@ -34,4 +55,8 @@ def stream_puts(stream, string, verbosity=Verbosity::NORMAL) @loginator.log( string, @streaminator_helper.extract_name(stream) ) end + def decorate + true #TODO LOGIC HERE + end + end diff --git a/lib/ceedling/tasks_release.rake b/lib/ceedling/tasks_release.rake index 5288c059..0e0ba116 100644 --- a/lib/ceedling/tasks_release.rake +++ b/lib/ceedling/tasks_release.rake @@ -23,7 +23,7 @@ task RELEASE_SYM => [:prepare] do rescue StandardError => e @ceedling[:application].register_build_failure - @ceedling[:streaminator].stderr_puts(šŸŒ± "#{e.class} ==> #{e.message}", Verbosity::ERRORS) + @ceedling[:streaminator].stderr_puts("#{e.class} ==> #{e.message}", Verbosity::ERRORS) # Debug backtrace @ceedling[:streaminator].stderr_puts("Backtrace ==>", Verbosity::DEBUG) diff --git a/lib/ceedling/test_invoker.rb b/lib/ceedling/test_invoker.rb index 9838482b..ceec6a90 100644 --- a/lib/ceedling/test_invoker.rb +++ b/lib/ceedling/test_invoker.rb @@ -350,7 +350,7 @@ def setup_and_invoke(tests:, context:TEST_SYM, options:{}) # Runtime errors (parent is Exception) continue on up to be caught by Ruby itself. rescue StandardError => e @application.register_build_failure - @streaminator.stderr_puts("šŸŒ± #{e.class} ==> #{e.message}", Verbosity::ERRORS) + @streaminator.stderr_puts("#{e.class} ==> #{e.message}", Verbosity::ERRORS) # Debug backtrace @streaminator.stderr_puts("Backtrace ==>", Verbosity::DEBUG) diff --git a/lib/ceedling/test_invoker_helper.rb b/lib/ceedling/test_invoker_helper.rb index 6d741fae..94274f11 100644 --- a/lib/ceedling/test_invoker_helper.rb +++ b/lib/ceedling/test_invoker_helper.rb @@ -287,7 +287,7 @@ def generate_executable_now(context:, build_path:, executable:, objects:, flags: notice += "\n" notice += "OPTIONS:\n" + " 1. Doublecheck this test's #include statements.\n" + - " 2. Simplify complex macros or fully specify symbols for this test in :project ā†³ :defines.\n" + + " 2. Simplify complex macros or fully specify symbols for this test in :project -> :defines.\n" + " 3. If no header file corresponds to the needed source file, use the #{UNITY_TEST_SOURCE_FILE}()\n" + " build diective macro in this test to inject a source file into the build.\n\n" + "See the docs on conventions, paths, preprocessing, compilation symbols, and build directive macros.\n\n" diff --git a/lib/ceedling/tool_validator.rb b/lib/ceedling/tool_validator.rb index e1bcc6b1..3476a813 100644 --- a/lib/ceedling/tool_validator.rb +++ b/lib/ceedling/tool_validator.rb @@ -94,7 +94,7 @@ def validate_executable(tool:, name:, extension:, respect_optional:, boom:) end if !exists - error = "#{name} ā†³ :executable => `#{executable}` " + error + error = "#{name} -> :executable => `#{executable}` " + error end # Raise exception if executable can't be found and boom is set @@ -117,7 +117,7 @@ def validate_stderr_redirect(tool:, name:, boom:) if redirect.class == Symbol if not StdErrRedirect.constants.map{|constant| constant.to_s}.include?( redirect.to_s.upcase ) options = StdErrRedirect.constants.map{|constant| ':' + constant.to_s.downcase}.join(', ') - error = "#{name} ā†³ :stderr_redirect => :#{redirect} is not a recognized option {#{options}}." + error = "#{name} -> :stderr_redirect => :#{redirect} is not a recognized option {#{options}}." # Raise exception if requested raise CeedlingException.new( error ) if boom @@ -127,7 +127,7 @@ def validate_stderr_redirect(tool:, name:, boom:) return false end elsif redirect.class != String - raise CeedlingException.new( "#{name} ā†³ :stderr_redirect is neither a recognized value nor custom string." ) + raise CeedlingException.new( "#{name} -> :stderr_redirect is neither a recognized value nor custom string." ) end return true diff --git a/lib/ceedling/unity_utils.rb b/lib/ceedling/unity_utils.rb index 4945b1af..b879be04 100644 --- a/lib/ceedling/unity_utils.rb +++ b/lib/ceedling/unity_utils.rb @@ -102,7 +102,7 @@ def test_runner_cmdline_args_configured?() if test_case_filters and !cmdline_args # Blow up if filters are in use but test runner command line arguments are not enabled msg = 'Unity test case filters cannot be used as configured. ' + - 'Enable :test_runner ā†³ :cmdline_args in your project configuration.' + 'Enable :test_runner -> :cmdline_args in your project configuration.' raise CeedlingException.new( msg ) end diff --git a/plugins/beep/lib/beep.rb b/plugins/beep/lib/beep.rb index 4aa76c9a..64e89a7c 100755 --- a/plugins/beep/lib/beep.rb +++ b/plugins/beep/lib/beep.rb @@ -25,13 +25,13 @@ def setup # Ensure configuration option is an actual tool if @tools[:beep_on_done].nil? - error = "Option :#{beep_config[:on_done]} for :beep ā†³ :on_done plugin configuration does not map to a tool." + error = "Option :#{beep_config[:on_done]} for :beep -> :on_done plugin configuration does not map to a tool." raise CeedlingException.new( error ) end # Ensure configuration option is an actual tool if @tools[:beep_on_error].nil? - error = "Option :#{beep_config[:on_done]} for :beep ā†³ :on_error plugin configuration does not map to a tool." + error = "Option :#{beep_config[:on_done]} for :beep -> :on_error plugin configuration does not map to a tool." raise CeedlingException.new( error ) end diff --git a/plugins/gcov/lib/gcov.rb b/plugins/gcov/lib/gcov.rb index ae888ec0..1e108cd4 100755 --- a/plugins/gcov/lib/gcov.rb +++ b/plugins/gcov/lib/gcov.rb @@ -231,7 +231,7 @@ def build_reportinators(config, enabled) config.each do |reportinator| if not GCOV_UTILITY_NAMES.map(&:upcase).include?( reportinator.upcase ) options = GCOV_UTILITY_NAMES.map{ |utility| "'#{utility}'" }.join(', ') - msg = "Plugin configuration :gcov ā†³ :utilities => `#{reportinator}` is not a recognized option {#{options}}." + msg = "Plugin configuration :gcov -> :utilities => `#{reportinator}` is not a recognized option {#{options}}." raise CeedlingException.new(msg) end end diff --git a/plugins/gcov/lib/gcovr_reportinator.rb b/plugins/gcov/lib/gcovr_reportinator.rb index 43e2331f..96798a36 100644 --- a/plugins/gcov/lib/gcovr_reportinator.rb +++ b/plugins/gcov/lib/gcovr_reportinator.rb @@ -151,9 +151,9 @@ def args_builder_common(gcovr_opts) # Value sanity checks for :fail_under_* settings if opt.to_s =~ /fail_/ if not value.is_a? Integer - raise CeedlingException.new(":gcov ā†³ :gcovr ā†³ :#{opt} => '#{value}' must be an integer") + raise CeedlingException.new(":gcov -> :gcovr -> :#{opt} => '#{value}' must be an integer") elsif (value < 0) || (value > 100) - raise CeedlingException.new(":gcov ā†³ :gcovr ā†³ :#{opt} => '#{value}' must be an integer percentage 0 ā€“ 100") + raise CeedlingException.new(":gcov -> :gcovr -> :#{opt} => '#{value}' must be an integer percentage 0 ā€“ 100") end end diff --git a/spec/spec_system_helper.rb b/spec/spec_system_helper.rb index f7e2ea11..5d8c355e 100644 --- a/spec/spec_system_helper.rb +++ b/spec/spec_system_helper.rb @@ -385,7 +385,7 @@ def can_test_projects_with_test_name_replaced_defines_with_success add_project_settings("project.yml", settings) output = `bundle exec ruby -S ceedling 2>&1` - #expect($?.exitstatus).to match(0) # Since a test either passes or is ignored, we return success here + expect($?.exitstatus).to match(0) # Since a test either passes or is ignored, we return success here expect(output).to match(/TESTED:\s+\d/) expect(output).to match(/PASSED:\s+\d/) expect(output).to match(/FAILED:\s+\d/)