Bug 1362047 - Add comment explaining unobvous uses of mockAppInfo() r=kmag
[gecko.git] / testing / xpcshell / xpcshellcommandline.py
bloba50a5c67df47496c53703148fa01ea24fe9962b4
1 import argparse
3 from mozlog import commandline
6 def add_common_arguments(parser):
7 parser.add_argument("--app-path",
8 type=unicode, dest="appPath", default=None,
9 help="application directory (as opposed to XRE directory)")
10 parser.add_argument("--interactive",
11 action="store_true", dest="interactive", default=False,
12 help="don't automatically run tests, drop to an xpcshell prompt")
13 parser.add_argument("--verbose",
14 action="store_true", dest="verbose", default=False,
15 help="always print stdout and stderr from tests")
16 parser.add_argument("--keep-going",
17 action="store_true", dest="keepGoing", default=False,
18 help="continue running tests after test killed with control-C (SIGINT)")
19 parser.add_argument("--logfiles",
20 action="store_true", dest="logfiles", default=True,
21 help="create log files (default, only used to override --no-logfiles)")
22 parser.add_argument("--dump-tests", type=str, dest="dump_tests", default=None,
23 help="Specify path to a filename to dump all the tests that will be run")
24 parser.add_argument("--manifest",
25 type=unicode, dest="manifest", default=None,
26 help="Manifest of test directories to use")
27 parser.add_argument("--no-logfiles",
28 action="store_false", dest="logfiles",
29 help="don't create log files")
30 parser.add_argument("--sequential",
31 action="store_true", dest="sequential", default=False,
32 help="Run all tests sequentially")
33 parser.add_argument("--temp-dir",
34 dest="tempDir", default=None,
35 help="Directory to use for temporary files")
36 parser.add_argument("--testing-modules-dir",
37 dest="testingModulesDir", default=None,
38 help="Directory where testing modules are located.")
39 parser.add_argument("--test-plugin-path",
40 type=str, dest="pluginsPath", default=None,
41 help="Path to the location of a plugins directory containing the test plugin or plugins required for tests. "
42 "By default xpcshell's dir svc provider returns gre/plugins. Use test-plugin-path to add a directory "
43 "to return for NS_APP_PLUGINS_DIR_LIST when queried.")
44 parser.add_argument("--total-chunks",
45 type=int, dest="totalChunks", default=1,
46 help="how many chunks to split the tests up into")
47 parser.add_argument("--this-chunk",
48 type=int, dest="thisChunk", default=1,
49 help="which chunk to run between 1 and --total-chunks")
50 parser.add_argument("--profile-name",
51 type=str, dest="profileName", default=None,
52 help="name of application profile being tested")
53 parser.add_argument("--build-info-json",
54 type=str, dest="mozInfo", default=None,
55 help="path to a mozinfo.json including information about the build configuration. defaults to looking for mozinfo.json next to the script.")
56 parser.add_argument("--shuffle",
57 action="store_true", dest="shuffle", default=False,
58 help="Execute tests in random order")
59 parser.add_argument("--xre-path",
60 action="store", type=str, dest="xrePath",
61 # individual scripts will set a sane default
62 default=None,
63 help="absolute path to directory containing XRE (probably xulrunner)")
64 parser.add_argument("--symbols-path",
65 action="store", type=str, dest="symbolsPath",
66 default=None,
67 help="absolute path to directory containing breakpad symbols, or the URL of a zip file containing symbols")
68 parser.add_argument("--jscov-dir-prefix",
69 action="store", type=str, dest="jscovdir",
70 default=argparse.SUPPRESS,
71 help="Directory to store per-test javascript line coverage data as json.")
72 parser.add_argument("--debugger",
73 action="store", dest="debugger",
74 help="use the given debugger to launch the application")
75 parser.add_argument("--debugger-args",
76 action="store", dest="debuggerArgs",
77 help="pass the given args to the debugger _before_ "
78 "the application on the command line")
79 parser.add_argument("--debugger-interactive",
80 action="store_true", dest="debuggerInteractive",
81 help="prevents the test harness from redirecting "
82 "stdout and stderr for interactive debuggers")
83 parser.add_argument("--jsdebugger", dest="jsDebugger", action="store_true",
84 help="Waits for a devtools JS debugger to connect before "
85 "starting the test.")
86 parser.add_argument("--jsdebugger-port", type=int, dest="jsDebuggerPort",
87 default=6000,
88 help="The port to listen on for a debugger connection if "
89 "--jsdebugger is specified.")
90 parser.add_argument("--tag",
91 action="append", dest="test_tags",
92 default=None,
93 help="filter out tests that don't have the given tag. Can be "
94 "used multiple times in which case the test must contain "
95 "at least one of the given tags.")
96 parser.add_argument("--utility-path",
97 action="store", dest="utility_path",
98 default=None,
99 help="Path to a directory containing utility programs, such "
100 "as stack fixer scripts.")
101 parser.add_argument("--xpcshell",
102 action="store", dest="xpcshell",
103 default=None,
104 help="Path to xpcshell binary")
105 # This argument can be just present, or the path to a manifest file. The
106 # just-present case is usually used for mach which can provide a default
107 # path to the failure file from the previous run
108 parser.add_argument("--rerun-failures",
109 action="store_true",
110 help="Rerun failures from the previous run, if any")
111 parser.add_argument("--failure-manifest",
112 action="store",
113 help="Path to a manifest file from which to rerun failures "
114 "(with --rerun-failure) or in which to record failed tests")
115 parser.add_argument("--threads",
116 type=int, dest="threadCount", default=0,
117 help="override the number of jobs (threads) when running tests in parallel, "
118 "the default is CPU x 1.5 when running via mach and CPU x 4 when running "
119 "in automation")
120 parser.add_argument("testPaths", nargs="*", default=None,
121 help="Paths of tests to run.")
123 def add_remote_arguments(parser):
124 parser.add_argument("--deviceIP", action="store", type=str, dest="deviceIP",
125 help="ip address of remote device to test")
127 parser.add_argument("--devicePort", action="store", type=str, dest="devicePort",
128 default=20701, help="port of remote device to test")
130 parser.add_argument("--objdir", action="store", type=str, dest="objdir",
131 help="local objdir, containing xpcshell binaries")
134 parser.add_argument("--apk", action="store", type=str, dest="localAPK",
135 help="local path to Fennec APK")
138 parser.add_argument("--noSetup", action="store_false", dest="setup", default=True,
139 help="do not copy any files to device (to be used only if device is already setup)")
141 parser.add_argument("--local-lib-dir", action="store", type=str, dest="localLib",
142 help="local path to library directory")
144 parser.add_argument("--local-bin-dir", action="store", type=str, dest="localBin",
145 help="local path to bin directory")
147 parser.add_argument("--remoteTestRoot", action="store", type=str, dest="remoteTestRoot",
148 help="remote directory to use as test root (eg. /mnt/sdcard/tests or /data/local/tests)")
151 def parser_desktop():
152 parser = argparse.ArgumentParser()
153 add_common_arguments(parser)
154 commandline.add_logging_group(parser)
156 return parser
159 def parser_remote():
160 parser = argparse.ArgumentParser()
161 common = parser.add_argument_group("Common Options")
162 add_common_arguments(common)
163 remote = parser.add_argument_group("Remote Options")
164 add_remote_arguments(remote)
165 commandline.add_logging_group(parser)
167 return parser