Module: Uttk

Defined in:
lib/uttk.rb,
lib/uttk/logger.rb,
lib/uttk/status.rb,
lib/uttk/streams.rb,
lib/uttk/version.rb,
lib/uttk/filters/Id.rb,
lib/uttk/dumpers/Xml.rb,
lib/uttk/logger/path.rb,
lib/uttk/dumpers/Html.rb,
lib/uttk/dumpers/Path.rb,
lib/uttk/dumpers/Yaml.rb,
lib/uttk/loaders/Yaml.rb,
lib/uttk/streams/Diff.rb,
lib/uttk/weights/WMin.rb,
lib/uttk/dumpers/Basic.rb,
lib/uttk/filters/Saver.rb,
lib/uttk/weights/WExpr.rb,
lib/uttk/dumpers/Dumper.rb,
lib/uttk/filters/Buffer.rb,
lib/uttk/filters/Filter.rb,
lib/uttk/loaders/Loader.rb,
lib/uttk/logger/backend.rb,
lib/uttk/logger_factory.rb,
lib/uttk/strategies/Cmd.rb,
lib/uttk/streams/Stream.rb,
lib/uttk/weights/WFloat.rb,
lib/uttk/weights/Weight.rb,
lib/uttk/filters/Compact.rb,
lib/uttk/filters/Default.rb,
lib/uttk/filters/NodeCut.rb,
lib/uttk/logger/severity.rb,
lib/uttk/strategies/Fail.rb,
lib/uttk/strategies/Make.rb,
lib/uttk/strategies/Pass.rb,
lib/uttk/strategies/Pool.rb,
lib/uttk/strategies/Stub.rb,
lib/uttk/strategies/Test.rb,
lib/uttk/logger/verbosity.rb,
lib/uttk/strategies/Abort.rb,
lib/uttk/strategies/Block.rb,
lib/uttk/strategies/Clean.rb,
lib/uttk/strategies/Error.rb,
lib/uttk/strategies/JUnit.rb,
lib/uttk/strategies/Proxy.rb,
lib/uttk/strategies/RUnit.rb,
lib/uttk/strategies/Sleep.rb,
lib/uttk/strategies/Suite.rb,
lib/uttk/strategies/Assert.rb,
lib/uttk/strategies/Import.rb,
lib/uttk/strategies/RMatch.rb,
lib/uttk/strategies/SubCmd.rb,
lib/uttk/dumpers/BasicColor.rb,
lib/uttk/filters/JustStatus.rb,
lib/uttk/filters/TextFilter.rb,
lib/uttk/logger/to_uttk_log.rb,
lib/uttk/strategies/Authors.rb,
lib/uttk/strategies/CmdBase.rb,
lib/uttk/strategies/Compile.rb,
lib/uttk/strategies/IOBased.rb,
lib/uttk/strategies/Iterate.rb,
lib/uttk/strategies/KillAll.rb,
lib/uttk/strategies/Package.rb,
lib/uttk/filters/RPathFilter.rb,
lib/uttk/logger/section_node.rb,
lib/uttk/strategies/Checkout.rb,
lib/uttk/strategies/SqlQuery.rb,
lib/uttk/strategies/Strategy.rb,
lib/uttk/filters/DefaultColor.rb,
lib/uttk/generators/generator.rb,
lib/uttk/strategies/Bootstrap.rb,
lib/uttk/strategies/Composite.rb,
lib/uttk/strategies/Configure.rb,
lib/uttk/strategies/SignalCmd.rb,
lib/uttk/filters/KeepSkipBased.rb,
lib/uttk/strategies/Collection.rb,
lib/uttk/path_filters/PathFilter.rb,
lib/uttk/path_filters/ColorStatus.rb,
lib/uttk/path_filters/RemoveTypes.rb,
lib/uttk/strategies/PackageCollection.rb,
lib/uttk/strategies/ProbabilityThreshold.rb

Overview

Copyright

Copyright © 2005 Uttk Team. All rights reserved.

Author

Nicolas Pouillard <[email protected]>.

License

LGPL

Revision

$Id: /w/fey/uttk/trunk/lib/uttk/path_filters/PathFilter.rb 21975 2006-02-19T22:24:11.182512Z pouillar $

Defined Under Namespace

Modules: Dumpers, Filters, Generators, Loaders, PathFilters, Strategies, Streams, Weights Classes: AbortStatus, ErrorStatus, FailStatus, Logger, LoggerFactory, ObserverError, PassStatus, RunningStatus, SkipStatus, StartStatus, Status, TimeoutAbortStatus, UttkException

Constant Summary collapse

UTTK_MODULES =
[]
S =

Modules shortcuts

