Author:Nathaniel Talbott.
Copyright:Copyright © 2000-2002 Nathaniel Talbott. All rights reserved.
License:Ruby license.

Methods

Classes and Modules

Module Test::Unit

Attributes

collector  [W] 
exclude  [RW] 
filters  [RW] 
output_level  [RW] 
pattern  [RW] 
runner  [W] 
suite  [R] 
to_run  [RW] 

Public Class methods

[Source]

    # File test/unit/autorunner.rb, line 75
75:       def initialize(standalone)
76:         Unit.run = true
77:         @standalone = standalone
78:         @runner = RUNNERS[:console]
79:         @collector = COLLECTORS[(standalone ? :dir : :objectspace)]
80:         @filters = []
81:         @to_run = []
82:         @output_level = UI::NORMAL
83:         yield(self) if(block_given?)
84:       end

Public Instance methods

[Source]

     # File test/unit/autorunner.rb, line 191
191:       def keyword_display(array)
192:         list = array.collect {|e, *| e.to_s}
193:         Array === array or list.sort!
194:         list.collect {|e| e.sub(/^(.)([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')}.join(", ")
195:       end

[Source]

     # File test/unit/autorunner.rb, line 100
100:       def options
101:         @options ||= OptionParser.new do |o|
102:           o.banner = "Test::Unit automatic runner."
103:           o.banner << "\nUsage: #{$0} [options] [-- untouched arguments]"
104: 
105:           o.on
106:           o.on('-r', '--runner=RUNNER', RUNNERS,
107:                "Use the given RUNNER.",
108:                "(" + keyword_display(RUNNERS) + ")") do |r|
109:             @runner = r
110:           end
111: 
112:           if(@standalone)
113:             o.on('-a', '--add=TORUN', Array,
114:                  "Add TORUN to the list of things to run;",
115:                  "can be a file or a directory.") do |a|
116:               @to_run.concat(a)
117:             end
118: 
119:             @pattern = []
120:             o.on('-p', '--pattern=PATTERN', Regexp,
121:                  "Match files to collect against PATTERN.") do |e|
122:               @pattern << e
123:             end
124: 
125:             @exclude = []
126:             o.on('-x', '--exclude=PATTERN', Regexp,
127:                  "Ignore files to collect against PATTERN.") do |e|
128:               @exclude << e
129:             end
130:           end
131: 
132:           o.on('-n', '--name=NAME', String,
133:                "Runs tests matching NAME.",
134:                "(patterns may be used).") do |n|
135:             n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
136:             case n
137:             when Regexp
138:               @filters << proc{|t| n =~ t.method_name ? true : nil}
139:             else
140:               @filters << proc{|t| n == t.method_name ? true : nil}
141:             end
142:           end
143: 
144:           o.on('-t', '--testcase=TESTCASE', String,
145:                "Runs tests in TestCases matching TESTCASE.",
146:                "(patterns may be used).") do |n|
147:             n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
148:             case n
149:             when Regexp
150:               @filters << proc{|t| n =~ t.class.name ? true : nil}
151:             else
152:               @filters << proc{|t| n == t.class.name ? true : nil}
153:             end
154:           end
155: 
156:           o.on('-v', '--verbose=[LEVEL]', OUTPUT_LEVELS,
157:                "Set the output level (default is verbose).",
158:                "(" + keyword_display(OUTPUT_LEVELS) + ")") do |l|
159:             @output_level = l || UI::VERBOSE
160:           end
161: 
162:           o.on('--',
163:                "Stop processing options so that the",
164:                "remaining options will be passed to the",
165:                "test."){o.terminate}
166: 
167:           o.on('-h', '--help', 'Display this help.'){puts o; exit}
168: 
169:           o.on_tail
170:           o.on_tail('Deprecated options:')
171: 
172:           o.on_tail('--console', 'Console runner (use --runner).') do
173:             warn("Deprecated option (--console).")
174:             @runner = RUNNERS[:console]
175:           end
176: 
177:           o.on_tail('--gtk', 'GTK runner (use --runner).') do
178:             warn("Deprecated option (--gtk).")
179:             @runner = RUNNERS[:gtk]
180:           end
181: 
182:           o.on_tail('--fox', 'Fox runner (use --runner).') do
183:             warn("Deprecated option (--fox).")
184:             @runner = RUNNERS[:fox]
185:           end
186: 
187:           o.on_tail
188:         end
189:       end

[Source]

    # File test/unit/autorunner.rb, line 86
86:       def process_args(args = ARGV)
87:         begin
88:           @to_run.concat options.parse!(args)
89:         rescue OptionParser::ParseError => e
90:           puts e
91:           puts options
92:           $! = nil
93:           abort
94:         else
95:           @filters << proc{false} unless(@filters.empty?)
96:         end
97:         not @to_run.empty?
98:       end

[Source]

     # File test/unit/autorunner.rb, line 197
197:       def run
198:         @suite = @collector[self]
199:         result = @runner[self] or return false
200:         result.run(@suite, @output_level).passed?
201:       end

Search

Google

Ruby API Docs

Links