tests/vendor/ceedling/lib/configurator_validator.rb
def validate_executable_filepath(config, *keys)
    exe_extension = config[:extension][:executable]
    hash          = retrieve_value(config, keys)
    filepath      = hash[:value]

    # return early if we couldn't walk into hash and find a value
    return false if (filepath.nil?)

    # skip everything if we've got an argument replacement pattern
    return true if (filepath =~ TOOL_EXECUTOR_ARGUMENT_REPLACEMENT_PATTERN)
    
    # if there's no path included, verify file exists somewhere in system search paths
    if (not filepath.include?('/'))
      exists = false
      
      @system_wrapper.search_paths.each do |path|
        if (@file_wrapper.exist?( File.join(path, filepath)) )
          exists = true
          break
        end
        
        if (@file_wrapper.exist?( (File.join(path, filepath)).ext( exe_extension ) ))
          exists = true
          break
        elsif (@system_wrapper.windows? and @file_wrapper.exist?( (File.join(path, filepath)).ext( EXTENSION_WIN_EXE ) ))
          exists = true
          break
        end
      end
      
      if (not exists)
        # no verbosity checking since this is lowest level anyhow & verbosity checking depends on configurator
        @stream_wrapper.stderr_puts("ERROR: Config filepath #{format_key_sequence(keys, hash[:depth])}['#{filepath}'] does not exist in system search paths.") 
        return false        
      end
      
    # if there is a path included, check that explicit filepath exists
    else
      if (not @file_wrapper.exist?(filepath))
        # no verbosity checking since this is lowest level anyhow & verbosity checking depends on configurator
        @stream_wrapper.stderr_puts("ERROR: Config filepath #{format_key_sequence(keys, hash[:depth])}['#{filepath}'] does not exist on disk.") 
        return false
      end      
    end

    return true
  end
# walk into config hash. verify specified file exists.
walk into config hash. verify specified file exists.
walk into config hash . verify specified file exists .
def validate_executable_filepath(config, *keys)
    exe_extension = config[:extension][:executable]
    hash          = retrieve_value(config, keys)
    filepath      = hash[:value]
    return false if (filepath.nil?)
    return true if (filepath =~ TOOL_EXECUTOR_ARGUMENT_REPLACEMENT_PATTERN)
    if (not filepath.include?('/'))
      exists = false
      @system_wrapper.search_paths.each do |path|
        if (@file_wrapper.exist?( File.join(path, filepath)) )
          exists = true
          break
        end
        if (@file_wrapper.exist?( (File.join(path, filepath)).ext( exe_extension ) ))
          exists = true
          break
        elsif (@system_wrapper.windows? and @file_wrapper.exist?( (File.join(path, filepath)).ext( EXTENSION_WIN_EXE ) ))
          exists = true
          break
        end
      end
      if (not exists)
        @stream_wrapper.stderr_puts("ERROR: Config filepath #{format_key_sequence(keys, hash[:depth])}['#{filepath}'] does not exist in system search paths.") 
        return false        
      end
    else
      if (not @file_wrapper.exist?(filepath))
        @stream_wrapper.stderr_puts("ERROR: Config filepath #{format_key_sequence(keys, hash[:depth])}['#{filepath}'] does not exist on disk.") 
        return false
      end      
    end
    return true
  end
def validate_executable_filepath ( config , * keys ) exe_extension = config [ :extension ] [ :executable ] hash = retrieve_value ( config , keys ) filepath = hash [ :value ] return false if ( filepath . nil? ) return true if ( filepath =~ TOOL_EXECUTOR_ARGUMENT_REPLACEMENT_PATTERN ) if ( not filepath . include? ( '/' ) ) exists = false @system_wrapper . search_paths . each do | path | if ( @file_wrapper . exist? ( File . join ( path , filepath ) ) ) exists = true break end if ( @file_wrapper . exist? ( ( File . join ( path , filepath ) ) . ext ( exe_extension ) ) ) exists = true break elsif ( @system_wrapper . windows? and @file_wrapper . exist? ( ( File . join ( path , filepath ) ) . ext ( EXTENSION_WIN_EXE ) ) ) exists = true break end end if ( not exists ) @stream_wrapper . stderr_puts ( "ERROR: Config filepath #{format_key_sequence(keys, hash[:depth])}['#{filepath}'] does not exist in system search paths." ) return false end else if ( not @file_wrapper . exist? ( filepath ) ) @stream_wrapper . stderr_puts ( "ERROR: Config filepath #{format_key_sequence(keys, hash[:depth])}['#{filepath}'] does not exist on disk." ) return false end end return true end
walk into config hash.
walk into config hash .
# return early if we couldn't walk into hash and find a value # skip everything if we've got an argument replacement pattern # if there's no path included, verify file exists somewhere in system search paths # no verbosity checking since this is lowest level anyhow & verbosity checking depends on configurator # if there is a path included, check that explicit filepath exists # no verbosity checking since this is lowest level anyhow & verbosity checking depends on configurator
config
keys