Strategies
L =
Loaders
D =
Dumpers
F =
Filters
W =
Weights
DEFAULT_OPTIONS =

Set default options

{
  :observers => [],
  :backend => STDOUT.tty? ? 'DefaultColor' : 'Default',
  :loader => Loaders::Yaml,
  :wclass => Weights::Default,
  :attributes => {}, #FIXME: freeze
  :symbols => {}, #FIXME: freeze
  :log_severity => Logger::Severity::INFO,
  :log_verbosity => 0,
  :log_section => [], #FIXME: freeze
  :benchmark => false,
  :profile => false,
  :dump_status => false,
  :cache_mode => false,
  :cache_proc => DumpableProc.new('|test, status|
     status.pass? or (status.is_a? Uttk::SkipStatus and status.weight.pass?)'
  ).freeze,
}.freeze
Version =
::Version.parse("dev-util/uttk-0.3#KID")

Class Method Summary collapse

Class Method Details

.binObject



270
271
272
# File 'lib/uttk.rb', line 270

def self.bin
  Config::CONFIG["RUBY_INSTALL_NAME"].to_cmd[dir.parent.parent + 'bin/uttk']
end

.default_log(options = default_options, log_factory = default_log_factory(options)) ⇒ Object

Return the default logger factory



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/uttk.rb', line 248

def self.default_log ( options=default_options,
                       log_factory=default_log_factory(options) )
  log = log_factory.create
  options[:observers] << options[:backend] if options[:observers].empty?
  options[:observers].each do |backend|
    Filters[backend].each do |obsv|
      raise ObserverError, obsv unless obsv.respond_to? :update
      log.add_observer(obsv)
    end
  end
  log.info_basicObserver do
    log.add_observer(Uttk::Dumpers::Basic.new(STDERR))
    nil
  end
  log
end

.default_log_factory(options = default_options) ⇒ Object

Return the default logger factory



234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/uttk.rb', line 234

def self.default_log_factory ( options=default_options )
  log_factory = LoggerFactory.new
  if ENV.has_key?('UTTK_SEVERITY')
    log_factory.severity_level = ENV['UTTK_SEVERITY']
  else
    log_factory.severity_level = options[:log_severity]
  end
  log_factory.verbosity_level = options[:log_verbosity]
  log_factory.section_tree << Logger::SectionNode.new('basicObserver')
  log_factory.active_section = options[:log_section]
  log_factory
end

.default_optionsObject



208
209
210
# File 'lib/uttk.rb', line 208

def self.default_options
  DEFAULT_OPTIONS
end

.default_symtbl(options = default_options, log_factory = default_log_factory(options), log = default_log(options, log_factory)) ⇒ Object

Return the default symbol table



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/uttk.rb', line 213

def self.default_symtbl ( options=default_options,
                          log_factory=default_log_factory(options),
                          log=default_log(options, log_factory))
  symtbl = SymTbl.new(options)
  symtbl[:uttk] = Pathname.new($0).expand_path
  symtbl[:ruby] = Config::CONFIG['RUBY_INSTALL_PATH']
  symtbl[:'uttk-unit'] = symtbl[:uttk_unit] =
    (Uttk.dir.parent.parent/'bin'/'uttk-unit').expand_path.cleanpath
  symtbl[:core_ex] = CoreEx.dir
  symtbl[:symtbl_class] = symtbl.class
  symtbl[:pwd] = Pathname.pwd.expand_path
  symtbl[:loader] = options[:loader].new
  symtbl[:log_factory] = log_factory
  symtbl[:log] = log
  symtbl[:cache] = {}
  symtbl[:cache_proc] = options[:cache_proc]
  symtbl[:suite_name] = 'root'
  symtbl
end

.pathname_to_class(p) ⇒ Object

Autoload modules



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/uttk.rb', line 84

def pathname_to_class(p)
  const = p.basename.to_s.sub(/\.rb$/, '')
  if const =~ ConstRegexp::RB_CONST
    const
  else
    raise(ArgumentError,
        "`#{p.to_s}' - your file doesn't follow our convention, " +
        "the filename must be equal to the class name you declared into.")
    nil
  end
end

.setup_autoload_allObject



140
141
142
143
144
# File 'lib/uttk.rb', line 140

def self.setup_autoload_all
  UTTK_MODULES.each do |uttk_module|
    uttk_module.setup_autoload
  end
end

.uttk_eval(string, symtbl, filename = __FILE__, lineno = 1) ⇒ Object

Evaluate code in the context of the Uttk module



266
267
268
# File 'lib/uttk.rb', line 266

def self.uttk_eval(string, symtbl, filename=__FILE__, lineno=1)
  eval(string, binding, filename, lineno)
end