Parent

Syckle::Plugins::Testrb

Test::Unit Plugin via testrb

This service plugin runs your test/unit (or minitest) tests based unit tests using the testrb commandline tool.

TODO: How to abort lifecycle if fail?

Constants

DEFAULT_TESTS

Default test file patterns.

Attributes

exclude[RW]

Test file patterns to specially exclude.

live[RW]

Test against live install (i.e. Don’t use loadpath option).

loadpath[RW]

Add these folders to the $LOAD_PATH.

requires[RW]

Libs to require when running tests.

tests[RW]

File glob pattern of tests to run.

Public Instance Methods

exclude=(val) click to toggle source

Special writer to ensure the value is a list.

# File lib/plugins/syckle/testrb.rb, line 44
def exclude=(val)
  @exclude = val.to_list
end
loadpath=(val) click to toggle source

Special writer to ensure the value is a list.

# File lib/plugins/syckle/testrb.rb, line 39
def loadpath=(val)
  @loadpath = val.to_list
end
require=(val) click to toggle source

In case you forget the ‘s’.

Alias for: requires=
requires=(val) click to toggle source

Special writer to ensure the value is a list.

# File lib/plugins/syckle/testrb.rb, line 49
def requires=(val)
  @requires = val.to_list
end
Also aliased as: require=
runtests() click to toggle source

Run unit tests. Unlike test-solo and test-cross this loads all tests and runs them together in a single process.

Note that this shells out to the testrb program.

TODO: Generate a test log entry?

# File lib/plugins/syckle/testrb.rb, line 96
def runtests
  tests    = self.tests
  loadpath = self.loadpath
  requires = self.requires
  live     = self.live
  exclude  = self.exclude

  #log      = options['log'] != false
  #logfile  = File.join('log', apply_naming_policy('test', 'log'))

  # what about arguments for selecting specific tests?
  #tests = EVN['TESTS'] if ENV['TESTS']

  #unless live
  #  loadpath.each do |lp|
  #    $LOAD_PATH.unshift(File.expand_path(lp))
  #  end
  #end

  if File.exist?('test/suite.rb')
    files = 'test/suite.rb'
  else
    files = multiglob_r(*tests)
  end

  if files.empty?
    status "WARNING: NO TESTS DEFINED!"
    return
  end

  # TODO: Use a subdirectory for log. Also html or xml format possible?

  filelist = files.select{|file| !File.directory?(file) }.join(' ')
  logfile  = project.log + 'testrb.log'

  # TODO: Does tee work on Windows?

  if live
    command = %[testrb #{filelist} 2>&1 | tee -a #{logfile}]
  else
    command = %[testrb -I#{loadpath.join(':')} #{filelist} 2>&1 | tee -a #{logfile}]
  end

  success = sh(command) #, :show=>true) #show?

  abort "Tests failed." unless success

  #if log && !trial?
  #  command = %[testrb -I#{loadpath} #{filelist} > #{logfile} 2>&1]  # /dev/null 2>&1
  #  system command
  #  puts "Updated #{logfile}"
  #end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.