83
85
parser = optparse.OptionParser("%prog [options] [tests]")
88
parser.add_option("--blacklist", action="append",
89
help="skip tests listed in the specified blacklist file")
84
90
parser.add_option("-C", "--annotate", action="store_true",
85
91
help="output files annotated with coverage")
86
92
parser.add_option("--child", type="int",
87
93
help="run as child process, summary to given fd")
88
94
parser.add_option("-c", "--cover", action="store_true",
89
95
help="print a test coverage report")
96
parser.add_option("-d", "--debug", action="store_true",
97
help="debug mode: write output of test scripts to console"
98
" rather than capturing and diff'ing it (disables timeout)")
90
99
parser.add_option("-f", "--first", action="store_true",
91
100
help="exit on the first test failure")
101
parser.add_option("--inotify", action="store_true",
102
help="enable inotify extension when running tests")
92
103
parser.add_option("-i", "--interactive", action="store_true",
93
104
help="prompt to accept changed output")
94
105
parser.add_option("-j", "--jobs", type="int",
95
106
help="number of jobs to run in parallel"
96
107
" (default: $%s or %d)" % defaults['jobs'])
108
parser.add_option("--keep-tmpdir", action="store_true",
109
help="keep temporary directory after running tests")
97
110
parser.add_option("-k", "--keywords",
98
111
help="run tests matching keywords")
99
parser.add_option("--keep-tmpdir", action="store_true",
100
help="keep temporary directory after running tests")
101
parser.add_option("--tmpdir", type="string",
102
help="run tests in the given temporary directory"
103
" (implies --keep-tmpdir)")
104
parser.add_option("-d", "--debug", action="store_true",
105
help="debug mode: write output of test scripts to console"
106
" rather than capturing and diff'ing it (disables timeout)")
107
parser.add_option("-R", "--restart", action="store_true",
108
help="restart at last error")
112
parser.add_option("-l", "--local", action="store_true",
113
help="shortcut for --with-hg=<testdir>/../hg")
114
parser.add_option("-n", "--nodiff", action="store_true",
115
help="skip showing test changes")
109
116
parser.add_option("-p", "--port", type="int",
110
117
help="port on which servers should listen"
111
118
" (default: $%s or %d)" % defaults['port'])
119
parser.add_option("--pure", action="store_true",
120
help="use pure Python code instead of C extensions")
121
parser.add_option("-R", "--restart", action="store_true",
122
help="restart at last error")
112
123
parser.add_option("-r", "--retest", action="store_true",
113
124
help="retest failed tests")
114
125
parser.add_option("-S", "--noskips", action="store_true",
116
127
parser.add_option("-t", "--timeout", type="int",
117
128
help="kill errant tests after TIMEOUT seconds"
118
129
" (default: $%s or %d)" % defaults['timeout'])
130
parser.add_option("--tmpdir", type="string",
131
help="run tests in the given temporary directory"
132
" (implies --keep-tmpdir)")
119
133
parser.add_option("-v", "--verbose", action="store_true",
120
134
help="output verbose messages")
121
parser.add_option("-n", "--nodiff", action="store_true",
122
help="skip showing test changes")
135
parser.add_option("--view", type="string",
136
help="external diff viewer")
123
137
parser.add_option("--with-hg", type="string",
125
139
help="test using specified hg script rather than a "
126
140
"temporary installation")
127
parser.add_option("--local", action="store_true",
128
help="shortcut for --with-hg=<testdir>/../hg")
129
parser.add_option("--pure", action="store_true",
130
help="use pure Python code instead of C extensions")
131
141
parser.add_option("-3", "--py3k-warnings", action="store_true",
132
142
help="enable Py3k warnings on Python 2.6+")
133
parser.add_option("--inotify", action="store_true",
134
help="enable inotify extension when running tests")
135
parser.add_option("--blacklist", action="append",
136
help="skip tests listed in the specified blacklist file")
138
144
for option, default in defaults.items():
139
145
defaults[option] = int(os.environ.get(*default))
140
146
parser.set_defaults(**defaults)
141
147
(options, args) = parser.parse_args()
149
# jython is always pure
150
if 'java' in sys.platform or '__pypy__' in sys.modules:
143
153
if options.with_hg:
144
154
if not (os.path.isfile(options.with_hg) and
145
155
os.access(options.with_hg, os.X_OK)):