xpcshellcommandline.py (13650B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import argparse 6 7 from mozlog import commandline 8 9 10 def add_common_arguments(parser): 11 parser.add_argument( 12 "--app-binary", 13 type=str, 14 dest="app_binary", 15 default=None, 16 help="path to application binary (eg: c:\\program files\\mozilla firefox\\firefox.exe)", 17 ) 18 parser.add_argument( 19 "--app-path", 20 type=str, 21 dest="appPath", 22 default=None, 23 help="application directory (as opposed to XRE directory)", 24 ) 25 parser.add_argument( 26 "--msix-app-path", 27 type=str, 28 dest="msixAppPath", 29 default=None, 30 help="application directory for msix mode (as opposed to XRE directory)", 31 ) 32 parser.add_argument( 33 "--msix-app-binary", 34 type=str, 35 dest="msix_app_binary", 36 default=None, 37 help="path to application binary for msix mode (eg: c:\\program files\\mozilla firefox\\firefox.exe)", 38 ) 39 parser.add_argument( 40 "--interactive", 41 action="store_true", 42 dest="interactive", 43 default=False, 44 help="don't automatically run tests, drop to an xpcshell prompt", 45 ) 46 parser.add_argument( 47 "--verbose", 48 action="store_true", 49 dest="verbose", 50 default=False, 51 help="always print stdout and stderr from tests", 52 ) 53 parser.add_argument( 54 "--verbose-if-fails", 55 action="store_true", 56 dest="verboseIfFails", 57 default=False, 58 help="Output the log if a test fails, even when run in parallel", 59 ) 60 parser.add_argument( 61 "--keep-going", 62 action="store_true", 63 dest="keepGoing", 64 default=False, 65 help="continue running tests after test killed with control-C (SIGINT)", 66 ) 67 parser.add_argument( 68 "--logfiles", 69 action="store_true", 70 dest="logfiles", 71 default=True, 72 help="create log files (default, only used to override --no-logfiles)", 73 ) 74 parser.add_argument( 75 "--dump-tests", 76 type=str, 77 dest="dump_tests", 78 default=None, 79 help="Specify path to a filename to dump all the tests that will be run", 80 ) 81 parser.add_argument( 82 "--manifest", 83 type=str, 84 dest="manifest", 85 default=None, 86 help="Manifest of test directories to use", 87 ) 88 parser.add_argument( 89 "--no-logfiles", 90 action="store_false", 91 dest="logfiles", 92 help="don't create log files", 93 ) 94 parser.add_argument( 95 "--sequential", 96 action="store_true", 97 dest="sequential", 98 default=False, 99 help="Run all tests sequentially", 100 ) 101 parser.add_argument( 102 "--temp-dir", 103 dest="tempDir", 104 default=None, 105 help="Directory to use for temporary files", 106 ) 107 parser.add_argument( 108 "--testing-modules-dir", 109 dest="testingModulesDir", 110 default=None, 111 help="Directory where testing modules are located.", 112 ) 113 parser.add_argument( 114 "--total-chunks", 115 type=int, 116 dest="totalChunks", 117 default=1, 118 help="how many chunks to split the tests up into", 119 ) 120 parser.add_argument( 121 "--this-chunk", 122 type=int, 123 dest="thisChunk", 124 default=1, 125 help="which chunk to run between 1 and --total-chunks", 126 ) 127 parser.add_argument( 128 "--profile-name", 129 type=str, 130 dest="profileName", 131 default=None, 132 help="name of application profile being tested", 133 ) 134 parser.add_argument( 135 "--build-info-json", 136 type=str, 137 dest="mozInfo", 138 default=None, 139 help="path to a mozinfo.json including information about the build " 140 "configuration. defaults to looking for mozinfo.json next to " 141 "the script.", 142 ) 143 parser.add_argument( 144 "--shuffle", 145 action="store_true", 146 dest="shuffle", 147 default=False, 148 help="Execute tests in random order", 149 ) 150 parser.add_argument( 151 "--xre-path", 152 action="store", 153 type=str, 154 dest="xrePath", 155 # individual scripts will set a sane default 156 default=None, 157 help="absolute path to directory containing XRE (probably xulrunner)", 158 ) 159 parser.add_argument( 160 "--msix-xre-path", 161 action="store", 162 type=str, 163 dest="msixXrePath", 164 # individual scripts will set a sane default 165 default=None, 166 help="absolute path to directory containing XRE in msix mode (probably xulrunner)", 167 ) 168 parser.add_argument( 169 "--symbols-path", 170 action="store", 171 type=str, 172 dest="symbolsPath", 173 default=None, 174 help="absolute path to directory containing breakpad symbols, " 175 "or the URL of a zip file containing symbols", 176 ) 177 parser.add_argument( 178 "--jscov-dir-prefix", 179 action="store", 180 type=str, 181 dest="jscovdir", 182 default=argparse.SUPPRESS, 183 help="Directory to store per-test javascript line coverage data as json.", 184 ) 185 parser.add_argument( 186 "--debugger", 187 action="store", 188 dest="debugger", 189 help="use the given debugger to launch the application", 190 ) 191 parser.add_argument( 192 "--debugger-args", 193 action="store", 194 dest="debuggerArgs", 195 help="pass the given args to the debugger _before_ " 196 "the application on the command line", 197 ) 198 parser.add_argument( 199 "--debugger-interactive", 200 action="store_true", 201 dest="debuggerInteractive", 202 help="prevents the test harness from redirecting " 203 "stdout and stderr for interactive debuggers", 204 ) 205 parser.add_argument( 206 "--jsdebugger", 207 dest="jsDebugger", 208 action="store_true", 209 help="Waits for a devtools JS debugger to connect before starting the test.", 210 ) 211 parser.add_argument( 212 "--jsdebugger-port", 213 type=int, 214 dest="jsDebuggerPort", 215 default=6000, 216 help="The port to listen on for a debugger connection if " 217 "--jsdebugger is specified.", 218 ) 219 parser.add_argument( 220 "--tag", 221 action="append", 222 dest="test_tags", 223 default=None, 224 help="filter out tests that don't have the given tag. Can be " 225 "used multiple times in which case the test must contain " 226 "at least one of the given tags.", 227 ) 228 parser.add_argument( 229 "--utility-path", 230 action="store", 231 dest="utility_path", 232 default=None, 233 help="Path to a directory containing utility programs, such " 234 "as stack fixer scripts.", 235 ) 236 parser.add_argument( 237 "--xpcshell", 238 action="store", 239 dest="xpcshell", 240 default=None, 241 help="Path to xpcshell binary", 242 ) 243 parser.add_argument( 244 "--http3server", 245 action="store", 246 dest="http3server", 247 default=None, 248 help="Path to http3server binary", 249 ) 250 # This argument can be just present, or the path to a manifest file. The 251 # just-present case is usually used for mach which can provide a default 252 # path to the failure file from the previous run 253 parser.add_argument( 254 "--rerun-failures", 255 action="store_true", 256 help="Rerun failures from the previous run, if any", 257 ) 258 parser.add_argument( 259 "--failure-manifest", 260 action="store", 261 help="Path to a manifest file from which to rerun failures " 262 "(with --rerun-failure) or in which to record failed tests", 263 ) 264 parser.add_argument( 265 "--threads", 266 type=int, 267 dest="threadCount", 268 default=0, 269 help="override the number of jobs (threads) when running tests " 270 "in parallel, the default is CPU x 1.5 when running via mach " 271 "and CPU x 4 when running in automation", 272 ) 273 parser.add_argument( 274 "--timeout-factor", 275 type=float, 276 dest="timeoutFactor", 277 default=1.0, 278 help="multiplier for test timeout values", 279 ) 280 parser.add_argument( 281 "--variant", 282 action="store", 283 default="", 284 help="use specified variant for any harness level changes.", 285 ) 286 parser.add_argument( 287 "--setpref", 288 action="append", 289 dest="extraPrefs", 290 metavar="PREF=VALUE", 291 help="Defines an extra user preference (can be passed multiple times.", 292 ) 293 parser.add_argument( 294 "--setenv", 295 action="append", 296 dest="extraEnv", 297 metavar="NAME=VALUE", 298 help="Set one or more environment variable before launching the test " 299 "(can be passed multiple times).", 300 ) 301 parser.add_argument( 302 "testPaths", nargs="*", default=None, help="Paths of tests to run." 303 ) 304 parser.add_argument( 305 "--verify", 306 action="store_true", 307 default=False, 308 help="Run tests in verification mode: Run many times in different " 309 "ways, to see if there are intermittent failures.", 310 ) 311 parser.add_argument( 312 "--verify-max-time", 313 dest="verifyMaxTime", 314 type=int, 315 default=3600, 316 help="Maximum time, in seconds, to run in --verify mode.", 317 ) 318 parser.add_argument( 319 "--headless", 320 action="store_true", 321 default=False, 322 dest="headless", 323 help="Enable headless mode by default for tests which don't specify " 324 "whether to use headless mode", 325 ) 326 parser.add_argument( 327 "--conditioned-profile", 328 action="store_true", 329 default=False, 330 dest="conditionedProfile", 331 help="Run with conditioned profile instead of fresh blank profile", 332 ) 333 parser.add_argument( 334 "--self-test", 335 action="store_true", 336 default=False, 337 dest="self_test", 338 help="Run self tests", 339 ) 340 parser.add_argument( 341 "--run-failures", 342 action="store", 343 default="", 344 dest="runFailures", 345 help="Run failures matching keyword", 346 ) 347 parser.add_argument( 348 "--timeout-as-pass", 349 action="store_true", 350 default=False, 351 dest="timeoutAsPass", 352 help="Harness level timeouts will be treated as passing", 353 ) 354 parser.add_argument( 355 "--crash-as-pass", 356 action="store_true", 357 default=False, 358 dest="crashAsPass", 359 help="Harness level crashes will be treated as passing", 360 ) 361 parser.add_argument( 362 "--disable-fission", 363 action="store_true", 364 default=False, 365 dest="disableFission", 366 help="disable fission mode (back to e10s || 1proc)", 367 ) 368 parser.add_argument( 369 "--repeat", 370 action="store", 371 default=0, 372 type=int, 373 dest="repeat", 374 help="repeat the test X times, default [0]", 375 ) 376 parser.add_argument( 377 "--profiler", 378 action="store_true", 379 default=False, 380 dest="profiler", 381 help="Run the Firefox Profiler and get a performance profile of the " 382 "test. This is useful to find performance issues, and also " 383 "to see what exactly the test is doing.", 384 ) 385 386 387 def add_remote_arguments(parser): 388 parser.add_argument( 389 "--objdir", 390 action="store", 391 type=str, 392 dest="objdir", 393 help="Local objdir, containing xpcshell binaries.", 394 ) 395 396 parser.add_argument( 397 "--apk", 398 action="store", 399 type=str, 400 dest="localAPK", 401 help="Local path to Firefox for Android APK.", 402 ) 403 404 parser.add_argument( 405 "--deviceSerial", 406 action="store", 407 type=str, 408 dest="deviceSerial", 409 help="adb serial number of remote device. This is required " 410 "when more than one device is connected to the host. " 411 "Use 'adb devices' to see connected devices.", 412 ) 413 414 parser.add_argument( 415 "--adbPath", 416 action="store", 417 type=str, 418 dest="adbPath", 419 default=None, 420 help="Path to adb binary.", 421 ) 422 423 parser.add_argument( 424 "--noSetup", 425 action="store_false", 426 dest="setup", 427 default=True, 428 help="Do not copy any files to device (to be used only if " 429 "device is already setup).", 430 ) 431 parser.add_argument( 432 "--no-install", 433 action="store_false", 434 dest="setup", 435 default=True, 436 help="Don't install the app or any files to the device (to be used if " 437 "the device is already set up)", 438 ) 439 440 parser.add_argument( 441 "--local-bin-dir", 442 action="store", 443 type=str, 444 dest="localBin", 445 help="Local path to bin directory.", 446 ) 447 448 parser.add_argument( 449 "--remoteTestRoot", 450 action="store", 451 type=str, 452 dest="remoteTestRoot", 453 help="Remote directory to use as test root (eg. /data/local/tmp/test_root).", 454 ) 455 456 457 def parser_desktop(): 458 parser = argparse.ArgumentParser() 459 add_common_arguments(parser) 460 commandline.add_logging_group(parser) 461 462 return parser 463 464 465 def parser_remote(): 466 parser = argparse.ArgumentParser() 467 common = parser.add_argument_group("Common Options") 468 add_common_arguments(common) 469 remote = parser.add_argument_group("Remote Options") 470 add_remote_arguments(remote) 471 commandline.add_logging_group(parser) 472 473 return parser