@@ -18,13 +18,15 @@ def self.run(*argv)
1818 # @return nothing
1919 def initialize
2020 require 'optparse'
21+
22+ @config = Test . configuration ( true )
2123 end
2224
2325 # Test run configuration.
2426 #
2527 # @return [Config]
2628 def config
27- @config ||= Test . configuration
29+ @config
2830 end
2931
3032 # Run tests.
@@ -55,6 +57,10 @@ def run(argv=nil)
5557 end
5658 end
5759
60+ def preparse_options ( argv )
61+
62+ end
63+
5864 # Setup OptionsParser instance.
5965 #
6066 # @return [OptionParser]
@@ -84,52 +90,58 @@ def options
8490 end
8591
8692 opt . on '-t' , '--tag TAG' , 'select tests by tag' do |tag |
87- config . tags . concat enlist ( tag )
93+ config . tags . concat makelist ( tag )
8894 end
8995 opt . on '-u' , '--unit TAG' , 'select tests by software unit' do |unit |
90- config . units . concat enlist ( unit )
96+ config . units . concat makelist ( unit )
9197 end
9298 opt . on '-m' , '--match TEXT' , 'select tests by description' do |text |
93- config . match . concat enlist ( text )
99+ config . match . concat makelist ( text )
94100 end
95101
96102 opt . on '-A' , '--autopath' , 'automatically add paths to $LOAD_PATH' do |paths |
97103 config . autopath = true
98104 end
99105 opt . on '-I' , '--loadpath PATH' , 'add given path to $LOAD_PATH' do |paths |
100- #enlist (paths).reverse_each do |path|
106+ #makelist (paths).reverse_each do |path|
101107 # $LOAD_PATH.unshift path
102108 #end
103- config . loadpath . concat enlist ( paths )
109+ config . loadpath . concat makelist ( paths )
110+ end
111+ opt . on '-C' , '--chdir DIR' , 'change directory before running tests' do |dir |
112+ config . chdir = dir
113+ end
114+ opt . on '-R' , '--chroot' , 'change to project root directory before running tests' do
115+ config . chdir = Config . root
104116 end
105- #opt.on '-C', '--chdir DIR', 'change directory before running tests' do |dir|
106- # config.chdir = dir
107- #end
108- #opt.on '-R', '--chroot', 'change to project root directory before running tests' do |bool|
109- # config.chroot = bool
110- #end
111117 opt . on '-r' , '--require FILE' , 'require file' do |file |
112118 #require file
113- config . requires . concat pathlist ( file )
119+ config . requires . concat makelist ( file )
114120 end
115121 opt . on '-c' , '--config FILE' , "require local config file (immediately)" do |file |
116- Config . require_config ( file )
122+ config . load_config ( file )
117123 end
118124 opt . on '-V' , '--verbose' , 'provide extra detail in reports' do
119125 config . verbose = true
120126 end
121- #opt.on('--log DIRECTORY ', 'log directory '){ |dir |
122- # options[: log] = dir
127+ #opt.on('--log PATH ', 'log test output to path '){ |path |
128+ # config. log = path
123129 #}
124130 opt . on ( "--[no-]ansi" , 'turn on/off ANSI colors' ) { |v | $ansi = v }
125131 opt . on ( "--debug" , 'turn on debugging mode' ) { $DEBUG = true }
126132
127133 #opt.separator "COMMAND OPTIONS:"
128- #opt.on("--about" , 'display information about rubytest'){
129- # puts "Ruby Test v#{VERSION}"
130- # puts "#{COPYRIGHT}"
131- # exit
132- #}
134+ opt . on ( '--about' , 'display information about rubytest' ) do
135+ puts "Ruby Test v%s" % [ Test . index [ 'version' ] ]
136+ Test . index [ 'copyrights' ] . each do |c |
137+ puts "(c) %s %s (%s)" % c . values_at ( 'year' , 'holder' , 'license' )
138+ end
139+ exit
140+ end
141+ opt . on ( '--version' , 'display rubytest version' ) do
142+ puts Test ::VERSION
143+ exit
144+ end
133145 opt . on ( '-h' , '--help' , 'display this help message' ) {
134146 puts opt
135147 exit
@@ -142,7 +154,7 @@ def options
142154 # all strings and not empty.
143155 #
144156 # @return [Array<String>]
145- def enlist ( list )
157+ def makelist ( list )
146158 case list
147159 when String
148160 list = list . split ( /[:;]/ )
0 commit comments