Class: Reap::TestTask

Inherits:
Task
  • Object
show all
Defined in:
lib/reap/tasks/test-task.rb

Constant Summary

Constants inherited from Task

Reap::Task::DEFAULT_INCLUDE, Reap::Task::MUST_EXCLUDE, Reap::Task::RUBY

Instance Attribute Summary

Attributes inherited from Task

#config, #section

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Task

#[], inherited, #initialize, #package_name, registry, #ruby, #sh, tasks

Constructor Details

This class inherits a constructor from Reap::Task

Class Method Details

.descObject



8
# File 'lib/reap/tasks/test-task.rb', line 8

def self.desc ; "Run unit tests." ; end

.taskObject



6
# File 'lib/reap/tasks/test-task.rb', line 6

def self.task ; :test ; end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/reap/tasks/test-task.rb', line 18

def run
  # get test files
  test_libs = @libs
  test_files = FileList.new
  test_files.include(*@files)
  if test_files.empty?
    puts "No test files found."
    return
  end
  #test_reqs = test_files.gsub(/^(.*)\.rb$/, ' -r"\1"').join(" \\\n")
  #test_opts = " \\\n -- #{@options}" if @options
  puts "Reap is shelling out work to Ruby's Test Suite..."
  begin
    test_files.each { |f|
      ruby %{-r"test/unit" "#{f}"}
    }
    #puts %Q{ ruby %{-I#{test_libs} -e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}} } if $DEBUG
    #ruby %{-I#{test_libs} -e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}}
    #ruby %{-e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}}
  rescue
    puts "Error occured while trying to run tests."
    exit 0
  end
end

#set(section) ⇒ Object



11
12
13
14
15
16
# File 'lib/reap/tasks/test-task.rb', line 11

def set( section )
  @libs = ( section["libs"] || ['lib'] ).join(':')
  #@libs = (section["libs"] || []).join(':')
  @files = section["files"] || [ 'test/**/tc*.rb', 'test/**/test*.rb', 'test/**/*test.rb' ]
  @options = section['options']     
end