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