summaryrefslogtreecommitdiffstats
path: root/testing/talos/talos/cmdline.py
blob: dc7ecd9a09e06f8f7610141300c547b377c87550 (plain)
1
2
3
4
5
6
7
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import argparse
import os

import six
from mozlog.commandline import add_logging_group


class _StopAction(argparse.Action):
    def __init__(
        self,
        option_strings,
        dest=argparse.SUPPRESS,
        default=argparse.SUPPRESS,
        help=None,
    ):
        super(_StopAction, self).__init__(
            option_strings=option_strings,
            dest=dest,
            default=default,
            nargs=0,
            help=help,
        )


class _ListTests(_StopAction):
    def __call__(self, parser, namespace, values, option_string=None):
        from talos import test

        print("Available tests:")
        print("================\n")
        test_class_names = [
            (test_class.name(), test_class.description())
            for test_class in six.itervalues(test.test_dict())
        ]
        test_class_names.sort()
        for name, description in test_class_names:
            print(name)
            print("-" * len(name))
            print(description)
            print()  # Appends a single blank line to the end
        parser.exit()


class _ListSuite(_StopAction):
    def __call__(self, parser, namespace, values, option_string=None):
        from talos.config import suites_conf

        print("Available suites:")
        conf = suites_conf()
        max_suite_name = max([len(s) for s in conf])
        pattern = " %%-%ds (%%s)" % max_suite_name
        for name in conf:
            print(pattern % (name, ":".join(conf[name]["tests"])))
        print()
        parser.exit()


