2
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
"""Processes command line options for Drizzle test-runner"""
31
def comma_list_split(option, opt, value, parser):
32
"""Callback for splitting input expected in list form"""
33
cur_list = getattr(parser.values, option.dest,[])
34
input_list = value.split(',')
35
# this is a hack to work with make target - we
36
# don't deal with a dangling ',' in our list
40
value_list = cur_list + input_list
42
value_list = input_list
43
setattr(parser.values, option.dest, value_list)
45
def organize_options(args, test_cases):
46
"""Put our arguments in a nice dictionary
47
We use option.dest as dictionary key
52
variables = vars(args)
53
variables['test_cases']= test_cases
54
if variables['manualgdb']:
58
# Create the CLI option parser
59
parser= optparse.OptionParser()
61
# find some default values
62
# assume we are in-tree testing in general and operating from root/test(?)
63
testdir_default = os.path.abspath(os.getcwd())
65
server_default = os.path.abspath(os.path.join(testdir_default,
66
'../drizzled/drizzled'))
68
workdir_default = os.path.join(testdir_default,'dbqp_work')
70
clientbindir_default = os.path.abspath(os.path.join(testdir_default,
73
basedir_default = os.path.split(testdir_default)[0]
76
# system_control_group - things like verbose, debug, etc
77
# test-runner affecting options
78
system_control_group = optparse.OptionGroup(parser,
79
"Options for the test-runner itself")
81
system_control_group.add_option(
86
, help="Set this to continue test execution beyond the first failed test"
89
system_control_group.add_option(
94
, help="Spin up the server(s) for the first specified test then exit (will leave servers running)"
97
system_control_group.add_option(
100
, action="store_true"
102
, help="Produces extensive output about test-runner state. Distinct from --debug"
105
system_control_group.add_option(
108
, action="store_true"
110
, help="Provide internal-level debugging output. Distinct from --verbose"
113
system_control_group.add_option(
117
, help="Testing mode. We only support dtr...for now >;) [%default]"
120
system_control_group.add_option(
123
, action="store_true"
125
, help="Record a testcase result (if the testing mode supports it) [%default]"
128
system_control_group.add_option(
131
, action="store_true"
133
, help="Don't try to cleanup from earlier runs (currently just a placeholder) [%default]"
136
parser.add_option_group(system_control_group)
138
# end system_control_group
140
# test_control_group - things like suite, do-test, skip-test
141
# Affect which tests are run
142
test_control_group = optparse.OptionGroup(parser,
143
"Options for controlling which tests are executed")
146
test_control_group.add_option(
151
, callback=comma_list_split
152
, help="The name of the suite containing tests we want. Can accept comma-separated list (with no spaces). Additional --suite args are appended to existing list [autosearch]"
155
test_control_group.add_option(
161
, help="The path containing the suite(s) you wish to execute. Use on --suitepath for each suite you want to use."
163
test_control_group.add_option(
168
, help="input can either be a prefix or a regex. Will only execute tests that match the provided pattern"
171
test_control_group.add_option(
176
, help = "input can either be a prefix or a regex. Will exclude tests that match the provided pattern"
179
test_control_group.add_option(
182
, action="store_true"
184
, help = "sort the testcases so that they are executed optimally for the given mode [%default]"
189
parser.add_option_group(test_control_group)
190
# end test_control_group
192
# test subject control group
193
# terrible name for options tht define the server / code
195
test_subject_control_group = optparse.OptionGroup(parser,
196
"Options for defining the code that will be under test")
198
test_subject_control_group.add_option(
202
, default = basedir_default
203
, help = "Pass this argument to signal to the test-runner that this is an in-tree test. We automatically set a number of variables relative to the argument (client-bindir, serverdir, testdir) [%default]"
206
test_subject_control_group.add_option(
210
, default = "auto-search"
211
, help = "Path to the server executable. [%default]"
214
test_subject_control_group.add_option(
216
, dest="clientbindir"
218
, default = "auto-search"
219
, help = "Path to the directory containing client program binaries for use in testing [%default]"
223
test_subject_control_group.add_option(
224
"--default-storage-engine"
225
, dest="defaultengine"
227
, help="Start drizzled using the specified engine [%default]"
231
parser.add_option_group(test_subject_control_group)
232
# end test subject control group
235
# environment options
236
# define where to find our testsets, working dirs, etc
237
environment_control_group = optparse.OptionGroup(parser,
238
"Options for defining the testing environment")
240
environment_control_group.add_option(
244
, default = testdir_default
245
, help = "Path to the test dir, containing additional files for test execution. [%default]"
248
environment_control_group.add_option(
252
, default = workdir_default
253
, help = "Path to the directory test-run will use to store generated files and directories. [%default]"
256
environment_control_group.add_option(
260
, default = basedir_default
261
, help = "build option [%default]"
264
environment_control_group.add_option(
268
, default = basedir_default
269
, help = "build option [%default]"
272
environment_control_group.add_option(
275
, action='store_true'
277
, help = "By default, we symlink workdir to a location in shm. Use this flag to not symlink [%default]"
280
environment_control_group.add_option(
283
, action='store_true'
285
, help = "Don't try to clean up working directories before test execution [%default]"
288
environment_control_group.add_option(
289
"--no-secure-file-priv"
290
, dest = "nosecurefilepriv"
291
, action='store_true'
293
, help = "Turn off the use of --secure-file-priv=vardir for started servers"
296
parser.add_option_group(environment_control_group)
297
# end environment control group
299
option_passing_group = optparse.OptionGroup(parser,
300
"Options to pass options on to the server")
302
option_passing_group.add_option(
304
, dest="drizzledoptions"
308
, help = "Pass additional options to the server. Will be passed to all servers for all tests (mostly for --start-and-exit)"
311
parser.add_option_group(option_passing_group)
312
# end option passing group
315
analysis_control_group = optparse.OptionGroup(parser,
316
"Options for defining the tools we use for code analysis (valgrind, gprof, gcov, etc)")
318
analysis_control_group.add_option(
321
, action='store_true'
323
, help = "Run drizzletest and drizzled executables using valgrind with default options [%default]"
325
analysis_control_group.add_option(
327
, dest="valgrindarglist"
330
, help = "Pass an option to valgrind (overrides/removes default valgrind options)"
333
parser.add_option_group(analysis_control_group)
335
debugger_control_group = optparse.OptionGroup(parser,
336
"Options for controlling the use of debuggers with test execution")
338
debugger_control_group.add_option(
341
, action='store_true'
343
, help="Start the drizzled server(s) in gdb"
346
debugger_control_group.add_option(
349
, action='store_true'
351
, help="Allows you to start the drizzled server(s) in gdb manually (in another window, etc)"
354
parser.add_option_group(debugger_control_group)
357
# supplied will be those arguments matching an option,
358
# and test_cases will be everything else
359
(args, test_cases)= parser.parse_args()
362
variables = organize_options(args, test_cases)