Parent

Syckle::Plugins::Turn

Turn Plugin

This service plugin runs your test/unit (or mint/test) unit tests using the turn commandline tool.

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/turn.rb, line 42
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/turn.rb, line 37
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/turn.rb, line 47
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/turn.rb, line 93
def runtests
  tests    = self.tests
  exclude  = self.exclude
  loadpath = self.loadpath
  requires = self.requires
  live     = self.live

  #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

  files = multiglob_r(*tests) - multiglob_r(*exclude)

  if files.empty?
    report "WARNING: NO TESTS TO RUN"
    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 + 'turn.log'

  # TODO: Does tee work on Windows? Hmmm... I rather add a logging option to turn itself.
  # TODO: Also, turn needs to return a failing exist code if tests fail.

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

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

  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.