def create_parser(mach_interface=False):
    parser = argparse.ArgumentParser()
    add_arg = parser.add_argument

    if not mach_interface:
        add_arg(
            "-e",
            "--executablePath",
            required=True,
            dest="browser_path",
            help="path to executable we are testing",
        )
    add_arg("-t", "--title", default="qm-pxp01", help="Title of the test run")
    add_arg(
        "--browserWait",
        dest="browser_wait",
        default=5,
        type=int,
        help="Amount of time allowed for the browser to cleanly close",
    )
    add_arg(
        "-a",
        "--activeTests",
        help="List of tests to run, separated by ':' (ex. damp:tart)",
    )
    add_arg("--suite", help="Suite to use (instead of --activeTests)")
    add_arg("--subtests", help="Name of the subtest(s) to run (works only on DAMP)")
    add_arg(
        "--mainthread",
        action="store_true",
        help="Collect mainthread IO data from the browser by setting"
        " an environment variable",
    )
    add_arg(
        "--mozAfterPaint",
        action="store_true",
        dest="tpmozafterpaint",
        help="wait for MozAfterPaint event before recording the time",
    )
    add_arg(
        "--firstPaint",
        action="store_true",
        dest="firstpaint",
        help="Also report the first paint value in supported tests",
    )
    add_arg(
        "--useHero",
        action="store_true",
        dest="tphero",
        help="use Hero elementtiming attribute to record the time",
    )
    add_arg(
        "--userReady",
        action="store_true",
        dest="userready",
        help="Also report the user ready value in supported tests",
    )
    add_arg(
        "--spsProfile",
        action="store_true",
        dest="gecko_profile",
        help="(Deprecated - Use --gecko-profile instead.) Profile the "
        "run and output the results in $MOZ_UPLOAD_DIR.",
    )
    add_arg(
        "--spsProfileInterval",
        dest="gecko_profile_interval",
        type=float,
        help="(Deprecated - Use --gecko-profile-interval instead.) How "
        "frequently to take samples (ms)",
    )
    add_arg(
        "--spsProfileEntries",
        dest="gecko_profile_entries",
        type=int,
        help="(Deprecated - Use --gecko-profile-entries instead.) How "
        "many samples to take with the profiler",
    )
    add_arg(
        "--gecko-profile",
        action="store_true",
        dest="gecko_profile",
        help="Profile the run and output the results in $MOZ_UPLOAD_DIR. "
        "After talos is finished, profiler.firefox.com will be launched in "
        "Firefox so you can analyze the local profiles. To disable "
        "auto-launching of profiler.firefox.com set the "
        "DISABLE_PROFILE_LAUNCH=1 env var.",
    )
    add_arg(
        "--gecko-profile-interval",
        dest="gecko_profile_interval",
        type=float,
        help="How frequently to take samples (ms)",
    )
    add_arg(
        "--gecko-profile-entries",
        dest="gecko_profile_entries",
        type=int,
        help="How many samples to take with the profiler",
    )
    add_arg(
        "--gecko-profile-features",
        dest="gecko_profile_features",
        type=str,
        help="Comma-separated list of features to enable in the profiler",
    )
    add_arg(
        "--gecko-profile-threads",
        dest="gecko_profile_threads",
        type=str,
        help="Comma-separated list of threads to sample",
    )
    add_arg(
        "--gecko-profile-extra-threads",
        dest="gecko_profile_extra_threads",
        type=str,
        help="Comma-separated list of extra threads to add to the default list of threads to profile.",
    )
    add_arg(
        "--extension",
        dest="extensions",
        action="append",
        default=["${talos}/talos-powers"],
        help="Extension to install while running",
    )
    add_arg("--fast", action="store_true", help="Run tp tests as tp_fast")
    add_arg(
        "--symbolsPath",
        dest="symbols_path",
        help="Path to the symbols for the build we are testing",
    )
    add_arg("--xperf_path", help="Path to windows performance tool xperf.exe")
    add_arg(
        "--test_timeout",
        type=int,
        default=1200,
        help="Time to wait for the browser to output to the log file",
    )
    add_arg(
        "--errorFile",
        dest="error_filename",
        default=os.path.abspath("browser_failures.txt"),
        help="Filename to store the errors found during the test."
        " Currently used for xperf only.",
    )
    add_arg(
        "--setpref",
        action="append",
        default=[],
        dest="extraPrefs",
        metavar="PREF=VALUE",
        help="Set a browser preference. May be used multiple times.",
    )
    add_arg(
        "--firstNonBlankPaint",
        action="store_true",
        dest="fnbpaint",
        help="Wait for firstNonBlankPaint event before recording the time",
    )
    add_arg(
        "--pdfPaint",
        action="store_true",
        dest="pdfpaint",
        help="Wait for the first page of a PDF to be rendered",
    )
    add_arg("--webServer", dest="webserver", help="DEPRECATED")
    if not mach_interface:
        add_arg(
            "--develop",
            action="store_true",
            default=False,
            help="useful for running tests on a developer machine."
            " Doesn't upload to the graph servers.",
        )
    add_arg("--cycles", type=int, help="number of browser cycles to run")
    add_arg("--tpmanifest", help="manifest file to test")
    add_arg("--tpcycles", type=int, help="number of pageloader cycles to run")
    add_arg(
        "--tptimeout",
        type=int,
        help="number of milliseconds to wait for a load event after"
        " calling loadURI before timing out",
    )
    add_arg(
        "--tppagecycles",
        type=int,
        help="number of pageloader cycles to run for each page in" " the manifest",
    )
    add_arg(
        "--no-download",
        action="store_true",
        dest="no_download",
        help="Do not download the talos test pagesets",
    )
    add_arg(
        "--sourcestamp",
        help="Specify the hg revision or sourcestamp for the changeset"
        " we are testing.  This will use the value found in"
        " application.ini if it is not specified.",
    )
    add_arg(
        "--repository",
        help="Specify the url for the repository we are testing. "
        "This will use the value found in application.ini if"
        " it is not specified.",
    )
    add_arg(
        "--framework",
        help="Will post to the specified framework for Perfherder. "
        'Default "talos".  Used primarily for experiments on '
        "new platforms",
    )
    add_arg("--print-tests", action=_ListTests, help="print available tests")
    add_arg("--print-suites", action=_ListSuite, help="list available suites")
    add_arg(
        "--no-upload-results",
        action="store_true",
        dest="no_upload_results",
        help="If given, it disables uploading of talos results.",
    )
    add_arg(
        "--profile",
        type=str,
        default=None,
        help="Downloads a profile from TaskCluster and uses it",
    )
    debug_options = parser.add_argument_group("Command Arguments for debugging")
    debug_options.add_argument(
        "--debug",
        action="store_true",
        help="Enable the debugger. Not specifying a --debugger option will"
        "result in the default debugger being used.",
    )
    debug_options.add_argument(
        "--debugger", default=None, help="Name of debugger to use."
    )
    debug_options.add_argument(
        "--debugger-args",
        default=None,
        metavar="params",
        help="Command-line arguments to pass to the debugger itself; split"
        "as the Bourne shell would.",
    )
    add_arg(
        "--code-coverage",
        action="store_true",
        dest="code_coverage",
        help="Remove any existing ccov gcda output files after browser"
        " initialization but before starting the tests. NOTE:"
        " Currently only supported in production.",
    )
    add_arg(
        "--disable-fission",
        action="store_false",
        dest="fission",
        default=True,
        help="Disable Fission (site isolation) in Gecko.",
    )
    add_arg(
        "--project",
        type=str,
        default="mozilla-central",
        help="The project branch we're running tests on. Used for "
        "disabling/skipping tests.",
    )
    add_arg(
        "--screenshot-on-failure",
        action="store_true",
        dest="screenshot_on_failure",
        default=False,
        help="Take a screenshot when the test fails.",
    )

    add_logging_group(parser)
    return parser


def parse_args(argv=None):
    parser = create_parser()
    return parser.parse_args(argv)