xpcshellcommandline.py 9.0 KB

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