# File lib/test/unit/autorunner.rb, line 193
      def options
        @options ||= OptionParser.new do |o|
          o.banner = "Test::Unit automatic runner."
          o.banner += "\nUsage: #{$0} [options] [-- untouched arguments]"

          o.on("-r", "--runner=RUNNER", RUNNERS,
               "Use the given RUNNER.",
               "(" + keyword_display(RUNNERS) + ")") do |r|
            @runner = r
          end

          o.on("--collector=COLLECTOR", COLLECTORS,
               "Use the given COLLECTOR.",
               "(" + keyword_display(COLLECTORS) + ")") do |collector|
            @collector = collector
          end

          if (@standalone)
            o.on("-b", "--basedir=DIR", "Base directory of test suites.") do |b|
              @base = b
            end

            o.on("-w", "--workdir=DIR", "Working directory to run tests.") do |w|
              @workdir = w
            end

            o.on("--default-test-path=PATH",
                 "Add PATH to the default test paths.",
                 "The PATH is used when user doesn't specify any test path.",
                 "You can specify this option multiple times.") do |path|
              @default_test_paths << path
            end

            o.on("-a", "--add=TORUN", Array,
                 "Add TORUN to the list of things to run;",
                 "can be a file or a directory.") do |paths|
              paths.each do |path|
                add_test_path(path)
              end
            end

            @pattern = []
            o.on("-p", "--pattern=PATTERN", Regexp,
                 "Match files to collect against PATTERN.") do |e|
              @pattern << e
            end

            @exclude = []
            o.on("-x", "--exclude=PATTERN", Regexp,
                 "Ignore files to collect against PATTERN.") do |e|
              @exclude << e
            end
          end

          o.on("-n", "--name=NAME", String,
               "Runs tests matching NAME.",
               "Use '/PATTERN/' for NAME to use regular expression.") do |name|
            name = (%r{\A/(.*)/\Z} =~ name ? Regexp.new($1) : name)
            @filters << lambda do |test|
              return true if name === test.method_name
              return true if name === test.local_name
              false
            end
          end

          o.on("--ignore-name=NAME", String,
               "Ignores tests matching NAME.",
               "Use '/PATTERN/' for NAME to use regular expression.") do |n|
            n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
            case n
            when Regexp
              @filters << proc {|t| n =~ t.method_name ? false : true}
            else
              @filters << proc {|t| n != t.method_name}
            end
          end

          o.on("-t", "--testcase=TESTCASE", String,
               "Runs tests in TestCases matching TESTCASE.",
               "Use '/PATTERN/' for TESTCASE to use regular expression.") do |n|
            n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
            @filters << lambda do |test|
              match_test_case_name(test, n)
            end
          end

          o.on("--ignore-testcase=TESTCASE", String,
               "Ignores tests in TestCases matching TESTCASE.",
               "Use '/PATTERN/' for TESTCASE to use regular expression.") do |n|
            n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
            @filters << lambda do |test|
              not match_test_case_name(test, n)
            end
          end

          o.on("--location=LOCATION", String,
               "Runs tests that defined in LOCATION.",
               "LOCATION is one of PATH:LINE, PATH or LINE") do |location|
            if /\A\d+\z/ =~ location
              path = nil
              line = location.to_i
            else
              path, line, = location.split(/:(\d+)/, 2)
              line = line.to_i unless line.nil?
            end
            add_location_filter(path, line)
          end

          o.on("--attribute=EXPRESSION", String,
               "Runs tests that matches EXPRESSION.",
               "EXPRESSION is evaluated as Ruby's expression.",
               "Test attribute name can be used with no receiver in EXPRESSION.",
               "EXPRESSION examples:",
               "  !slow",
               "  tag == 'important' and !slow") do |expression|
            @filters << lambda do |test|
              matcher = AttributeMatcher.new(test)
              matcher.match?(expression)
            end
          end

          priority_filter = Proc.new do |test|
            if @filters == [priority_filter]
              Priority::Checker.new(test).need_to_run?
            else
              nil
            end
          end
          o.on("--[no-]priority-mode",
               "Runs some tests based on their priority.") do |priority_mode|
            if priority_mode
              Priority.enable
              @filters |= [priority_filter]
            else
              Priority.disable
              @filters -= [priority_filter]
            end
          end

          o.on("--default-priority=PRIORITY",
               Priority.available_values,
               "Uses PRIORITY as default priority",
               "(#{keyword_display(Priority.available_values)})") do |priority|
            Priority.default = priority
          end

          o.on("-I", "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
               "Appends directory list to $LOAD_PATH.") do |dirs|
            $LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
          end

          color_schemes = ColorScheme.all
          o.on("--color-scheme=SCHEME", color_schemes,
               "Use SCHEME as color scheme.",
               "(#{keyword_display(color_schemes)})") do |scheme|
            @color_scheme = scheme
          end

          o.on("--config=FILE",
               "Use YAML fomat FILE content as configuration file.") do |file|
            load_config(file)
          end

          o.on("--order=ORDER", TestCase::AVAILABLE_ORDERS,
               "Run tests in a test case in ORDER order.",
               "(#{keyword_display(TestCase::AVAILABLE_ORDERS)})") do |order|
            TestCase.test_order = order
          end

          assertion_message_class = Test::Unit::Assertions::AssertionMessage
          o.on("--max-diff-target-string-size=SIZE", Integer,
               "Shows diff if both expected result string size and " +
               "actual result string size are " +
               "less than or equal SIZE in bytes.",
               "(#{assertion_message_class.max_diff_target_string_size})") do |size|
            assertion_message_class.max_diff_target_string_size = size
          end

          o.on("--[no-]stop-on-failure",
               "Stops immediately on the first non success test",
               "(#{@stop_on_failure})") do |boolean|
            @stop_on_failure = boolean
          end

          ADDITIONAL_OPTIONS.each do |option_builder|
            option_builder.call(self, o)
          end

          o.on("--",
               "Stop processing options so that the",
               "remaining options will be passed to the",
               "test."){o.terminate}

          o.on("-h", "--help", "Display this help."){puts o; exit}

          o.on_tail
          o.on_tail("Deprecated options:")

          o.on_tail("--console", "Console runner (use --runner).") do
            warn("Deprecated option (--console).")
            @runner = self.class.runner(:console)
          end

          if RUNNERS[:fox]
            o.on_tail("--fox", "Fox runner (use --runner).") do
              warn("Deprecated option (--fox).")
              @runner = self.class.runner(:fox)
            end
          end

          o.on_tail
        end
      end