File: test.rb

package info (click to toggle)
libtmail-ruby 0.10.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 624 kB
  • ctags: 1,236
  • sloc: ruby: 5,939; ansic: 1,302; yacc: 337; makefile: 188
file content (68 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# execute runit test in T/
#

require 'runit/testsuite'
require 'runit/testcase'
require 'runit/cui/testrunner'
$:.unshift '../..'


module RUNIT

  @tmp = []

  class << self
    def load( fname, methods = nil )
      @tmp.push [nil, methods]
      require fname
    end

    def add_test_case( klass )
      @tmp[-1][0] = klass
    end

    def exec
      suite = TestSuite.new
      @tmp.each do |klass, methods|
        if methods then
          methods.each do |i|
            suite.add_test klass.new( 'test_' + i )
          end
        else
          suite.add_test klass.suite
        end
      end
      RUNIT::CUI::TestRunner.quiet_mode = true
      f = File.open('/dev/tty', 'w')
      f.sync = true
      RUNIT::CUI::TestRunner.new(f).run suite
    end
  end

end

class Module
  def testme!
    RUNIT.add_test_case self
  end
end


unless File.basename(Dir.pwd) == 'T' then
  Dir.chdir 'T'
end

if ARGV.empty? then
  Dir['./test*.rb'].each do |fname|
    RUNIT.load fname
  end
else
  ARGV.each do |i|
    name, m = i.split('.', 2)
    methods = m.split(',') if m

    RUNIT.load "test#{name}.rb", methods
  end
end
RUNIT.exec