Skip to content

Commit 08554ad

Browse files
committed
Rename -p/--profile to -c/--config.
1 parent 4c8b272 commit 08554ad

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

lib/rubytest/cli.rb

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Test
22

33
# Command line interface to test runner.
44
#
5+
# TODO: Use `cli` based library instead of option parse.
6+
#
57
class CLI
68

79
#
@@ -51,6 +53,14 @@ def run(argv=nil)
5153
#end
5254
end
5355

56+
# These options are parsed prior to any other options.
57+
#
58+
# TODO: Certain opitons should be parsed before others.
59+
# Some aren't even useful if not, use as -R.
60+
def preoptions
61+
62+
end
63+
5464
#
5565
# Setup OptionsParser instance.
5666
#
@@ -61,9 +71,6 @@ def options
6171
opt.banner = "Usage: #{File.basename($0)} [options] [files ...]"
6272

6373
#opt.separator "PRESET OPTIONS:"
64-
#opt.on '-c', '--config FILE', "require local config file" do |file|
65-
# require_config(file)
66-
#end
6774
#pnames = profile_names
6875
#unless pnames.empty?
6976
# pnames.each do |pname|
@@ -92,19 +99,25 @@ def options
9299
config.match << text
93100
end
94101

95-
opt.on '-a', '--autopath', 'automatically add paths to $LOAD_PATH' do |paths|
102+
opt.on '-A', '--autopath', 'automatically add paths to $LOAD_PATH' do |paths|
96103
config.autopath = true
97104
end
98105
opt.on '-I', '--loadpath PATH', 'add given path to $LOAD_PATH' do |paths|
99106
paths.split(/[:;]/).reverse_each do |path|
100107
$LOAD_PATH.unshift path
101108
end
102109
end
110+
#opt.on '-C', '--chdir DIR', 'change directory before running tests' do |dir|
111+
# config.chdir = dir
112+
#end
113+
#opt.on '-R', '--chroot', 'change to project root directory before running tests' do |bool|
114+
# config.chroot = bool
115+
#end
103116
opt.on '-r', '--require FILE', 'require file (immediately)' do |file|
104117
require file
105118
end
106-
opt.on '-p', '--profile FILE', "require local profile" do |file|
107-
Config.require_profile(file)
119+
opt.on '-c', '--config FILE', "require local config file" do |file|
120+
Config.require_config(file)
108121
end
109122
opt.on '-d' , '--details', 'provide extra detail in reports' do
110123
config.verbose = true

lib/rubytest/config.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def self.dotindex
8484
end
8585

8686
#
87-
def self.require_profile(file)
87+
# TODO: Should config files be require relative to project root
88+
# or relatvie to current working directory?
89+
#
90+
def self.require_config(file)
8891
#if File.exist?(file)
8992
# require file
9093
#else
@@ -95,10 +98,11 @@ def self.require_profile(file)
9598
#end
9699
end
97100

98-
# Setup $LOAD_PATH based on .index file.
101+
# Setup $LOAD_PATH based on project's `.index` file, if an
102+
# index file is not found, then default to `lib/` if it exists.
99103
#
100104
def self.load_path_setup
101-
if load_paths = (dotindex['paths'] || {})['load']
105+
if load_paths = (dotindex['paths'] || {})['lib']
102106
load_paths.each do |path|
103107
$LOAD_PATH.unshift(File.join(root, path))
104108
end
@@ -185,6 +189,20 @@ def autopath=(boolean)
185189
@autopath = !!boolean
186190
end
187191

192+
#
193+
#attr :chroot
194+
195+
#def chroot=(boolean)
196+
# @chroot = !!boolean
197+
#end
198+
199+
#
200+
#attr :chdir
201+
202+
#def chdir=(dir)
203+
# @chroot = dir.to_s
204+
#end
205+
188206
end
189207

190208
end

0 commit comments

Comments
 (0)