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
9
"""Processes command line options for Drizzle test-runner"""
17
def comma_list_split(option, opt, value, parser):
18
"""Callback for splitting input expected in list form"""
19
setattr(parser.values, option.dest, value.split(','))
21
def organize_options(args, test_cases):
22
"""Put our arguments in a nice dictionary
23
We use option.dest as dictionary key
28
variables = vars(args)
29
variables['test_cases']= test_cases
32
# Create the CLI option parser
33
parser= optparse.OptionParser()
35
# find some default values
36
# assume we are in-tree testing in general and operating from root/test(?)
37
testdir_default = os.path.abspath(os.getcwd())
38
server_default = os.path.abspath(os.path.join(testdir_default,
39
'../drizzled/drizzled'))
40
workdir_default = os.path.join(testdir_default,'dtr_work')
41
clientbindir_default = os.path.abspath(os.path.join(testdir_default,
43
basedir_default = os.path.split(testdir_default)[0]
45
# system_control_group - things like verbose, debug, etc
46
# test-runner affecting options
47
system_control_group = optparse.OptionGroup(parser,
48
"Options for the test-runner itself")
50
system_control_group.add_option(
55
, help="Set this to continue test execution beyond the first failed test"
58
system_control_group.add_option(
63
, help="Produces extensive output about test-runner state. Distinct from --debug"
66
system_control_group.add_option(
71
, help="Provide internal-level debugging output. Distinct from --verbose"
74
system_control_group.add_option(
78
, help="Testing mode. We only support dtr...for now >;) [%default]"
81
system_control_group.add_option(
86
, help="Record a testcase result (if the testing mode supports it) [%default]"
89
parser.add_option_group(system_control_group)
91
# end system_control_group
93
# test_control_group - things like suite, do-test, skip-test
94
# Affect which tests are run
95
test_control_group = optparse.OptionGroup(parser,
96
"Options for controlling which tests are executed")
99
test_control_group.add_option(
104
, help="The name of the suite containing tests we want. Use one --suite arg for each suite you want to use. [default=autosearch]"
107
test_control_group.add_option(
113
, help="The path containing the suite(s) you wish to execute. Use on --suitepath for each suite you want to use."
115
test_control_group.add_option(
120
, help="input can either be a prefix or a regex. Will only execute tests that match the provided pattern"
123
test_control_group.add_option(
128
, help = "input can either be a prefix or a regex. Will exclude tests that match the provided pattern"
131
parser.add_option_group(test_control_group)
132
# end test_control_group
134
# environment options
135
# define where to find our drizzled, client dirs, working dirs, etc
136
environment_control_group = optparse.OptionGroup(parser,
137
"Options for defining the testing environment")
139
environment_control_group.add_option(
143
, default = basedir_default
144
, 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]"
147
environment_control_group.add_option(
151
, default = "auto-search"
152
, help = "Path to the server executable. [%default]"
155
environment_control_group.add_option(
157
, dest="clientbindir"
159
, default = "auto-search"
160
, help = "Path to the directory containing client program binaries for use in testing [%default]"
163
environment_control_group.add_option(
167
, default = testdir_default
168
, help = "Path to the test dir, containing additional files for test execution. [%default]"
171
environment_control_group.add_option(
175
, default = workdir_default
176
, help = "Path to the directory test-run will use to store generated files and directories. [%default]"
179
environment_control_group.add_option(
182
, action='store_true'
184
, help = "By default, we symlink workdir to a location in shm. Use this flag to not symlink [%default]"
187
environment_control_group.add_option(
189
, dest="libeatmydata"
190
, action='store_true'
192
, help = "Use libeatmydata to disable fsync calls. This greatly speeds up test execution, but data durability is nil. Sets LD_PRELOAD to include the libeatmydata library [%default]"
195
environment_control_group.add_option(
198
, action='store_true'
200
, help = "Don't try to clean up working directories before test execution [%default]"
203
environment_control_group.add_option(
204
"--no-secure-file-priv"
205
, dest = "nosecurefilepriv"
206
, action='store_true'
208
, help = "Turn off the use of --secure-file-priv=vardir for started servers"
212
parser.add_option_group(environment_control_group)
213
# end environment control group
219
, help="Start drizzled using the specified engine [%default]"
224
# supplied will be those arguments matching an option,
225
# and test_cases will be everything else
226
(args, test_cases)= parser.parse_args()
229
variables = organize_options(args, test_cases)