8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/oats/commandline_options.rb', line 8
def CommandlineOptions.options(argv = nil)
$oats_execution['input_args'] = $oats_unit_test ? $oats_unit_test['input_args'] : ARGV.dup
argv ||= $oats_execution['input_args'].dup
argv_save = argv.dup
begin
options = {}
optparse = OptionParser.new do|opts|
opts.banner = "Usage: oats.rb [options] test1 test2 ..."
opts.separator "Options:"
opts.on( '--tests t1,t2,t3', Array,
'Test files for OATS execution.' ) do |t|
options['execution:test_files'] = t
end
opts.on( '-b', '--browser_type TYPE', ['firefox', 'iexplore','chrome'],
'Select test execution browser type (firefox, iexplore, chrome)' ) do |t|
options['selenium:browser_type'] = t
end
opts.on( '-e', '--environments env1,env2,env3', Array,
'Environment list for OATS execution.' ) do |t|
options['execution:environments'] = t
end
opts.on( '-t', '--test_dir DIR_TESTS',
'Test directory to override environment variable OATS_TESTS.' ) do |t|
options['_:dir_tests'] = t
end
opts.on( '-i', '--ini INI_YAML_FILE',
'The oats-user.yml to use.' ) do |t|
options['_:ini_file'] = t
end
opts.on( '-p', '--port PORT', Integer,
'Port number for the Oats Agent.' ) do |t|
options['execution:occ:agent_port'] = t if t
end
opts.on( '-n', '--nickname NICKNAME',
'Nickname to display on OCC for the Oats Agent.' ) do |t|
options['execution:occ:agent_nickname'] = t if t
end
opts.on( '-o', '--options key11.key12.key13:val1,key21.key22:val2,...', Array,
'Options to override values specified in oats.yml as well as other commandline options.' ) do |t|
options['_:options'] = t
end
opts.on( '-j', '--json JSON',
'The json hash to merge with oats data.' ) do |t|
options['_:json'] = t
end
opts.on( '-q', '--quiet',
'Do not echo anything to the console while running.' ) do |t|
options['_:quiet'] = true
end
opts.on( '-a', '--agent',
'Invokes background agent handling.' ) do |t|
options['_:agent'] = true
end
opts.on( '-u', '--oats_user OATS_USER',
'Sets OATS_USER for agent, in conjunction with -a.' ) do |t|
options['_:oats_user'] = t
end
opts.on( '-k', '--kill_agent',
'Kill the agent.' ) do |t|
options['_:kill_agent, in conjunction with -a'] = true
end
opts.on( '-g', '--gemfile GEMFILE',
'Gemfile path to be included.' ) do |t|
options['_:gemfile'] = t
end
opts.on( '-d' , '--d_options unit_test_dir1,unit_test_dir2', Array,
'NetBeans passes these d options to TestUnit.' ) do |t|
options['_:d_options'] = t
end
opts.on_tail( '-h', '--help', 'Display this screen' ) { $stderr.puts opts; exit }
end
optparse.parse!(argv)
if argv and ! argv.empty?
options['execution:test_files'] ||= []
options['execution:test_files'] += argv
end
rescue Exception => e
raise unless e.class.to_s =~ /^OptionParser::/
$stderr.puts e.message
$stderr.puts "Please type 'oats -h' for valid options."
exit 1
end
options['_:args'] = argv_save
@@OPTIONS = options
end
|